Hi,
I'm trying to do graphs with ggplot2. However, I have a problem with my axis.
I need to add breaks at axis, that why, I'm using break.axis.
As I googled and as I know, we can use the function axis.break. I'm using the following script with "mtcars" data just to simplify my problem:
head(mtcars)
A <- ggplot(mtcars, aes(x=cyl, y=disp)) +
geom_path(linetype= 3, size = 0.2, col="bisque1") +
geom_point(size = 2, shape=15, col="bisque1") +
scale_x_continuous(element_blank(), limits = c(0, 400), expand = c(0, 0))+
scale_y_continuous(element_blank(), expand = c(0, 0)) + expand_limits(y=c(0,500))
B <- A + geom_path(data = mtcars, aes(x= hp , y= disp), linetype= 3, size = 0.2, col="tan") +
geom_point(data = mtcars, aes(x=hp , y= disp), size = 2, shape=15, col="tan") +
geom_path(data = mtcars, aes(x= drat , y= disp), linetype= 3, size = 0.2, col="bisque4") +
geom_point(data = mtcars, aes(x= drat , y= disp), size = 2, shape=15, col="bisque4") +
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
panel.background = element_blank(), axis.line = element_line(colour = "black"),
axis.title.x = element_text(colour = "black", size=15),
axis.title.y = element_text(colour = "black", size=15),
axis.text = element_text(colour = "black", size=10))
B
# I used the following script as I found on google that axis.break works with plot and not ggplot2
plot.new()
plot(B)
axis.break(axis=1,breakpos=2.5,pos=1, breakcol="black", style="slash", bgcol="white")
The problem is when I'm running it, I have no error message but I can't see the breaks on axis (see figure).
Do anyone have a solution? and I really appreciate any help. I really want to see break slash (see figure)
Thanks in advance
Amonda