0

My plot. I want it shows y-axis as the second posted image

enter image description here -

enter image description here - the annotations of which I want

  • 2
    Have you try `scale_y_log10` function ? If it is not what you are looking for, can you provide a reproducible example: https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – dc37 Mar 18 '20 at 04:00
  • I used the code as follows. But whatever I change the minor part, I can't get what I expected. p <- ggplot(data = data, mapping = aes(x = date, y = total_cases, color = location)) + geom_line() + scale_x_date( date_breaks = "1 month", labels = date_format("%b %d") ) + scale_y_log10( breaks = trans_breaks("log10", function(x) 10^x), labels = trans_format("log10", math_format(10^.x)) ) + xlab(label = "Date (Y2020)") + ylab(label = "Total cases") ggplotly() – Peter Keller Mar 18 '20 at 04:03
  • 1
    Hi Peter. The issue is probably not related to `ggplot2`. Checked on some example data. And to me everything looks fine. However, when converting to plotly via ´ggplotly` the labels break. – stefan Mar 18 '20 at 07:59
  • @stefan, thank you for the idea. Do you know a fix? – Peter Keller Mar 19 '20 at 00:45
  • 1
    Hi Peter. Unfortunately no. Using math format or greek letters, super- and subscripts in ggplot2 for axis and tick labels requires an object of type `expression()`. However at least with `ggplotly` this seems not possible (at the moment). Either I get the warning `In is.na(ticktext) :is.na() applied to non-(list or vector) of type 'expression'` or the error `Error in unique.default(x) : unique() applies only to vectors`. I would suggest to check the documentation of plotly and/or edit your question to focus on this issue. – stefan Mar 19 '20 at 06:24
  • Thanks to Stefan. Your reply solved my confusion. – Peter Keller Mar 20 '20 at 07:04

0 Answers0