[R] Overlapping x - axis lables

Patrick Connolly p_connolly at slingshot.co.nz
Fri Nov 27 09:04:02 CET 2009


On Thu, 26-Nov-2009 at 11:03PM -0800, Julia Cains wrote:

|> Dear Sir,
|> 
|> Thanks again for your help. Sir, actually I am working on a data containing 84 months and the corresponding savings (core) balances and non-core balances and I am plotting a stacked bar.
|> 
|> The original code I am using is as follows
|> 
|> x = read.csv('core-noncore.csv')
|> 
|> x2 <- data.frame(rep(x$month, 2), stack(x, select = -month))?? 
|> names(x2) <- c('month', 'Count', 'Type')
|> library(lattice)
|> barchart(Count ~ month, groups = Type, data =x2, horizontal = FALSE, stack =TRUE, auto.key = list(columns = 2))?????? # stacked? vertical bar chart
|> 
|> However, when I try to apply the code given by you, its showing the error 
|> "plot.new has not been called yet"
|> 

|> Sir, is it that the command works only with plot command and not
|> with barchart.

More or less: more accurately, it works with base graphics, not with
lattice graphics.

If you wish to use lattice, you can make similar customizations using
the scales list.  Look through the help for xyplot, and search for
scales.  If you know how to make lists, you can use the same ideas
that the axis() function uses to customize the axes.

HTH



|> Warm regards
|> 
|> Julia
|> 
|> 
|> ************************************************
|> 
|> 
|> 
|> Only a man of Worth sees Worth in other men
|> 
|> 
|> 
|> ************************************************
|> 
|> --- On Fri, 11/27/09, Dennis Murphy <djmuser at gmail.com> wrote:
|> 
|> From: Dennis Murphy <djmuser at gmail.com>
|> Subject: Re: [R] Overlapping x - axis lables
|> 
|> Date: Friday, November 27, 2009, 6:36 AM
|> 
|> Hi Julia:
|> 
|> Two things:
|> ? (i) use axes = FALSE in your initial call to plot();
|> ? (ii) use axis(1, at = 10 * (0:10))?? if you want it by tens, for example
|> ??????????????? axis(2)????? # use default
|> ??????????????? box()???????? # if you want a box around the plot.
|> 
|> ?axis is your friend here.
|> 
|> HTH,
|> Dennis
|> 
|> 
|> 
|> Dear R helpers
|> 
|> 
|> 
|> Suppose I am plotting a simple scatter plot where no of paired observations (x,y) are say 100.
|> 
|> 
|> 
|> 
|> 
|> month ? ? ???? length
|> 
|> 1??????? ? ? ? ? ?? 10
|> 
|> 2???????? ? ? ? ? ? 12
|> 
|> 3?????????????????? 17
|> 
|> 4??????? ?????????? 21
|> 
|> 5?????????????????? 13
|> 
|> ..........................
|> 
|> ..........................
|> 
|> ..........................
|> 
|> 
|> 
|> 100????????????? 16
|> 
|> 
|> 
|> 
|> 
|> 
|> 
|> when i run the command
|> 
|> 
|> 
|> plot(month, length)
|> 
|> 
|> 
|> the required plot is generated. But the problem is that on? the X - axis, month values are also printed and it becomes difficult to read the month values on the graph.
|> 
|> ?
|> 
|> (Actually I am working on a stacked graph where I am facing this problem..)
|> 
|> 
|> 
|> So, how to display only few month values (say 1, 5, 10 and so on) without affecting the original graph i.e. the graph should display all the data 100 points but on x - axix only few month values should be displayed in order to improve the readability.
|> 
|> 
|> 
|> 
|> Thanking in advance
|> 
|> 
|> 
|> Julia
|> 
|> 
|> 
|> 
|> 
|> 
|> 
|> 
|> 
|> ************************************************
|> 
|> 
|> 
|> 
|> 
|> 
|> 
|> Only a man of Worth sees Worth in other men
|> 
|> 
|> 
|> 
|> 
|> 
|> 
|> ************************************************
|> 
|> 
|> 
|> 
|> 
|> 
|> 
|>  ? ? ? ?[[alternative HTML version deleted]]
|> 
|> 
|> 
|> 
|> ______________________________________________
|> 
|> R-help at r-project.org mailing list
|> 
|> https://stat.ethz.ch/mailman/listinfo/r-help
|> 
|> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
|> 
|> and provide commented, minimal, self-contained, reproducible code.
|> 
|> 
|> 
|> 
|> 
|> 
|> 
|>       
|> 	[[alternative HTML version deleted]]
|> 

|> ______________________________________________
|> R-help at r-project.org mailing list
|> https://stat.ethz.ch/mailman/listinfo/r-help
|> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
|> and provide commented, minimal, self-contained, reproducible code.


-- 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.   
   ___    Patrick Connolly   
 {~._.~}                   Great minds discuss ideas    
 _( Y )_  	         Average minds discuss events 
(:_~*~_:)                  Small minds discuss people  
 (_)-(_)  	                      ..... Eleanor Roosevelt
	  
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.




More information about the R-help mailing list