如果有人能告诉我如何指定,我将不胜感激 域布局以在几列中获得相同大小的饼图。 我已经找到了这个例子,但是,我不知道域选项的每个参数是什么意思,如何调整它们并正确部署,文档中的信息不多。
plot_ly() %>%
add_pie(data = count(diamonds, cut), labels = ~cut, values = ~n,
name = "Cut",domain = list(x = c(0.4, 0.9), y = c(0.4, 1)),hole = 0.6) %>%
add_pie(data = count(diamonds, color), labels = ~cut, values = ~n,
name = "Color", domain = list(x = c(0.4, 0.4), y = c(0.4, 1)),hole = 0.6) %>%
add_pie(data = count(diamonds, clarity), labels = ~cut, values = ~n,
name = "Clarity", domain = list(x = c(0.4, 0.001), y = c(0.4, 1)),hole = 0.6) %>%
layout( showlegend = F,autosize=TRUE,
xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE))
谢谢。
答案 0 :(得分:0)
x
指定子图所在的完整图的相对范围。范围从0到1,0是最低/最左边的部分。
在您的情况下,如果您想要有三列,则需要域的(0, 0.3), (0.35, 0.65), (0.7, 1)
部分是滑动窗口(y
),而(0, 1)
部分将是常量(library (plotly)
library(magrittr)
library(dplyr)
plot_ly() %>%
add_pie(data = count(diamonds, cut), labels = ~cut, values = ~n,
name = "Cut",domain = list(x = c(0.0, 0.30), y = c(0, 1)),hole = 0.6) %>%
add_pie(data = count(diamonds, color), labels = ~cut, values = ~n,
name = "Color", domain = list(x = c(0.35, 0.65), y = c(0, 1)),hole = 0.6) %>%
add_pie(data = count(diamonds, clarity), labels = ~cut, values = ~n,
name = "Clarity", domain = list(x = c(0.7, 1), y = c(0, 1)),hole = 0.6) %>%
layout( showlegend = F,autosize=TRUE,
xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE))
)。
{{1}}