Log scaling in both axis

147 views Asked by At

I am trying to make a 2D plot in which both axis are log scaled. In my case, I am working with these data frame:

my_data = data.frame(oX = c(90, 95, 97.5, 99, 99.5, 99.75, 99.9), 
                    obs.P1 = c(10.02099, 5.01323, 2.50981, 1.00575, 0.50388, 0.25591, 0.10194))

And the "raw" (not scaled) plot looks somehow like this:

plot without axis scaling

To plot using ggplot, I run the following:

ggplot(my_data, aes(x = oX, y = obs.P1)) +
  geom_line(aes(y = obs.P1), color='midnightblue', size = 1) + 
  geom_point(aes(y = obs.P1), color='midnightblue', size = 2.5) +
  scale_x_continuous(trans = 'log10') + scale_y_continuous(trans = 'log10')

and I get the following figure:

ggplot2 with failed axis scaling

Using R graphics I get similar results. The script is this one:

plot(my_data$oX, my_data$obs.P1, log = 'xy')

And the figure:

R basics plot with failed axis scaling

The problem is that when I try to scale both axis, I cannot see any changes in the x-axis (whilst the y-axis is log-scaled compared to the original plot, the x-axis remains in linear scale). Any idea about what am I doing wrong?

0

There are 0 answers