我已经贴了这个
as an issue on Github
两周前。既然重新提出这个问题显然是可以的”
if the project maintainers don't respond in a reasonable amount of time
“,我会把问题贴在这里。
我想创造小倍数
固定长宽比
是的。但是,只有一些绘图保留正确的纵横比。根据我收集的信息,使用plotly设置固定纵横比的操作如下:
layout(yaxis = list(scaleanchor = "x"))
.考虑下面的例子:
library(purrr)
library(plotly)
df <- data.frame(
x = rep(1:5,25),
y = rep(1:5,25),
g = sort(rep(1:25,5))
)
plots <- df %>%
split(.$g) %>%
map(function(x){
plot_ly(data = x, x = ~x, y = ~y, type = "scatter",mode = "lines") %>% add_lines()
})
small_multiples <- subplot(plots,nrows = 5) %>%
layout(yaxis = list(scaleanchor = "x")) %>%
hide_legend()
如果我策划
small_multiples
,只有第一个绘图(第1行第1列)的纵横比为1。另一个有任意的长宽比。
以下是此绘图的交互式版本的链接:
https://plot.ly/~rata_zhaw/1/
有趣的是,如果我选择
shareX = T
在里面
subplot()
,整个第一列具有正确的纵横比。如果我选择什么都不会改变
shareY = T
下面是第二个情节的互动版本的链接:
https://plot.ly/~rata_zhaw/3/
如果我单独绘制任何绘图,则纵横比正确:
plots[[10]] %>%
layout(yaxis = list(scaleanchor = "x")) %>%
hide_legend()