0

I have below provided an example of the problem that I am trying to solve. As you can see that I have the y-axes names in the middle of the graph. Is there any way to remove those y-axes names? Thanks in advance.

library(ggbreak) library(patchwork) library(ggplot2) x = c(0,0.1,0.5, 2, 3, 5, 7, 10, 100) y1 = c(892, 1059, 1004, 1020, 1097, 903, 881,1096, 910) y2 = c(2070, 2183, 2381, 2406, 2675, 2639, 2662, 2523, 2453) data = data.frame(x=x, y1 = y1, y2 = y2) ggplot(data=data,aes(x = x ,y=y1))+ geom_point(aes(y=y1), color = "black")+ geom_point(data = data,aes(x=x,y=y2),colour="blue")+ scale_y_continuous("Y1", sec.axis = sec_axis(y2~ .*(5) , name = "Y2"))+ xlab("x") + ylab("")+ expand_limits(x = 0, y = 0)+ scale_x_break(c(12, 90)) 

enter image description here

0

2 Answers 2

1

Instead of using ggbreak one option would be to use just ggplot2 and patchwork which gives you "full" control to style the axes, to add and remove axis labels, ... :

library(patchwork) library(ggplot2) p <- ggplot(data = data, aes(x = x, y = y1)) + geom_point(aes(y = y1), color = "black") + geom_point(data = data, aes(x = x, y = y2), colour = "blue") + labs(x = "x", y = NULL) + expand_limits(x = 0, y = 0) p1 <- p + scale_y_continuous("Y1", sec.axis = sec_axis(y2 ~ . * (5), name = NULL)) + coord_cartesian(xlim = c(NA, 12)) p2 <- p + scale_y_continuous(name = NULL, sec.axis = sec_axis(y2 ~ . * (5), name = "Y2")) + coord_cartesian(xlim = c(90, NA)) + theme(axis.text.y = element_blank(), axis.ticks.y = element_blank()) p1 + p2 

Sign up to request clarification or add additional context in comments.

Comments

0

Try:

+theme(axis.title.y = element_blank()) 

1 Comment

This eliminates all y-axes labels. I want to remove the names of the y-axes that are circled in red.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.