annotation_logticks
Adds log tick marks with diminishing spacing to the plot and then convert them with ggplotly
a <- ggplot(msleep, aes(bodywt, brainwt)) + geom_point(na.rm = TRUE) + scale_x_log10( breaks = scales::trans_breaks("log10", function(x) 10^x), labels = scales::trans_format("log10", scales::math_format(10^.x)) ) + scale_y_log10( breaks = scales::trans_breaks("log10", function(x) 10^x), labels = scales::trans_format("log10", scales::math_format(10^.x)) ) + theme_bw() p <- a + annotation_logticks() # Default: log ticks on bottom and left
plotly::ggplotly(p)
## Warning in geom2trace.default(dots[[1L]][[1L]], dots[[2L]][[1L]], dots[[3L]][[1L]]): geom_GeomLogticks() has yet to be implemented in plotly. ## If you'd like to see this geom implemented, ## Please open an issue with your example code at ## https://github.com/ropensci/plotly/issues
## Warning in is.na(ticktext): is.na() applied to non-(list or vector) of type ## 'expression' ## Warning in is.na(ticktext): is.na() applied to non-(list or vector) of type ## 'expression'
a <- ggplot(msleep, aes(bodywt, brainwt)) + geom_point(na.rm = TRUE) + scale_x_log10( breaks = scales::trans_breaks("log10", function(x) 10^x), labels = scales::trans_format("log10", scales::math_format(10^.x)) ) + scale_y_log10( breaks = scales::trans_breaks("log10", function(x) 10^x), labels = scales::trans_format("log10", scales::math_format(10^.x)) ) + theme_bw() p <- a + annotation_logticks(sides = "lr") # Log ticks for y, on left and right
plotly::ggplotly(p)
## Warning in geom2trace.default(dots[[1L]][[1L]], dots[[2L]][[1L]], dots[[3L]][[1L]]): geom_GeomLogticks() has yet to be implemented in plotly. ## If you'd like to see this geom implemented, ## Please open an issue with your example code at ## https://github.com/ropensci/plotly/issues
## Warning in is.na(ticktext): is.na() applied to non-(list or vector) of type ## 'expression' ## Warning in is.na(ticktext): is.na() applied to non-(list or vector) of type ## 'expression'
a <- ggplot(msleep, aes(bodywt, brainwt)) + geom_point(na.rm = TRUE) + scale_x_log10( breaks = scales::trans_breaks("log10", function(x) 10^x), labels = scales::trans_format("log10", scales::math_format(10^.x)) ) + scale_y_log10( breaks = scales::trans_breaks("log10", function(x) 10^x), labels = scales::trans_format("log10", scales::math_format(10^.x)) ) + theme_bw() p <- a + annotation_logticks(sides = "trbl") # All four sides
plotly::ggplotly(p)
## Warning in geom2trace.default(dots[[1L]][[1L]], dots[[2L]][[1L]], dots[[3L]][[1L]]): geom_GeomLogticks() has yet to be implemented in plotly. ## If you'd like to see this geom implemented, ## Please open an issue with your example code at ## https://github.com/ropensci/plotly/issues
## Warning in is.na(ticktext): is.na() applied to non-(list or vector) of type ## 'expression' ## Warning in is.na(ticktext): is.na() applied to non-(list or vector) of type ## 'expression'
a <- ggplot(msleep, aes(bodywt, brainwt)) + geom_point(na.rm = TRUE) + scale_x_log10( breaks = scales::trans_breaks("log10", function(x) 10^x), labels = scales::trans_format("log10", scales::math_format(10^.x)) ) + scale_y_log10( breaks = scales::trans_breaks("log10", function(x) 10^x), labels = scales::trans_format("log10", scales::math_format(10^.x)) ) + theme_bw() p <- a + annotation_logticks(sides = "lr", outside = TRUE) + coord_cartesian(clip = "off") # Ticks outside plot
plotly::ggplotly(p)
## Warning in geom2trace.default(dots[[1L]][[1L]], dots[[2L]][[1L]], dots[[3L]][[1L]]): geom_GeomLogticks() has yet to be implemented in plotly. ## If you'd like to see this geom implemented, ## Please open an issue with your example code at ## https://github.com/ropensci/plotly/issues
## Warning in is.na(ticktext): is.na() applied to non-(list or vector) of type ## 'expression' ## Warning in is.na(ticktext): is.na() applied to non-(list or vector) of type ## 'expression'
a <- ggplot(msleep, aes(bodywt, brainwt)) + geom_point(na.rm = TRUE) + scale_x_log10( breaks = scales::trans_breaks("log10", function(x) 10^x), labels = scales::trans_format("log10", scales::math_format(10^.x)) ) + scale_y_log10( breaks = scales::trans_breaks("log10", function(x) 10^x), labels = scales::trans_format("log10", scales::math_format(10^.x)) ) + theme_bw() p <- a + annotation_logticks(sides = "trbl") + theme(panel.grid.minor = element_blank())
plotly::ggplotly(p)
## Warning in geom2trace.default(dots[[1L]][[1L]], dots[[2L]][[1L]], dots[[3L]][[1L]]): geom_GeomLogticks() has yet to be implemented in plotly. ## If you'd like to see this geom implemented, ## Please open an issue with your example code at ## https://github.com/ropensci/plotly/issues
## Warning in is.na(ticktext): is.na() applied to non-(list or vector) of type ## 'expression' ## Warning in is.na(ticktext): is.na() applied to non-(list or vector) of type ## 'expression'
b <- ggplot(msleep, aes(log10(bodywt), log10(brainwt))) + geom_point(na.rm = TRUE) + scale_x_continuous(name = "body", labels = scales::math_format(10^.x)) + scale_y_continuous(name = "brain", labels = scales::math_format(10^.x)) + theme_bw() + theme(panel.grid.minor = element_blank()) p <- b + annotation_logticks()
plotly::ggplotly(p)
## Warning in geom2trace.default(dots[[1L]][[1L]], dots[[2L]][[1L]], dots[[3L]][[1L]]): geom_GeomLogticks() has yet to be implemented in plotly. ## If you'd like to see this geom implemented, ## Please open an issue with your example code at ## https://github.com/ropensci/plotly/issues
## Warning in is.na(ticktext): is.na() applied to non-(list or vector) of type ## 'expression' ## Warning in is.na(ticktext): is.na() applied to non-(list or vector) of type ## 'expression'
t <- ggplot(msleep, aes(bodywt, brainwt)) + geom_point() + coord_trans(x = "log10", y = "log10") + theme_bw() p <- t + annotation_logticks(scaled = FALSE)
plotly::ggplotly(p)
## Warning in geom2trace.default(dots[[1L]][[1L]], dots[[2L]][[1L]], dots[[3L]][[1L]]): geom_GeomLogticks() has yet to be implemented in plotly. ## If you'd like to see this geom implemented, ## Please open an issue with your example code at ## https://github.com/ropensci/plotly/issues
a <- ggplot(msleep, aes(bodywt, brainwt)) + geom_point(na.rm = TRUE) + scale_x_log10( breaks = scales::trans_breaks("log10", function(x) 10^x), labels = scales::trans_format("log10", scales::math_format(10^.x)) ) + scale_y_log10( breaks = scales::trans_breaks("log10", function(x) 10^x), labels = scales::trans_format("log10", scales::math_format(10^.x)) ) + theme_bw() p <- a + annotation_logticks( short = unit(.5,"mm"), mid = unit(3,"mm"), long = unit(4,"mm") )
plotly::ggplotly(p)
## Warning in geom2trace.default(dots[[1L]][[1L]], dots[[2L]][[1L]], dots[[3L]][[1L]]): geom_GeomLogticks() has yet to be implemented in plotly. ## If you'd like to see this geom implemented, ## Please open an issue with your example code at ## https://github.com/ropensci/plotly/issues
## Warning in is.na(ticktext): is.na() applied to non-(list or vector) of type ## 'expression' ## Warning in is.na(ticktext): is.na() applied to non-(list or vector) of type ## 'expression'