2

There must be an easier way to add customized ticks and labels in a plot using ggplot2 than creating custom function to do it like some answers in the forum...

Here's my code,

data<-data.frame(WS_Spd_WVT=c(0.5,1.2,4.2,0.3),C_E=c(100,200,150,50))
plot8 <- ggplot(data=data,aes(x=WS_Spd_WVT,y=C_E)) + geom_point(color='blue') + 
  scale_y_continuous(breaks=seq(-200,500,by=100)) + 
  ylim(-100,500) +
  theme(panel.background =        element_rect(fill='white',color='black'),panel.grid.major=element_line(size=0.5,color='gray'),panel.      grid.minor=element_line(size=0.25,color='gray')) + 
  ylab(expression('C'[E])) + xlab('U') +       scale_x_continuous(breaks=seq(0,14,by=1),minor_breaks=seq(0,14,by=0.5))
plot8

I just need to add 0.5 tick marks with labels (e.g., 1.5,2.0,2.5, etc) for the x-axis and (50, 100,150, 200, etc.) for the y-axis. Is it possible to add even minor ticks to the minor tick marks for the y-axis?

While I am at it, anyway to change the major axis label size and the minor axis label size separately instead of using 'base_size?'

Yusri
  • 282
  • 1
  • 4
  • 16
  • I'm sure this question has been asked and answered here before. Did you do a search? – Rich Scriven Sep 20 '14 at 03:55
  • Yes I did, couldn't find a simple answer, some of them requiring additional custom function. Isn't there a simple in scale_x_continuous() or other function argument that just enable minor ticks? – Yusri Sep 20 '14 at 06:39
  • generally speaking, people write custom functions when the functionality is not available in a more straight-forward form. AFAIK, there isn't a way to have minor tick marks in ggplot2. – baptiste Sep 20 '14 at 13:28
  • Ok thank you then, I am just surprised there isn't anything simpler. – Yusri Sep 21 '14 at 03:14
  • See [this answer](https://stackoverflow.com/questions/18081746/controlling-both-the-major-and-minor-grid-lines-on-the-y-axis) to the same question. – John Nov 06 '17 at 20:29

0 Answers0