1

I want to, on the X-axis add in tick marks for 250, 750, 1250, 1750, but don't add the numbers (just the tick marks). This would show numbers for every other tick mark. So half the tick marks on the x axis would have numbers and the other half would be blank.

ggplot(data = AvsCa, aes(x = Ca, y = A, group = Light_Level, color = Light_Level))+
  geom_point()+
  geom_line()+
  labs(y=expression("CO"["2"]*~"Assimilation Rate"~italic(A)~"(µmol"~~m^-2*s^-1*")"),
       x=expression("Ambient CO"["2"]*~"Concentration, C"["a"]*~"(µmol mol"^-1*")"))+
  scale_y_continuous(sec.axis=dup_axis())+
  theme_set(theme_bw())+
  theme(axis.text = element_text(size = 11),
        axis.ticks.length=unit(-0.1, "cm"), 
        axis.text.x.top=element_blank(), 
        axis.text.y.right=element_blank(),
        axis.title.x.top=element_blank(),
        axis.title.x = element_text(margin = unit(c(5, 0, 0, 0), "mm")),
        axis.title.y.right=element_blank(),
        axis.title.y = element_text(margin = unit(c(0, 5, 0, 0), "mm")),
        panel.grid.major = element_blank(), 
        panel.grid.minor = element_blank(), 
        legend.position = c(.2,.8))+ 
        scale_color_discrete(name= expression(italic(Q["in"])~"(Light Intensity)"),
                             labels=c(expression("1000 µmol m"^-2*s^-1),
                                      expression("1500 µmol m"^-2*s^-1)))
IRTFM
  • 258,963
  • 21
  • 364
  • 487
glennca
  • 11
  • 1
  • It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input hat can be used to test and verify possible solutions. – MrFlick Aug 11 '21 at 05:00

1 Answers1

1

Here is a way to replace every 2nd tick label with empty text. Simplified for brevity and reproducibility:

library(ggplot2)

ggplot(mpg, aes(displ, cty)) +
  geom_point() +
  scale_x_continuous(
    labels = function(x) {
      x[seq_along(x) %% 2 == 1] <- ""
      x
    }
  )

Created on 2021-08-11 by the reprex package (v1.0.0)

teunbrand
  • 33,645
  • 4
  • 37
  • 63