0

https://ggplot2.tidyverse.org/reference/annotation_logticks.html

There is a package for logticks, but it is not for basic R graphics. Is there a ready-to-use function to easily generate the ticks (with the range as the input argument) that would be printed nicely so that they can be used with basic R graphics (the axis() command specifically)?

For example, between 10 and 100, I may want to have major ticks at 10, 20, ..., 90, 100, and minor ticks at 11, ..., 19, 21, ...,29, ..., 91, ..., 99.

Between 100 and 1000, the ticks will be just the above ones multiple by 10. For other ranges, the ticks can be similarly defined.

So if I have an input range of 15 and 150. I will have all the ticks described above that are within 15 and 150 as output.

The function should be relatively flexible. For example, I may reduce the frequency of major ticks, say to keep the ones at 10, 20, 50, 100. But the minor ticks can still remain as is, plus, the additional ones like 30, 40, 60, 70, 80, 90.

Another flexibility may be uses people can specify how many major ticks and minor ticks should be (but needs to be rounded so that the ticks are not an awkward place).

user1424739
  • 11,937
  • 17
  • 63
  • 152
  • 2
    plot(1, log="y"); see also ?axTicks and ?pretty –  Mar 27 '22 at 13:22
  • Not sure if these answers my question. axTicks seems to work on something already plotted. But I need to compute the ticks with just the range as the input. pretty is not for log scale. – user1424739 Mar 27 '22 at 14:31
  • this SO question has some useful answers (I think): https://stackoverflow.com/questions/47890742/logarithmic-scale-plot-in-r –  Mar 27 '22 at 15:07

0 Answers0