Re: [R] ggplot not showing all the years on the x-axis

2013-01-08 Thread Yao He
Hi,this is a question about how to set the scale,try this
add a scale_x_discrete() like that:

plot - tmpplot + geom_line()+scale_x_continuous(breaks=ii)


Yao He


2013/1/8 Francesco Sarracino f.sarrac...@gmail.com:
 Dear R helpers,

 I am currently having hard time fixing the values on the x-axis of a plot
 with ggplot: even though I have 12 years, ggplot plots only 3 of them.
 Here is my example:

 library(ggplot2)
 ii - 2000:2011
 ss - rnorm(12,0,1)
 pm - data.frame(ii,ss)
 tmpplot - ggplot(pm, aes(x = ii, y = ss))
 plot - tmpplot + geom_line()
 plot

 In my case, ggplot reports on the year 2000, 2004 and 2008 on the x-axis,
 but I'd like to have all the years from 2000 to 2011. I know how to fix
 this with the standard plot in R, but for consistency I'd like to use
 ggplot.
 Can anyone help?
 thanks in advance,
 f.

 [[alternative HTML version deleted]]

 __
 R-help@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.



-- 
—
Master candidate in 2rd year
Department of Animal genetics  breeding
Room 436,College of Animial ScienceTechnology,
China Agriculture University,Beijing,100193
E-mail: yao.h.1...@gmail.com
——

__
R-help@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.


Re: [R] ggplot not showing all the years on the x-axis

2013-01-08 Thread Francesco Sarracino
Indeed, it works. I've been mumbling around with scale_x_discrete(), but
without any success.
Thanks a lot, Yao. You helped me a lot!
f.


On 8 January 2013 10:06, Yao He yao.h.1...@gmail.com wrote:

 Hi,this is a question about how to set the scale,try this
 add a scale_x_discrete() like that:

 plot - tmpplot + geom_line()+scale_x_continuous(breaks=ii)


 Yao He


 2013/1/8 Francesco Sarracino f.sarrac...@gmail.com:
  Dear R helpers,
 
  I am currently having hard time fixing the values on the x-axis of a plot
  with ggplot: even though I have 12 years, ggplot plots only 3 of them.
  Here is my example:
 
  library(ggplot2)
  ii - 2000:2011
  ss - rnorm(12,0,1)
  pm - data.frame(ii,ss)
  tmpplot - ggplot(pm, aes(x = ii, y = ss))
  plot - tmpplot + geom_line()
  plot
 
  In my case, ggplot reports on the year 2000, 2004 and 2008 on the x-axis,
  but I'd like to have all the years from 2000 to 2011. I know how to fix
  this with the standard plot in R, but for consistency I'd like to use
  ggplot.
  Can anyone help?
  thanks in advance,
  f.
 
  [[alternative HTML version deleted]]
 
  __
  R-help@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.



 --
 —
 Master candidate in 2rd year
 Department of Animal genetics  breeding
 Room 436,College of Animial ScienceTechnology,
 China Agriculture University,Beijing,100193
 E-mail: yao.h.1...@gmail.com
 ——




-- 
Francesco Sarracino, Ph.D.
https://sites.google.com/site/fsarracino/

[[alternative HTML version deleted]]

__
R-help@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.