【问题标题】:Preserving values and labels order in pie chart在饼图中保留值和标签顺序
【发布时间】:2014-05-26 18:18:14
【问题描述】:

我想绘制一个饼图,其中必须保留值和标签的顺序。我怎么能生产它?

似乎默认情况下 R 可以控制字母顺序和顺时针顺序。 另外,我想通过添加将图表的一个点连接到另一个点的箭头来向图表添加更多信息,例如从ABCZXR,有可能吗?

# Simple Pie Chart
slices <- c(12,11,11,8,6,2,5,3)
lbls <- c("ABC", "DEF", "GPH", "ZXR", "O", "MN", "TS", "ZY")
pie(slices, labels = lbls, main="ranking disk")

谢谢, 夏娃

【问题讨论】:

  • 最好一次只问一个问题。

标签: r graph plot pie-chart


【解决方案1】:

以下将创建一个饼图,其中包含您放置标签的顺序,从 12 点开始,顺时针旋转:

pie(slices, labels = lbls, clockwise=TRUE, init.angle=90, main="ranking disk")

您可以调整clockwiseinit.angle 参数。

很遗憾,pie 不会返回标签或切片的坐标,但如果您根据需要调整坐标,则可以手动添加箭头:

arrows(.6,.6,-.6,-.4)

但是,您确实知道饼图是呈现信息的可怕方式,对吧?帮助页面?pie 的以下部分非常值得全文引用:

 Pie charts are a very bad way of displaying information.  The eye
 is good at judging linear measures and bad at judging relative
 areas.  A bar chart or dot chart is a preferable way of displaying
 this type of data.

 Cleveland (1985), page 264: “Data that can be shown by pie charts
 always can be shown by a dot chart.  This means that judgements of
 position along a common scale can be made instead of the less
 accurate angle judgements.” This statement is based on the
 empirical investigations of Cleveland and McGill as well as
 investigations by perceptual psychologists.

【讨论】:

  • 如果可以的话,我会再给饼图报价+1
猜你喜欢
  • 1970-01-01
  • 2011-02-28
  • 2019-11-25
  • 2016-02-12
  • 2020-08-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多