Reputation: 1265
I have created an R dataframe as follows
A<-data.frame("Col1"= c(21.5 ,22.5 ,15.5, 20.5 ,17.5 ,14.5 ,23.5, 11.5, 16.5, 25.5 ,18.5, 24.5 ,10.5 , 9.5, 19.5, 26.5, 13.5, 12.5 ,27.5, 4.5 , 5.5, 8.5, 6.5, 7.5))
A$Col2=c(0.619219548, 0.723265668,0.122833055, 0.536849680, 0.257225692 ,0.081648474, 0.794797325 ,0.023125359, 0.194364553, 0.909681117, 0.343930779, 0.857658382, 0.018791029 ,0.014457257, 0.467485576 ,0.950865217, 0.062140165, 0.040464671, 0.989875246, 0.001502443,0.003637989 ,0.012290763, 0.005796326, 0.007959621)
I have created the following plot on log scale using ggplot2 package
library(scales)
library(ggplot2)
chart_1<-ggplot(A, aes(x=Col1, y=Col2)) + geom_point()+ geom_smooth(method = "lm")+
scale_x_log10(minor_breaks = seq(0,max(A$Col1)*10 , 0.1), breaks = pretty_breaks())+
scale_y_log10(minor_breaks = seq(0,100,0.1))+ annotation_logticks(sides = "lb", outside =
FALSE,short = unit(1,"mm"), mid = unit(3,"mm"),long = unit(6,"mm")) + theme( panel.grid.major
= element_line(colour = "red", size = 0.5), panel.grid.minor= element_line(colour = "green",
size = 0.2))
In this I am able to generate a Y axis with uniform 9 annotation logticks between 2 major gridlines. ie between 0.001 - 0.01, 0.01 - 0.1 ,0.1 - 1, the axis is divided equally into 10 divisions. I would like the same to be done along the x axis dynamically. I am unable to accomplish the same. I request someone to guide me in this regard. Many thanks in advance
Upvotes: 0
Views: 151
Reputation: 123
I believe your code is working just fine. The annotation_logticks will write 10 marks between each log10 default scale values. This way, you have 10 tickmarks between 0.01 and 0.1, 10 tickmarks between 0.1 and 1, 10 tickmarks between 1 and 10 (you can see in your x-axis the marks on 5,6,7,8,9 and 10; and 10 tickmarks between 10 and 100 -> 20,20,40...100. You can see the tickmark on 20 and 30 on your x-axis.
Upvotes: 1