<p><div><div><div><div data-width="100" data-show-faces="false" data-send="true" data-layout="button_count" data-height="21" data-href="https://www.r-bloggers.com/repurposing-the-candlestick-chart/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://www.maxhumber.com/2017/01/15/candlesticks.html"> max humber</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>My cousin Eli is way cooler than me. Well, to be fair, I don’t exactly set a high bar! Eli is a skydiving enthusiast with over 200 jumps to his name. And I read books and write nonsense like this…</p>
<p>Eli is meticulous about collecting metadata from each of his jumps. Just a glance at his logbook and you can tell there’s something interesting hiding in there. So. I asked him if I could play with his data and try to come up with something.</p>
<p>I don’t know the technical terms, but basically, when you think about it, there are, hopefully, three stages in every skydive. The jump, the pull, and the landing. I thought that I could do something interesting with those three events across each jump. But the histograms and line graphs and bar charts that I’ve come to rely on just weren’t working. Interesting data deserves an interesting visualization.</p>
<p>After some time messing around with graphical primitives in <code>ggplot2</code> I hit on a candlestick-esque chart built from <code>geom_segment</code>s that I thought could work.</p>
<p>This was my first attempt with simulated data:</p>
<p><img alt="" src="https://i2.wp.com/www.maxhumber.com/assets/img/candle1.png?w=456" data-recalc-dims="1"></p>
<p>After getting Eli’s logbook to conform to and look like the simulated data I threw it all back into the <code>geom_segment</code>s and got this:</p>
<p><img alt="" src="https://i0.wp.com/www.maxhumber.com/assets/img/candle2.png?w=456" data-recalc-dims="1"></p>
<p>A little busy for my tastes. So, I decided to break every rule in data visualization and strip away all the fuss. I got rid of the labels and axes and text and titles and the legends because it was all noise and getting in the way of Eli’s fearlessness (stupidity?) and the data. I wanted the raw stuff to shine.</p>
<p>This is what I finally arrived at:</p>
<p><img alt="" src="https://i1.wp.com/www.maxhumber.com/assets/img/candle3.png?w=456" data-recalc-dims="1"></p>
<p>I love this slimmed down version because it’s kind of like putting notches in a wall. And despite the lack of labels and text annotations you can still see a lot. For instance, you can see Eli’s training exercises (two short bursts on the second and third row as well as the string of short jumps near the end of the third row). You can tease out some semblance of consistency in his free falls. And you can see where it almost all came to an end…that data point near the end of the second row where he had to pull his reserve chute.</p>
<p>Anyways. Thanks for letting my play with your data, Eli! For anyone interested, this is the <code>ggplot2</code> code that I used to create the final graph. And if you want to see all of the data for this post, it’s available on <a target="_blank" rel="nofollow" href="https://github.com/maxhumber/maxhumber.com/tree/master/_R">GitHub</a>:</p>
<div>
<pre><code><span>df</span><span> </span><span>%>%</span><span> </span><span>ggplot</span><span>(</span><span>aes</span><span>(</span><span>x</span><span> </span><span>=</span><span> </span><span>id</span><span>))</span><span> </span><span>+</span><span> </span><span>geom_segment</span><span>(</span><span>size</span><span> </span><span>=</span><span> </span><span>1</span><span>,</span><span> </span><span>color</span><span> </span><span>=</span><span> </span><span>&quot;grey20&quot;</span><span>,</span><span> </span><span>aes</span><span>(</span><span>
</span><span>xend</span><span> </span><span>=</span><span> </span><span>id</span><span>,</span><span>
</span><span>y</span><span> </span><span>=</span><span> </span><span>jump</span><span>,</span><span> </span><span>yend</span><span> </span><span>=</span><span> </span><span>chute</span><span>))</span><span> </span><span>+</span><span>
</span><span>geom_segment</span><span>(</span><span>lty</span><span> </span><span>=</span><span> </span><span>1</span><span>,</span><span> </span><span>size</span><span> </span><span>=</span><span> </span><span>0.25</span><span>,</span><span> </span><span>color</span><span> </span><span>=</span><span> </span><span>&quot;grey40&quot;</span><span>,</span><span> </span><span>aes</span><span>(</span><span>
</span><span>xend</span><span> </span><span>=</span><span> </span><span>id</span><span>,</span><span>
</span><span>y</span><span> </span><span>=</span><span> </span><span>chute</span><span>,</span><span> </span><span>yend</span><span> </span><span>=</span><span> </span><span>0</span><span>))</span><span> </span><span>+</span><span>
</span><span>facet_wrap</span><span>(</span><span>~</span><span>section</span><span>,</span><span> </span><span>scales</span><span> </span><span>=</span><span> </span><span>&quot;free_x&quot;</span><span>,</span><span> </span><span>ncol</span><span> </span><span>=</span><span> </span><span>1</span><span>)</span><span> </span><span>+</span><span> </span><span>labs</span><span>(</span><span>title</span><span> </span><span>=</span><span> </span><span>&quot;&quot;</span><span>,</span><span> </span><span>x</span><span> </span><span>=</span><span> </span><span>&quot;&quot;</span><span>,</span><span> </span><span>y</span><span> </span><span>=</span><span> </span><span>&quot;&quot;</span><span>,</span><span> </span><span>color</span><span> </span><span>=</span><span> </span><span>&quot;&quot;</span><span>)</span><span> </span><span>+</span><span> </span><span>scale_x_continuous</span><span>(</span><span>breaks</span><span> </span><span>=</span><span> </span><span>seq</span><span>(</span><span>0</span><span>,</span><span> </span><span>500</span><span>,</span><span> </span><span>25</span><span>))</span><span> </span><span>+</span><span> </span><span>theme</span><span>(</span><span>
</span><span>panel.background</span><span> </span><span>=</span><span> </span><span>element_rect</span><span>(</span><span>fill</span><span> </span><span>=</span><span> </span><span>&quot;#FFFFFF&quot;</span><span>),</span><span> </span><span>panel.grid.major</span><span> </span><span>=</span><span> </span><span>element_blank</span><span>(),</span><span>
</span><span>panel.grid.minor</span><span> </span><span>=</span><span> </span><span>element_blank</span><span>(),</span><span>
</span><span>strip.text</span><span> </span><span>=</span><span> </span><span>element_blank</span><span>(),</span><span>
</span><span>axis.ticks</span><span> </span><span>=</span><span> </span><span>element_blank</span><span>(),</span><span>
</span><span>legend.position</span><span> </span><span>=</span><span> </span><span>&quot;none&quot;</span><span>,</span><span>
</span><span>axis.text</span><span> </span><span>=</span><span> </span><span>element_blank</span><span>())</span><span>
</span></code></pre>
</div>
<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://www.maxhumber.com/2017/01/15/candlesticks.html"> max humber</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a title="The R Project for Statistical Computing" rel="nofollow" href="https://www.r-project.org/">R</a> news and <a title="R tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="https://www.r-bloggers.com/search/data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data">Big Data, <a title="R jobs" rel="nofollow" href="https://www.r-users.com/">R jobs</a>, visualization (<a title="ggplot and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="https://www.r-bloggers.com/search/map">maps</a>, <a title="Animation in R" rel="nofollow" href="https://www.r-bloggers.com/search/animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="https://www.r-bloggers.com/search/RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="https://www.r-bloggers.com/search/sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="https://www.r-bloggers.com/search/SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="https://www.r-bloggers.com/search/eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="https://www.r-bloggers.com/search/git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="https://www.r-bloggers.com/search/hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="https://www.r-bloggers.com/search/PCA">PCA</a>, <a title="Time series" rel="nofollow" href="https://www.r-bloggers.com/search/time+series">time series</a>, <a title="finance trading" rel="nofollow" href="https://www.r-bloggers.com/search/trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/Rji5KzDn4yc"></a></div>