I have plotly
graphics where I'd like to change axis tick mark labels to specific strings. Consider the following example:
library(plotly)
p <- plot_ly(data = iris, x = ~Sepal.Length, y = ~Petal.Length)
Say I want to supress all numeric xaxis tick mark labels and instead only plot the string "min" at x = 4.5
and "max" at x = 8
.
How can I achieve this in plotly
?
Sidenote: I know this is possible for base R plots, e.g. here and in ggplot2
by setting scale_x_continuous(breaks = c(4.5, 8), labels= c("4.5" = "min", "8" = "max"))
.
Is there also a way to achieve this in plotly
?
..Unfortunately the plotly
docs don't seem to offer a solution..
ggplotly
function to get a similar result:p2 = ggplot(iris, aes(Sepal.Length, Petal.Length)) + geom_point(colour=hcl(255,100,65)) + theme_bw() + scale_x_continuous(breaks=5:8, labels=LETTERS[5:8]); ggplotly(p2)
. The theme can be tweaked a bit more to get closer to the p - eipi10ticktext
could be useful. - eipi10ggplotly
pipes fromggplot2
toplotly
. It shows howplotly_json(p2)
would show what is being sent toplotly
so that you might recreate it more directly inside yourplot_ly
function. moderndata.plot.ly/… - Jon Spring