I had this idea of using some of my travel photos to create a photo calendar. I would normally go about it using Adobe Photoshop or Adobe Illustrator. But, that would involve a lot of manual work placing dates and days for each month. I would also like to mark some public holidays and friend’s birthdays. So, I wondered if it might be possible to do it with R. After fiddling about with it over the weekend, I managed to make it work. It went better than I expected. And here I am recreating the calendar using some stock photos. All stock photos are royalty-free from Pexels. For the impatient ones, the whole code and images are available at this Github repository. For detailed guide, keep reading.
It may seem like the world is descending into total chaos, violence, and destruction. War in Syria, Ukraine, Yemen, Islamic state, migrant crisis, Ebola, plane crashes, earthquakes, tsunamis and what-not. The more news you watch, the more worried you will be. This is because the news outlets tend to focus on spectacularly negative instances. Violence, atrocities, and hatred are thrown into the spotlight and into the lives of common people. With the ever increasing digital connectivity, it is easy to disseminate information and to absorb information at an unprecedented level. Relatively smaller incidents have a larger voice. As said by Ray Kurzwil, “The world isn’t getting worse, our information is getting better”. To appreciate the world we live in, we have to put things into a wider context.
The fact is that humanity has never lived in a better time than now in pretty much every aspect you look at; war, violence, diseases, poverty are all at the lowest it has ever been. Of course, there is still a long way to go, but this is the best it has been since the beginning of humankind. To prove my point, here we evaluate human progress using some real data and simple time-series plots. Most of the data and information was obtained from OurWorldInData.
This post/code is now outdated. Please see this new link for updated code.
This was inspired by the disease incidence rate in the US featured on the Wall Street Journal which I mentioned in one of the previous posts. The disease incidence dataset was originally used in this article in the New England Journal of Medicine. Here, I use the measles level 1 incidence (cases per 100,000 people) dataset obtained as a .csv file from Project Tycho. Download the .csv file here or head over to Project Tycho for other datasets.
In this post, we will look into creating a neat, clean and elegant heatmap in R. No clustering, no dendrograms, no trace lines, no bullshit. We will go through some basic data cleanup, reformatting and finally plotting. We go through this step by step. For the whole code with minimal explanations, scroll to the bottom of the page.
Scientific graphs are key in science to presenting usually complex data in an attractive and concise manner. Scientific graphs are supposed to be a visually summary of your data.
Data collection > Data analysis > Data visualisation
The most important part of a plot is of course its content. Once you have good content/data, you need to think about how to represent this data. Which sort of plot to use. How to best convey this information. See this article for most common types of data visualisation. Some of the popular programming environments for plotting include
Julia being the latest addition. Other options include Excel, Tableau, Plotly and more.
R is a great tool for graphics as evident from the numerous images, blogs and publications over the past years. There are several resources that can help you find code to create all sorts of graphs in
But, just managing to create a graph is not sufficient in my opinion. The graphic has to be beautiful, elegant, user-friendly and attractive. Getting from data to a plot is one thing, but creating a high-quality, publishable and professional looking figure is a different story. A Basic plot is the initial basic output figure from any plotting software. This uses the default setting and default looks. Most people stop at this point because they have gone through considerable effort to get the data, analyse it and finally figure out the code to plot it. But a basic plot is usually not going to look professional or elegant. It will need some level of customisation to make it attractive. The
ggplot2 plotting package in
R, for example, produces a pretty decent default output, but they are overused and the graphics are not unique or catchy. I haven’t come across many sources that go into the fine details of the making a professional looking graph. We will go into plot customisation in
R in a future post, but, in this post, we explore some examples of customised plots.