I want to plot a beta distribution in a double logarithmic plot.
x <- seq(0, 1, length=1001)
y <- dbeta(x, 0.1, 0.1)
plot(x, y, type="h", log="xy")
The xtics are set at
0.001
0.005
0.01 (without label)
0.05
0.1 (without label)
0.5
1 (without label)
How can I determine:
-
that labels are given for the main decimal positions (1.0, 0.1, 0.01, 0.001, 0.0001,…)
-
that tics should be drawn for 9 position between the decimal positions (for the region between 0.01 and 0.1 it would be 0.01, 0.02, 0.03,….)
-
that the maximum y-range should be 0.5
Thanks for your help.
Sven
For fine control of the axes, plot them separately, so first suppress the axes by using argument
axes = FALSEin theplot()call:Then add the axes as you want them
Question 2 can be answered in the same way, you just need to specify the locations for the tick marks, perhaps setting argument argument
tclin theaxis()call to be a bit smaller than default (which is-0.5). The tricky bit is in generating the minor ticks you want. I could only come up with this:or
which both give:
We use them via another call to
axis():We suppress labels here using
labels = NA. You just need to work out how to do the vectors forat…Putting the two steps together we have:
Which produces:
As for question 3, what do you mean the maximum range? You can set the limits on the y-axis using the
ylimargument toplot(). You provide the limits (min and max) like soBut a range on it’s own is not sufficient to define the limits, you’d need to tell us one of the min or max values to show on the plot or the actual range of values you want.