Reputation: 819
I found another answer here but it doesn't quite solve my problem.
I'm trying to adjust the log scale for the y axis on one of my box plots so that it ranges from 0 to 100,000. (it is currently at 0 to 10,000)
I have been playing around with the correct limits to set to give me the y axis below. But it doesn't get it exactly right.
How do I set the log scale for another boxplot to go from 10, 100, 1,000,10,000,100,000?
here's my code:
boxplot(RESULTS ~ ID, data=ywater, boxfill=colors,
names=c(" ","Site L1", " ", " ", "Site L2", " ", " ", "Site L3", " "), yaxt="n",
ylab="Concentration (cfu/100 mL)", log="y", ylim=c(1 , 100000))
legend('topleft', horiz = FALSE, fill = unique(colors), legend =levels(y$ANALYTE), bty = 'n')
axis(side=2, font=1)
Upvotes: 0
Views: 1434
Reputation: 32548
set.seed(42)
mydata = data.frame(y = c(sample(10:100000,200)))
boxplot(mydata$y, log = "y", yaxt = "n", ylim = c(10,100000), xaxs="i", yaxs="i")
axis(side=2, font=1, at = c(10,100,1000,10000,100000),
labels = c("10", "100", "1,000","10,000","100,000"), las =2)
Upvotes: 1