為什么餅圖有問題

介紹 (Introduction)

It seems as if people are split on pie charts: either you passionately hate them, or you are indifferent. In this article, I am going to explain why pie charts are problematic and, if you fall into the latter category, what you can do when creating pie charts to avoid upsetting those in the former.

似乎人們在餅圖上是分裂的:要么熱情地恨他們,要么冷漠。 在本文中,我將解釋為什么餅圖會出現問題,如果您屬于后者,那么創建餅圖時可以做些什么,以避免使前者煩惱。

餅圖為什么有問題? (Why are pie charts problematic?)

他們用大小來傳達信息 (They use size to convey information)

A pie chart uses the size of a portion (slice) of a circle (pie) to display a numerical variable. This factor is not an issue in and of itself, as many chart types use size to convey information, including bubble charts and bar charts; however, while bubble charts and bar charts use diameter and height, respectively, to convey information, pie charts rely on the angle describing a slice — -and the human eye is not very good at recognizing differences in angles.

餅圖使用圓(餅圖)的一部分(切片)的大小來顯示數字變量。 這個因素本身不是問題,因為許多圖表類型都使用大小來傳達信息,包括氣泡圖和條形圖。 但是,雖然氣泡圖和條形圖分別使用直徑和高度來傳達信息,但餅圖依賴于描述切片的角度-人眼在識別角度差異方面并不十分擅長。

Suppose I took a survey on people’s favorite kinds of pie. In the chart below, it is difficult to see how the categories relate to each other; individually, Cherry and Rhubarb seem to comprise a smaller portion of the pie than either Apple or Pumpkin, but it may not be obvious (without looking at the data) which is the smaller slice.

假設我對人們喜歡的派進行了調查。 在下面的圖表中,很難看到類別之間的相互關系。 分別看來,櫻桃和大黃在餡餅中所占的份額似乎比蘋果或南瓜要小,但不明顯(不查看數據)是較小的份額。

#Adjusting plot size and margins
options(repr.plot.width=8, repr.plot.height=4)
par(mfrow=c(1,1), mai = c(0.5, 0, 0.75, 0))#Data for pie chart
x = c(18, 15, 13, 25, 29)
labels = c("Key Lime", "Cherry", "Rhubarb", "Pumpkin", "Apple")
cols = c("greenyellow", "red", "mediumvioletred", "darkorange",
"cornsilk")#Build the pie chart
pie(x, labels, radius = 1, col=cols)

他們不能很好地顯示許多類別 (They cannot display many categories well)

This issue of conveying size via angle is even more pronounced when many categories are shown in a single pie chart. Furthermore, unlike some charts that are used to display several categories at once, such as bar charts, pie charts depend on differences in color to denote category; therefore, a large palette of colors is necessary, and without proper selection of the palette, the results could be either garish or ambiguous.

當在單個餅圖中顯示許多類別時,通過角度傳送尺寸的問題更加明顯。 此外,與某些條形圖等用于一次顯示多個類別的圖表不同,餅形圖依靠顏色的不同來表示類別。 因此,必須使用大的調色板,并且如果不正確選擇調色板,結果可能是亂碼或模棱兩可的。

#Adjusting plot size and margins
options(repr.plot.width=8, repr.plot.height=4)
par(mfrow=c(1,1), mai = c(0.55, 0, 0.8, 0))#Data for pie chart
x = c(2, 4, 5, 10, 13, 15, 15, 17, 19)
labels = c("Key Lime", "Pecan", "Cherry", "Blueberry", "Rhubarb",
"Lemon Meringue", "Blackberry", "Pumpkin", "Apple")
cols = c("greenyellow", "tan4", "red", "darkblue",
"mediumvioletred", "yellow", "black", "darkorange",
"cornsilk2")#Build the pie chart
pie(x, labels, radius = 1, col=cols)
Image for post
Image by Author
圖片作者

它們顯示了整體的一部分 (They show parts of a whole)

Pie charts represent a whole as its components. Therefore, if your dataset is a subset of a larger dataset (and thus does not represent the whole) or if your dataset consists of independent categories (and thus represents multiple wholes), then a pie chart may not be appropriate.

餅圖將整體表示為其組成部分。 因此,如果您的數據集是較大數據集的子集(因此不表示整體),或者如果您的數據集由獨立的類別組成(并因此表示多個整體),則餅形圖可能不合適。

熱門套餐中的餅圖 (Pie charts in popular packages)

I wouldn’t want to assume anyone’s opinion on as divisive a topic as the pie chart, but perhaps the disdain for this chart type is best exhibited by the lack of built-in functions for creating them in two very popular data visualization packages: ggplot2 (R) and seaborn (Python). With both packages, a pie chart can be created only through trickery.

我不想假設任何人都對餅圖這個具有爭議性的話題發表意見,但是對于這種圖表類型的鄙視最好表現為缺乏在兩個非常流行的數據可視化軟件包中創建內置圖表的內置功能:ggplot2 (R)和seaborn(Python)。 使用這兩個軟件包,只能通過欺騙來創建餅圖。

詭計 (Trickery)

It is convenient — -perhaps a little too convenient — -that a pie chart is no more than a single stacked bar displayed in polar coordinates. The code below builds the pie chart shown above, but using ggplot2.

餅圖只不過是極坐標中顯示的單個堆積條,這很方便-也許有點方便了。 下面的代碼使用ggplot2構建上面顯示的餅圖。

#Adjusting plot size and margins
options(repr.plot.width=8, repr.plot.height=4)
par(mfrow=c(1,1), mai = c(0.55, 0, 0.8, 0))#Data for the pie chart
values = c(9, 2, 5, 10, 13, 15, 10, 17, 19)
labels = c("Key \nLime", "Pecan", "Cherry", "Blueberry", "Rhubarb",
"Lemon \nMeringue", "Blackberry", "Pumpkin", "Apple")
cols = c("Key \nLime"="greenyellow", "Pecan"="tan4",
"Cherry"="red", "Blueberry"="darkblue",
"Rhubarb"="mediumvioletred", "Lemon \nMeringue"="yellow",
"Blackberry"="black", "Pumpkin"="darkorange",
"Apple"="cornsilk2")data = data.frame(labels, values)#Build the pie chart
ggplot(data, aes(x="", y=values, fill=labels))+
geom_bar(width = 1, stat = "identity") +
scale_fill_manual(values=cols) +
coord_polar("y", start=0) + #Use polar coordinates
theme(axis.title=element_blank(),
axis.text=element_blank(),
legend.title=element_blank())
Image for post
Image by Author
圖片作者

哪些圖表類型可用于替換餅圖? (What chart types can be used to replace pie charts?)

條形圖 (Bar charts)

Similar to pie charts, bar charts use size to convey information; however, for bar charts, the height of a rectangle varies, and differences between the heights of bars are easier to recognize than the differences between the angles of portions of a circle. Furthermore, bar charts can be configured to show absolute numbers, percentages, or both!

類似于餅圖,條形圖使用大小來傳達信息。 但是,對于條形圖,矩形的高度是變化的,并且條形的高度之間的差異比圓的各個部分的角度之間的差異更容易識別。 此外,可以將條形圖配置為顯示絕對數字,百分比或同時顯示兩者!

#Adjusting plot size and margins
options(repr.plot.width=8, repr.plot.height=4)
par(mfrow=c(1,1), mai = c(0.5, 1, 0.2, 1))#Data for bar chart
values = c(9, 2, 5, 10, 13, 15, 10, 17, 19)
labels = c("Key \nLime", "Pecan", "Cherry", "Blueberry", "Rhubarb",
"Lemon \nMeringue", "Blackberry", "Pumpkin", "Apple")data = data.frame(labels, values)
data = data[order(-values),]#Build the bar chart
barplot(height=data$values,
names.arg=data$labels,
ylab="Votes",
ylim = c(0, 20),
cex.names=0.7)
Image for post
Image by Author
圖片作者

華夫餅圖 (Waffle Charts)

Waffle charts, which are growing in popularity, use number rather than size to visualize a numerical dimension. The resulting graph is similar to a stacked bar or tree map; however, because each square is a unit, compared to alternatives that rely solely on size, it is easier for a person to confirm if a perceived difference between categories is real without relying on text.

華夫餅圖越來越流行,它使用數字而不是大小來可視化數字維度。 生成的圖形類似于堆積的條形圖或樹形圖。 但是,由于每個正方形都是一個單位,與僅依賴于大小的替代方案相比,一個人可以更容易地在不依賴文本的情況下確認類別之間的感知差異是否是真實的。

#Adjusting plot size and margins
options(repr.plot.width=8, repr.plot.height=4)
par(mfrow=c(1,1), mai = c(0.5, 1, 0.2, 1))#Create data
pies = c("Pecan"=2, "Cherry"=5, "Key Lime"=9, "Blueberry"=10,
"Blackberry"=10, "Rhubarb"=13, "Lemon Meringue"=15,
"Pumpkin"=17, "Apple"=19)waffle(pies, rows=5, size=1.5,
colors=c("tan4", "red", "greenyellow", "darkblue", "black",
"mediumvioletred", "yellow", "darkorange",
"cornsilk2"),
xlab="1 square = 1 vote", legend_pos = "bottom")
Image for post
Image by Author
圖片作者

但是,如果我不喜歡其他選擇,該怎么辦? (But what if I don’t like the alternatives?)

Even though there are many alternatives (e.g., bar charts, stacked bars, waffle charts, lollipop charts, tree maps), pie charts are a familiar chart type to most people, and depending on the audience, familiarity may be an important factor that affects interpretability. So if you want to stick with pie charts, consider taking the following advice.

即使有很多選擇(例如條形圖,堆積的條形圖,華夫餅圖,棒棒糖圖,樹形圖),餅圖也是大多數人熟悉的圖表類型,并且取決于受眾,熟悉度可能是影響可解釋性。 因此,如果您要堅持餅圖,請考慮采取以下建議。

通過分組限制類別數 (Limit the number of categories via grouping)

To avoid visual clutter and to ensure your pie chart is readable, the number of categories should be small. Therefore, it may be useful to group categories that individually comprise a small proportion of the pie into a single category. Note that, when using this approach, it may be helpful to list the items contained in the derived category. Furthermore, it is best to ensure that the new category does not form the majority of the resulting pie.

為避免視覺混亂,并確保餅圖可讀,類別的數量應少。 因此,將單獨包含一小部分餡餅的類別歸為一個類別可能很有用。 請注意,使用這種方法時,列出派生類別中包含的項目可能會有所幫助。 此外,最好確保新類別不構成結果派的大部分。

將百分比或絕對數字(或兩者)顯示為文本 (Show percentages or absolute numbers (or both) as text)

Text can be used to prevent misunderstandings due to ambiguity. By including text information, a person can see if there are differences among the categories. However, if it is necessary to include text, then one can argue that the visualization itself is ineffective (so be prepared to defend your choice of chart type).

文本可用于防止由于歧義而引起的誤解。 通過包含文本信息,人們可以查看類別之間是否存在差異。 但是,如果有必要包含文本,則可以認為可視化本身是無效的(因此請準備好捍衛您選擇的圖表類型)。

#Adjusting plot size and margins
options(repr.plot.width=8, repr.plot.height=4)
par(mfrow=c(1,1), mai = c(0.55, 0, 0.8, 0))#Data for pie chart
x = c(15, 20, 35, 30)
labels = c("Other (15%)", "Cherry (20%)", "Pumpkin (35%)",
"Apple (30%)")
cols = c("black", "red", "darkorange", "cornsilk2")#Build the pie chart
pie(x, labels, radius = 1, col=cols)
Image for post
Image by Author
圖片作者

結論 (Conclusions)

I hope you found this discussion of pie charts informative. While pie charts can be avoided in most cases, they remain a pithy little chart on which many, many people have little to no opinion. However, to avoid a mass uptake of pitchforks and torches, please remember to employ pie charts responsibly and to use caution when including any controversial chart type in your next presentation.

我希望您發現對餅形圖的討論能提供更多信息。 盡管在大多數情況下都可以避免餅圖,但它們仍然是一個精巧的小圖表,很多人對此幾乎沒有意見。 但是,為避免大量吸收干草叉和火炬,請記住要負責任地使用餅形圖,并在下次演示中包括任何有爭議的圖表類型時保持謹慎。

所需的庫 (Required libraries)

library(repr)
library(dplyr)
library(plotly)
library(waffle)
library(ggplot2)
library(RColorBrewer)

翻譯自: https://medium.com/analytics-vidhya/why-pie-charts-are-problematic-1075ce7d0270

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/389443.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/389443.shtml
英文地址,請注明出處:http://en.pswp.cn/news/389443.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

New Distinct Substrings(后綴數組)

New Distinct Substrings&#xff08;后綴數組&#xff09; 給定一個字符串&#xff0c;求不相同的子串的個數。\(n<50005\)。 顯然&#xff0c;任何一個子串一定是后綴上的前綴。先&#xff08;按套路&#xff09;把后綴排好序&#xff0c;對于當前的后綴\(S_i\)&#xff0…

Android dependency 'com.android.support:support-v4' has different version for the compile (26.1.0...

在項目中加入react-native-camera的時候 出現的錯誤. 解決方案: 修改 implementation project(:react-native-camera)為 implementation (project(:react-native-camera)) {exclude group: "com.android.support"}查看原文 Could not find play-services-basement.aa…

先知模型 facebook_使用Facebook先知進行犯罪率預測

先知模型 facebookTime series prediction is one of the must-know techniques for any data scientist. Questions like predicting the weather, product sales, customer visit in the shopping center, or amount of inventory to maintain, etc - all about time series …

莫煩Pytorch神經網絡第四章代碼修改

4.1CNN卷積神經網絡 import torch import torch.nn as nn from torch.autograd import Variable import torch.utils.data as Data import torchvision import matplotlib.pyplot as pltEPOCH 1 BATCH_SIZE 50 LR 0.001 DOWNLOAD_MNIST False #如果數據集已經下載到…

github gists 101使代碼共享漂亮

If you’ve been going through Medium, looking at technical articles, you’ve undoubtedly seen little windows that look like the below:如果您一直在閱讀Medium&#xff0c;并查看技術文章&#xff0c;那么您無疑會看到類似于以下內容的小窗口&#xff1a; def hello_…

loj #6278. 數列分塊入門 2

題目 題解 區間修改&#xff0c;詢問區間小于c的個數。分塊排序&#xff0c;用vector。至于那個塊的大小&#xff0c;好像要用到均值不等式 我不太會。。。就開始一個個試&#xff0c;發現sizsqrt(n)/4時最快&#xff01;&#xff01;&#xff01;明天去學一下算分塊復雜度的方…

基于Netty的百萬級推送服務設計要點

1. 背景1.1. 話題來源最近很多從事移動互聯網和物聯網開發的同學給我發郵件或者微博私信我&#xff0c;咨詢推送服務相關的問題。問題五花八門&#xff0c;在幫助大家答疑解惑的過程中&#xff0c;我也對問題進行了總結&#xff0c;大概可以歸納為如下幾類&#xff1a;1&#x…

莫煩Pytorch神經網絡第五章代碼修改

5.1動態Dynamic import torch from torch import nn import numpy as np import matplotlib.pyplot as plt# torch.manual_seed(1) # reproducible# Hyper Parameters INPUT_SIZE 1 # rnn input size / image width LR 0.02 # learning rateclass…

鮮為人知的6個黑科技網站_6種鮮為人知的熊貓繪圖工具

鮮為人知的6個黑科技網站Pandas is the go-to Python library for data analysis and manipulation. It provides numerous functions and methods that expedice the data analysis process.Pandas是用于數據分析和處理的Python庫。 它提供了加速數據分析過程的眾多功能和方法…

VRRP網關冗余

實驗要求?1、R1創建環回口&#xff0c;模擬外網?2、R2&#xff0c;R3使用VRRP技術?3、路由器之間使用EIGRP路由協議? 實驗拓撲? 實驗配置??R1(config)#interface loopback 0R1(config-if)#ip address 1.1.1.1 255.255.255.0R1(config-if)#int e0/0R1(config-if)#ip addr…

網頁JS獲取當前地理位置(省市區)

網頁JS獲取當前地理位置&#xff08;省市區&#xff09; 一、總結 一句話總結&#xff1a;ip查詢接口 二、網頁JS獲取當前地理位置&#xff08;省市區&#xff09; 眼看2014又要過去了&#xff0c;翻翻今年的文章好像沒有寫幾篇&#xff0c;忙真的或許已經不能成為借口了&#…

大熊貓卸妝后_您不應錯過的6大熊貓行動

大熊貓卸妝后數據科學 (Data Science) Pandas is used mainly for reading, cleaning, and extracting insights from data. We will see an advanced use of Pandas which are very important to a Data Scientist. These operations are used to analyze data and manipulate…

數據eda_關于分類和有序數據的EDA

數據eda數據科學和機器學習統計 (STATISTICS FOR DATA SCIENCE AND MACHINE LEARNING) Categorical variables are the ones where the possible values are provided as a set of options, it can be pre-defined or open. An example can be the gender of a person. In the …

PyTorch官方教程中文版:PYTORCH之60MIN入門教程代碼學習

Pytorch入門 import torch""" 構建非初始化的矩陣 """x torch.empty(5,3) #print(x)""" 構建隨機初始化矩陣 """x torch.rand(5,3)""" 構造一個矩陣全為 0&#xff0c;而且數據類型是 long &qu…

Flexbox 最簡單的表單

彈性布局(Flexbox)逐漸流行&#xff0c;越來越多的人開始使用&#xff0c;因為它寫Css布局真是太簡單了一一、<form>元素表單使用<form>元素<form></form>復制代碼上面是一個空的表單&#xff0c;根據HTML標準&#xff0c;它是一個塊級元素&#xff0c…

CSS中的盒子模型

一.為什么使用CSS 1.有效的傳遞頁面信息 2.使用CSS美化過的頁面文本&#xff0c;使頁面漂亮、美觀&#xff0c;吸引用戶 3.可以很好的突出頁面的主題內容&#xff0c;使用戶第一眼可以看到頁面主要內容 4.具有良好的用戶體驗 二.字體樣式屬性 1.font-family:英…

jdk重啟后步行_向后介紹步行以一種新穎的方式來預測未來

jdk重啟后步行“永遠不要做出預測&#xff0c;尤其是關于未來的預測。” (KK Steincke) (“Never Make Predictions, Especially About the Future.” (K. K. Steincke)) Does this picture portray a horse or a car? 這張照片描繪的是馬還是汽車&#xff1f; How likely is …

PyTorch官方教程中文版:入門強化教程代碼學習

PyTorch之數據加載和處理 from __future__ import print_function, division import os import torch import pandas as pd #用于更容易地進行csv解析 from skimage import io, transform #用于圖像的IO和變換 import numpy as np import matplotlib.pyplot a…

css3-2 CSS3選擇器和文本字體樣式

css3-2 CSS3選擇器和文本字體樣式 一、總結 一句話總結&#xff1a;是要記下來的&#xff0c;記下來可以省很多事。 1、css的基本選擇器中的:first-letter和:first-line是什么意思&#xff1f; :first-letter選擇第一個單詞&#xff0c;:first-line選擇第一行 2、css的偽類選…

mongodb仲裁者_真理的仲裁者

mongodb仲裁者Coming out of college with a background in mathematics, I fell upward into the rapidly growing field of data analytics. It wasn’t until years later that I realized the incredible power that comes with the position. As Uncle Ben told Peter Par…