[英]R plotly - How to make labels and legend larger in donut chart?
I'm making a donut chart with the following code我正在使用以下代码制作甜甜圈图
data <- data.frame(
category=c("Successful", "Unsuccessful", "Pending"),
amount=c(45, 26, 23)
)
# Make the plot
df <- data
fig <- df %>% plot_ly(labels = ~category, values = ~amount, marker = list(colors = c('#00aa7f', '#ff0000','#ccccc7')))
fig <- fig %>% add_pie(hole = 0.55)
fig
This results in a nice donut chart - but I feel like the legend and label are too small.这会产生一个漂亮的甜甜圈图 - 但我觉得图例和 label 太小了。
When I edit my code with the following: Nothing happens
df <- data
fig <- df %>% plot_ly(labels = ~category, values = ~amount, marker = list(colors = c('#00aa7f', '#ff0000','#ccccc7', size = 10)))
fig <- fig %>% add_pie(hole = 0.55)
fig
When I try this code - the font is way to big and although I try to adjust it - the size doesn't decrease.当我尝试此代码时-字体很大,尽管我尝试对其进行调整-大小并没有减小。
# Make the plot
df <- data
fig <- df %>% plot_ly(labels = ~category, values = ~amount, marker = list(colors = c('#00aa7f', '#ff0000','#ccccc7')), size = 10)
fig <- fig %>% add_pie(hole = 0.55)
fig
What am I doing wrong?我究竟做错了什么?
The label size can the changed by textfont
argument inside the add_pie
function. label 的大小可以通过textfont
中的add_pie
参数进行更改。 The legend size and hovertext size can be adjusted inside the layout
function with the arguments hoverlabel
and legend
.可以使用 arguments hoverlabel
和legend
在layout
function 内调整图例大小和悬停文本大小。
fig <- df %>% plot_ly(labels = ~category,
values = ~amount,
marker = list(colors = c('#00aa7f', '#ff0000','#ccccc7')))
fig <- fig %>%
add_pie(hole = 0.55,
textfont = list(size = 18)) %>%
layout(legend = list(font = list(size = 18)),
hoverlabel = list(font = list(size = 18)))
fig
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.