r - 如何在R中绘制由包绘制的图表的log2变换轴?
问题描述
目前我在 R 中使用 plotly,我想知道我应该使用什么代码来 log2 转换其中一个轴?
非常感谢您的回答!
解决方案
log
这是在 x 轴上进行变换的示例。但是,我不知道是否可以这样做log2
。
library(plotly)
mtcars %>%
plot_ly(x = ~disp, y = ~mpg) %>%
add_markers(marker = list(opacity = 0.8)) %>%
layout(xaxis = list(type = "log"))
另一种方法是使用ggplot2
with scale_x_continuous
with trans = "log2"
,然后ggplotly
library(ggplot2)
p <- ggplot(mtcars, aes(x = disp, y = mpg)) +
geom_point() +
scale_x_continuous(trans = "log2")
ggplotly(p)
推荐阅读
- c# - 为什么 SQL Server 字符串输出参数在 EF ExecuteSqlCommand 调用上返回 0?
- c# - 发送电子邮件 WebAPI
- git - 开启gitlab的二次验证后如何使用git命令
- html - 如何使用 XSLT 1.0 检查元素的前面子字符串?
- mongodb - 使用 .jks 文件从 shell 连接到 mongo
- angular - 用于 mat-selection-list 的角材料“disableRipple”在移动设备中不起作用
- ffmpeg - 这是在转码视频吗?
- uml - UML 活动图:在输出上带有保护条件的分叉
- bash - Bash 脚本冲突
- ios - 如何创建如下图所示的渐变阴影(绿色按钮上方):