饼图标签被切掉 [英] Pie Chart Labels Cut off

查看:122
本文介绍了饼图标签被切掉的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个饼图,某些标签被剪掉了.我想缩小地块以容纳所有标签.以下是可重现的示例.

I'm making a pie chart, and some of the labels get cut off. I'd like to shrink the plot to accommodate all the labels. Below is a reproducible example.

library(plotly)
plot_ly(type="pie",values=1:19,
        labels=c(101:119),textinfo="label+value+percent",
        textposition="outside",showlegend=F,marker=list(colors=c(
          "gray",
          "thistle",
          "red",
          "lightskyblue",
          "deeppink",
          "green",
          "gold",
          "brown",
          "purple",
          "orange",
          "cadetblue",
          "darkslategray",
          "burlywood",
          "yellow",
          "skyblue",
          "lightgreen",
          "hotpink",
          "lightgray",
          "blue"
        )))

推荐答案

您可以尝试一下.只需在layout()表达式中设置边距,高度和宽度.只是玩数字游戏,直到获得想要的东西.希望对您有所帮助.

You could try this. Just set the margin, height and width in your layout() expression. Just play with the numbers until you get what you want. Hope it helps.

m = list(
  l = 40,
  r = 40,
  b = 50,
  t = 50,
  pad = 0
)

plot_ly(type="pie",values=1:19, height = 25,
        labels=c(101:119),textinfo="label+value+percent",
        textposition="outside",showlegend=F,marker=list(colors=c(
          "gray",
          "thistle",
          "red",
          "lightskyblue",
          "deeppink",
          "green",
          "gold",
          "brown",
          "purple",
          "orange",
          "cadetblue",
          "darkslategray",
          "burlywood",
          "yellow",
          "skyblue",
          "lightgreen",
          "hotpink",
          "lightgray",
          "blue"
        ))) %>%
  layout(autosize = F, width = 800, height = 800, margin = m)

这篇关于饼图标签被切掉的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆