-
Notifications
You must be signed in to change notification settings - Fork 0
/
charts_piecharts.html
414 lines (326 loc) · 19.9 KB
/
charts_piecharts.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="pandoc" />
<title>Charts: Piecharts</title>
<script src="site_libs/jquery-1.11.3/jquery.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link href="site_libs/bootstrap-3.3.5/css/cosmo.min.css" rel="stylesheet" />
<script src="site_libs/bootstrap-3.3.5/js/bootstrap.min.js"></script>
<script src="site_libs/bootstrap-3.3.5/shim/html5shiv.min.js"></script>
<script src="site_libs/bootstrap-3.3.5/shim/respond.min.js"></script>
<script src="site_libs/jqueryui-1.11.4/jquery-ui.min.js"></script>
<link href="site_libs/tocify-1.9.1/jquery.tocify.css" rel="stylesheet" />
<script src="site_libs/tocify-1.9.1/jquery.tocify.js"></script>
<script src="site_libs/navigation-1.1/tabsets.js"></script>
<link href="site_libs/highlightjs-9.12.0/textmate.css" rel="stylesheet" />
<script src="site_libs/highlightjs-9.12.0/highlight.js"></script>
<script src="site_libs/htmlwidgets-1.3/htmlwidgets.js"></script>
<script src="site_libs/proj4js-2.3.15/proj4.js"></script>
<link href="site_libs/highcharts-6.0.3/css/motion.css" rel="stylesheet" />
<script src="site_libs/highcharts-6.0.3/highcharts.js"></script>
<script src="site_libs/highcharts-6.0.3/highcharts-3d.js"></script>
<script src="site_libs/highcharts-6.0.3/highcharts-more.js"></script>
<script src="site_libs/highcharts-6.0.3/modules/stock.js"></script>
<script src="site_libs/highcharts-6.0.3/modules/heatmap.js"></script>
<script src="site_libs/highcharts-6.0.3/modules/treemap.js"></script>
<script src="site_libs/highcharts-6.0.3/modules/annotations.js"></script>
<script src="site_libs/highcharts-6.0.3/modules/boost.js"></script>
<script src="site_libs/highcharts-6.0.3/modules/data.js"></script>
<script src="site_libs/highcharts-6.0.3/modules/drag-panes.js"></script>
<script src="site_libs/highcharts-6.0.3/modules/drilldown.js"></script>
<script src="site_libs/highcharts-6.0.3/modules/funnel.js"></script>
<script src="site_libs/highcharts-6.0.3/modules/item-series.js"></script>
<script src="site_libs/highcharts-6.0.3/modules/offline-exporting.js"></script>
<script src="site_libs/highcharts-6.0.3/modules/overlapping-datalabels.js"></script>
<script src="site_libs/highcharts-6.0.3/modules/parallel-coordinates.js"></script>
<script src="site_libs/highcharts-6.0.3/modules/sankey.js"></script>
<script src="site_libs/highcharts-6.0.3/modules/solid-gauge.js"></script>
<script src="site_libs/highcharts-6.0.3/modules/streamgraph.js"></script>
<script src="site_libs/highcharts-6.0.3/modules/sunburst.js"></script>
<script src="site_libs/highcharts-6.0.3/modules/vector.js"></script>
<script src="site_libs/highcharts-6.0.3/modules/wordcloud.js"></script>
<script src="site_libs/highcharts-6.0.3/modules/xrange.js"></script>
<script src="site_libs/highcharts-6.0.3/modules/exporting.js"></script>
<script src="site_libs/highcharts-6.0.3/modules/export-data.js"></script>
<script src="site_libs/highcharts-6.0.3/maps/modules/map.js"></script>
<script src="site_libs/highcharts-6.0.3/plugins/grouped-categories.js"></script>
<script src="site_libs/highcharts-6.0.3/plugins/motion.js"></script>
<script src="site_libs/highcharts-6.0.3/plugins/multicolor_series.js"></script>
<script src="site_libs/highcharts-6.0.3/custom/reset.js"></script>
<script src="site_libs/highcharts-6.0.3/custom/symbols-extra.js"></script>
<script src="site_libs/highcharts-6.0.3/custom/text-symbols.js"></script>
<script src="site_libs/highchart-binding-0.6.0/highchart.js"></script>
<meta name="description" content="Learn how to choose the most effective data visualisation options for your research data from the OxShef Charts webste. OxShef is a collaboration between University of Oxford and University of Sheffield." />
<link rel="icon" type="image/png" href="images/favicon.png" />
<script type="text/javascript" src="js/rmarkdown.js"></script>
<style type="text/css">code{white-space: pre;}</style>
<style type="text/css">
pre:not([class]) {
background-color: white;
}
</style>
<script type="text/javascript">
if (window.hljs) {
hljs.configure({languages: []});
hljs.initHighlightingOnLoad();
if (document.readyState && document.readyState === "complete") {
window.setTimeout(function() { hljs.initHighlighting(); }, 0);
}
}
</script>
<style type="text/css">
h1 {
font-size: 34px;
}
h1.title {
font-size: 38px;
}
h2 {
font-size: 30px;
}
h3 {
font-size: 24px;
}
h4 {
font-size: 18px;
}
h5 {
font-size: 16px;
}
h6 {
font-size: 12px;
}
.table th:not([align]) {
text-align: left;
}
</style>
<link rel="stylesheet" href="css/rmarkdown.css" type="text/css" />
<link rel="stylesheet" href="css/title-0px.css" type="text/css" />
</head>
<body>
<style type = "text/css">
.main-container {
max-width: 940px;
margin-left: auto;
margin-right: auto;
}
code {
color: inherit;
background-color: rgba(0, 0, 0, 0.04);
}
img {
max-width:100%;
height: auto;
}
.tabbed-pane {
padding-top: 12px;
}
.html-widget {
margin-bottom: 20px;
}
button.code-folding-btn:focus {
outline: none;
}
</style>
<div class="container-fluid main-container">
<!-- tabsets -->
<script>
$(document).ready(function () {
window.buildTabsets("TOC");
});
</script>
<!-- code folding -->
<script>
$(document).ready(function () {
// move toc-ignore selectors from section div to header
$('div.section.toc-ignore')
.removeClass('toc-ignore')
.children('h1,h2,h3,h4,h5').addClass('toc-ignore');
// establish options
var options = {
selectors: "h1,h2,h3",
theme: "bootstrap3",
context: '.toc-content',
hashGenerator: function (text) {
return text.replace(/[.\\/?&!#<>]/g, '').replace(/\s/g, '_').toLowerCase();
},
ignoreSelector: ".toc-ignore",
scrollTo: 0
};
options.showAndHide = false;
options.smoothScroll = true;
// tocify
var toc = $("#TOC").tocify(options).data("toc-tocify");
});
</script>
<style type="text/css">
#TOC {
margin: 25px 0px 20px 0px;
}
@media (max-width: 768px) {
#TOC {
position: relative;
width: 100%;
}
}
.toc-content {
padding-left: 30px;
padding-right: 40px;
}
div.main-container {
max-width: 1200px;
}
div.tocify {
width: 20%;
max-width: 260px;
max-height: 85%;
}
@media (min-width: 768px) and (max-width: 991px) {
div.tocify {
width: 25%;
}
}
@media (max-width: 767px) {
div.tocify {
width: 100%;
max-width: none;
}
}
.tocify ul, .tocify li {
line-height: 20px;
}
.tocify-subheader .tocify-item {
font-size: 0.90em;
padding-left: 25px;
text-indent: 0;
}
.tocify .list-group-item {
border-radius: 0px;
}
.tocify-subheader {
display: inline;
}
.tocify-subheader .tocify-item {
font-size: 0.95em;
}
</style>
<!-- setup 3col/9col grid for toc_float and main content -->
<div class="row-fluid">
<div class="col-xs-12 col-sm-4 col-md-3">
<div id="TOC" class="tocify">
</div>
</div>
<div class="toc-content col-xs-12 col-sm-8 col-md-9">
<div id="rStudioHeader" class="alwaysShrunk">
<div class="innards bandContent">
<div>
<a class="menuItem" href="index.html">OxShef: Charts</a>
</div>
<div id="menu">
<div id="menuToggler"></div>
<div id="menuItems">
<a class="menuItem" href="training-tutorials-and-templates.html">Training, Tutorials and Templates</a>
<a class="menuItem" href="charts.html">Charts</a>
<a class="menuItem" href="geoviz_maps.html">Geoviz (Maps)</a>
<a class="menuItem" href="networks.html">Networks</a>
<a class="menuItem" href="timeseries.html">Time Series</a>
<a class="menuItem" href="other.html">Other Visualisations</a>
<a class="menuItem gitHub" href="https://github.com/ox-it/OxfordIDN_charts"></a>
<a class="menuItem gitHubText" href="https://github.com/ox-it/OxfordIDN_charts">Source on GitHub</a>
</div>
</div>
</div>
</div>
<style type="text/css">
#TOC {
margin-left: 35px;
margin-top: 90px;
}
</style>
<script type="text/javascript">
$(".main-container").removeClass("main-container").removeClass("container-fluid").addClass("footerPushDown");
</script>
<div id="pageContent" class="standardPadding">
<div class="articleBandContent">
<style type="text/css">
.title {
display: none;
}
#disqus_thread {
display: none;
}
</style>
<div class="fluid-row" id="header">
<h1 class="title toc-ignore">Charts: Piecharts</h1>
</div>
<div id="what-is-a-piechart" class="section level1">
<h1>What is a piechart?</h1>
<p>Piecharts are useful visualisations for breaking down observations into a number of categories, the totals of which sum to 100% of the data. It is worth noting that it is often advisable to swap a barchart for a piechart, see</p>
<ul>
<li>Categories: For instance, species of animal e.g. human or iguana</li>
<li>Values: For instance, number of animals of each species</li>
</ul>
<p>Below is a comparison between a piechart and barchart build using <code>R</code> and the <code>highcharter</code> library.</p>
<div class="row">
<div class="col-md-6">
<div id="htmlwidget-d4bd5726ff00f78f077e" style="width:100%;height:250px;" class="highchart html-widget"></div>
<script type="application/json" data-for="htmlwidget-d4bd5726ff00f78f077e">{"x":{"hc_opts":{"title":{"text":null},"yAxis":{"title":{"text":"value"},"type":"linear"},"credits":{"enabled":false},"exporting":{"enabled":false},"plotOptions":{"series":{"label":{"enabled":false},"turboThreshold":0,"showInLegend":false},"treemap":{"layoutAlgorithm":"squarified"},"scatter":{"marker":{"symbol":"circle"}},"pie":{"dataLabels":{"enabled":false}}},"series":[{"group":"group","data":[{"category":"human","value":3,"y":3,"name":"human"},{"category":"non-human","value":4,"y":4,"name":"non-human"},{"category":"snake","value":6,"y":6,"name":"snake"},{"category":"iguana","value":8,"y":8,"name":"iguana"}],"type":"pie"}],"xAxis":{"type":"category","title":{"text":"category"},"categories":null}},"theme":{"chart":{"backgroundColor":"transparent"}},"conf_opts":{"global":{"Date":null,"VMLRadialGradientURL":"http =//code.highcharts.com/list(version)/gfx/vml-radial-gradient.png","canvasToolsURL":"http =//code.highcharts.com/list(version)/modules/canvas-tools.js","getTimezoneOffset":null,"timezoneOffset":0,"useUTC":true},"lang":{"contextButtonTitle":"Chart context menu","decimalPoint":".","downloadJPEG":"Download JPEG image","downloadPDF":"Download PDF document","downloadPNG":"Download PNG image","downloadSVG":"Download SVG vector image","drillUpText":"Back to {series.name}","invalidDate":null,"loading":"Loading...","months":["January","February","March","April","May","June","July","August","September","October","November","December"],"noData":"No data to display","numericSymbols":["k","M","G","T","P","E"],"printChart":"Print chart","resetZoom":"Reset zoom","resetZoomTitle":"Reset zoom level 1:1","shortMonths":["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],"thousandsSep":" ","weekdays":["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]}},"type":"chart","fonts":[],"debug":false},"evals":[],"jsHooks":[]}</script>
</div>
<div class="col-md-6">
<div id="htmlwidget-7edca02cdaea7df5edb1" style="width:100%;height:250px;" class="highchart html-widget"></div>
<script type="application/json" data-for="htmlwidget-7edca02cdaea7df5edb1">{"x":{"hc_opts":{"title":{"text":null},"yAxis":{"title":{"text":"value"},"type":"linear"},"credits":{"enabled":false},"exporting":{"enabled":false},"plotOptions":{"series":{"label":{"enabled":false},"turboThreshold":0,"showInLegend":false},"treemap":{"layoutAlgorithm":"squarified"},"scatter":{"marker":{"symbol":"circle"}},"pie":{"dataLabels":{"enabled":false}}},"series":[{"group":"group","data":[{"category":"iguana","value":8,"y":8,"name":"iguana"},{"category":"snake","value":6,"y":6,"name":"snake"},{"category":"non-human","value":4,"y":4,"name":"non-human"},{"category":"human","value":3,"y":3,"name":"human"}],"type":"bar"}],"xAxis":{"type":"category","title":{"text":"Category"}}},"theme":{"chart":{"backgroundColor":"transparent"}},"conf_opts":{"global":{"Date":null,"VMLRadialGradientURL":"http =//code.highcharts.com/list(version)/gfx/vml-radial-gradient.png","canvasToolsURL":"http =//code.highcharts.com/list(version)/modules/canvas-tools.js","getTimezoneOffset":null,"timezoneOffset":0,"useUTC":true},"lang":{"contextButtonTitle":"Chart context menu","decimalPoint":".","downloadJPEG":"Download JPEG image","downloadPDF":"Download PDF document","downloadPNG":"Download PNG image","downloadSVG":"Download SVG vector image","drillUpText":"Back to {series.name}","invalidDate":null,"loading":"Loading...","months":["January","February","March","April","May","June","July","August","September","October","November","December"],"noData":"No data to display","numericSymbols":["k","M","G","T","P","E"],"printChart":"Print chart","resetZoom":"Reset zoom","resetZoomTitle":"Reset zoom level 1:1","shortMonths":["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],"thousandsSep":" ","weekdays":["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]}},"type":"chart","fonts":[],"debug":false},"evals":[],"jsHooks":[]}</script>
</div>
</div>
</div>
<div id="limitations-of-piecharts" class="section level1">
<h1>Limitations of piecharts</h1>
<p>Research in graphical perception - the visual decoding of information encoded in graphs - suggests that piecharts are often an inefficient option for visualising the differences between many categories; as it is difficult for the visual perception system to judge small differences in the sizes of sections in a piechart. It’s also difficult to get exact measurements from piecharts, in the example above the barchart makes it clear that half as many observations are “non-human” as are categorised as “iguana”.</p>
<p>Often you will simply hear the advice “never use a piechart, instead use a barchart” based on the work of <a href="http://doi.org/10.2307/2288400" target="_blank">Cleveland and McGill</a> (amongst others). But blanket bans on piecharts are definitely overkill. There are many examples of where piecharts can be useful and a lot of variation possible in the design of piecharts, here are some useful resources and below there’s a very simple comparison between a piechart and donut chart.</p>
<ul>
<li>EagerEyes.org blogpost on <a href="https://eagereyes.org/techniques/pie-charts">designing effective piecharts</a></li>
<li>Study into <a href="https://kosara.net/papers/2016/Kosara-EuroVis-2016.pdf">judging error in piechart visualisations</a></li>
<li>Study into <a href="https://kosara.net/papers/2016/Skau-EuroVis-2016.pdf">differences between pie, area and sector charts</a></li>
</ul>
<div class="row">
<div class="col-md-6">
<div id="htmlwidget-3c19366e2fd12713e9f5" style="width:350px;height:250px;" class="highchart html-widget"></div>
<script type="application/json" data-for="htmlwidget-3c19366e2fd12713e9f5">{"x":{"hc_opts":{"title":{"text":null},"yAxis":{"title":{"text":"value"},"type":"linear"},"credits":{"enabled":false},"exporting":{"enabled":false},"plotOptions":{"series":{"label":{"enabled":false},"turboThreshold":0,"showInLegend":false,"animation":false},"treemap":{"layoutAlgorithm":"squarified"},"scatter":{"marker":{"symbol":"circle"}},"pie":{"dataLabels":{"enabled":true},"innerSize":100,"depth":45}},"series":[{"group":"group","data":[{"category":"human","value":3,"y":3,"name":"human"},{"category":"non-human","value":4,"y":4,"name":"non-human"},{"category":"snake","value":6,"y":6,"name":"snake"},{"category":"iguana","value":8,"y":8,"name":"iguana"}],"type":"pie"}],"xAxis":{"type":"category","title":{"text":"category"},"categories":null}},"theme":{"chart":{"backgroundColor":"transparent"}},"conf_opts":{"global":{"Date":null,"VMLRadialGradientURL":"http =//code.highcharts.com/list(version)/gfx/vml-radial-gradient.png","canvasToolsURL":"http =//code.highcharts.com/list(version)/modules/canvas-tools.js","getTimezoneOffset":null,"timezoneOffset":0,"useUTC":true},"lang":{"contextButtonTitle":"Chart context menu","decimalPoint":".","downloadJPEG":"Download JPEG image","downloadPDF":"Download PDF document","downloadPNG":"Download PNG image","downloadSVG":"Download SVG vector image","drillUpText":"Back to {series.name}","invalidDate":null,"loading":"Loading...","months":["January","February","March","April","May","June","July","August","September","October","November","December"],"noData":"No data to display","numericSymbols":["k","M","G","T","P","E"],"printChart":"Print chart","resetZoom":"Reset zoom","resetZoomTitle":"Reset zoom level 1:1","shortMonths":["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],"thousandsSep":" ","weekdays":["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]}},"type":"chart","fonts":[],"debug":false},"evals":[],"jsHooks":[]}</script>
</div>
<div class="col-md-6">
<div id="htmlwidget-ba9f27469535691ae1ca" style="width:350px;height:250px;" class="highchart html-widget"></div>
<script type="application/json" data-for="htmlwidget-ba9f27469535691ae1ca">{"x":{"hc_opts":{"title":{"text":null},"yAxis":{"title":{"text":"value"},"type":"linear"},"credits":{"enabled":false},"exporting":{"enabled":false},"plotOptions":{"series":{"label":{"enabled":false},"turboThreshold":0,"showInLegend":false,"animation":false},"treemap":{"layoutAlgorithm":"squarified"},"scatter":{"marker":{"symbol":"circle"}},"pie":{"dataLabels":{"enabled":true}}},"series":[{"group":"group","data":[{"category":"human","value":3,"y":3,"name":"human"},{"category":"non-human","value":4,"y":4,"name":"non-human"},{"category":"snake","value":6,"y":6,"name":"snake"},{"category":"iguana","value":8,"y":8,"name":"iguana"}],"type":"pie"}],"xAxis":{"type":"category","title":{"text":"category"},"categories":null}},"theme":{"chart":{"backgroundColor":"transparent"}},"conf_opts":{"global":{"Date":null,"VMLRadialGradientURL":"http =//code.highcharts.com/list(version)/gfx/vml-radial-gradient.png","canvasToolsURL":"http =//code.highcharts.com/list(version)/modules/canvas-tools.js","getTimezoneOffset":null,"timezoneOffset":0,"useUTC":true},"lang":{"contextButtonTitle":"Chart context menu","decimalPoint":".","downloadJPEG":"Download JPEG image","downloadPDF":"Download PDF document","downloadPNG":"Download PNG image","downloadSVG":"Download SVG vector image","drillUpText":"Back to {series.name}","invalidDate":null,"loading":"Loading...","months":["January","February","March","April","May","June","July","August","September","October","November","December"],"noData":"No data to display","numericSymbols":["k","M","G","T","P","E"],"printChart":"Print chart","resetZoom":"Reset zoom","resetZoomTitle":"Reset zoom level 1:1","shortMonths":["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],"thousandsSep":" ","weekdays":["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]}},"type":"chart","fonts":[],"debug":false},"evals":[],"jsHooks":[]}</script>
</div>
</div>
</div>
</div> <!-- articleBandContent -->
</div> <!-- pageContent -->
<div id="rStudioFooter" class="band full">
<div class="bandContent">
<h4><a href="http://oxshef.io" target="_blank" style="color:#fff;font-weight:bold">OxShef</a></h4>
<div id="logos">
<!--<a href="https://twitter.com/rstudio" class="footerLogo twitter"></a>!-->
<a href="https://github.com/ox-it/OxfordIDN_charts" class="footerLogo gitHub"></a>
<!--<a href="https://www.linkedin.com/company/rstudio-inc" class="footerLogo linkedIn"></a>
<a href="https://www.facebook.com/pages/RStudio-Inc/267733656584415" Class="footerLogo facebook"></a>-->
</div>
</div>
</div>
<!-- bizible -->
<script type="text/javascript" src="//cdn.bizible.com/scripts/bizible.js" async=""></script>
</div>
</div>
</div>
<script>
// add bootstrap table styles to pandoc tables
function bootstrapStylePandocTables() {
$('tr.header').parent('thead').parent('table').addClass('table table-condensed');
}
$(document).ready(function () {
bootstrapStylePandocTables();
});
</script>
</body>
</html>