Mexico City Average Temperature Seasonality Cycle Plot

Cycle Plots in Qlik

Mexico City Average Temperature Seasonality Cycle PlotBefore I continue with my blog series about becoming a Qlik Sense Developer, I’d like to share my current progress and confirm that it has been well worth the extra time and effort.  I’ve found out that there are manifold ways to apply web development skills to extend Qlik Sense’s functionality. For example, you can create a bot that answers your natural language questions, a connector to access data that is stored in Qlik Sense from other tools, expand Qlik Sense’s administrative functionality, or a mashup that tells a data-driven story.

A few developers are a master of everything, but most of us, especially those of us who are beginners, are likely to only specialize in a certain area that motivates us the most. My current aim is to concentrate my efforts to the creation and maintenance of insightful, but less well-known, data visualizations in Qlik Sense. This initiative begins with visualizing seasonality using a cycle plot.

Visualizing Seasonality in Qlik

When we, QlikView Developers, hear the word “seasonality” from business users, we are inclined to propose the radar chart. The QlikView data visualization guide which dates back to 2009, and still exists in the Qlik’s demo site, helps propagate this idea.

Let’s take a closer look at seasonality, and how we can visualize it using a line chart, a radar chart, and a less common, but powerful visualization called a cycle plot. We’ll use weather data from Mexico City to demonstrate how useful it can be.

The City That Has No Season

When many think of Mexican weather, they think of tropical beaches like Cancun. On the other hand, Mexico City has a relatively steady temperature that is neither too hot nor too cold all year round. Life-long residents will always complain about what they perceive to be extreme weather, but it is nothing like the marked extremes of temperate zones like my home state of Iowa, USA.

Due to the importance of agriculture in Iowa, weather is an important part of the daily news and gossip. When I call my parents, they never miss the opportunity to ask how the weather is in Mexico. In Iowa, it is common knowledge that July and August are going to be the hottest months and January the coldest.

The habitants of Mexico are less concerned about the weather, and it’s hard to guess which months are the hottest or the coldest.  However, they never fail to share their opinions two times a year. Every November, I hear the words, “It’s so cold today! Man, something tells me that this winter is going to be really bad.” Then, every March, I hear the exact opposite, “It’s so hot today. Man, something tells me that it’s going to be really hot this year.” I’ve jokingly dismissed the habitants’ biannual complaint for the last ten years, without any knowledge of Mexico City’s actual seasonal temperatures or yearly trends.

Let’s put data where my mouth is and find out if there’s any truth beyond one’s own perception. I downloaded the average, minimum, and maximum monthly temperatures by state in Mexico from https://datos.gob.mx/ and visualized seasonality in the following three ways.

Seasonality with a Line Chart

The first option to visualize seasonality and yearly trends is to use a line chart. In the following chart we can observe the average monthly temperatures in Celsius for Mexico City from 1985 to 2015. In between all the noise, we can perceive a winter from November to February, a relatively hot spring that peaks in May, and a long, mild, and unchanging summer from June to October.

Along with the seasons, we can also note a change through the years. I used a sequential color schema to show the years. The most recent years are a darker orange, and show that while the seasonality doesn’t appear to have changed, the temperature of every month has shifted upwards over in the last several years.

Let’s see if a radar chart can offer any new perspective.

Seasonality with a Radar Chart

I converted the previous line chart into a radar chart with the help of an extension developed by Brian Booden and Matthieu Burel. Some analysts like to use a radar chart to study seasonality because it is a visual metaphor of the cyclical nature of seasonality.

However, I’d avoid getting too wrapped up in using visual metaphors, such as radar charts or funnel charts, to visualize data. Their pseudo, visual poetry comes at a cost. You’ll notice in the previous example that it would be impossible to accurately compare December and June temperatures without the support of the grid lines. Curiously, we don’t measure the difference of these two months by using the distance between the center of the circle and the data point. Instead, we use the distance between the final, arbitrary grid line and the data point.

We can argue that it adds new data in the form of a line between December and January, and facilitates the comparison between the first and last month of the cycle. However, again, this new data doesn’t make up for the loss of our ability to accurately compare all the other months. In my opinion, a better complement to the first line chart would be cycle plot.

Seasonality with a Cycle Plot

Our cycle plot begins by calculating the average (mean) value of each month throughout the years and displaying the value as a straight line for each month. In the following cycle plot, the mean is the straight, gray line, and it tells us that, on average, May is the hottest month of the year in Mexico City.  The award for the coldest month of the year is a near tie between December and January.

Mexico City Average Temperature Seasonality Cycle Plot

The next step is to analyze how the temperatures of each month have changed throughout the years. We do this by displaying the temperatures for the same month of every year in 12 mini line charts. In the first line chart in the beginning of this post, we can perceive that temperatures have risen in latter years through the use of color. However, the use of color can only give us a general idea of this rise. The cycle plot gives us a detailed view of how temperatures have evolved through the years.

For example, in the cycle plot we can make the following observations:

  • There is a consistent upward trend in February, March, and April.
  • The temperatures of June, August, and September rose with a sudden jump.
  • November’s temperatures have held steady.

I don’t know whether this rise in temperature is due to a larger weather cycle, a local environmental event, or global climate change. I’ll leave that to the scientists to decide. All that I can say is that there may be some truth to the idea that summers are getting hotter in Mexico City. Even so, to my surprise, May is actually the hottest month of the year.

Update: Check out Vlad Gutkovsky’s introduction to Violin Plots using the same data set. It’s a great reminder that the goal of learning data visualization is not to find the one, perfect chart; but rather, to know how to use multiple visualization types to extract meaning from data.

Download the Qlik Sense Cycle Plot

Along with weather, you can also use cycle plots to analysis the periodicity of website visitors by the hours in a day, or a store’s sales by the days in a week, or expenses by the quarters in a year.  You can read more about cycle plots in an article by Stephen Few.

You can download and use a free version of the Qlik Sense Cycle Plot from GitHub. (I’ll add it to Qlik Branch once I merge accounts.) You can also find a full feature, supported version of the Qlik Sense Cycle Plot in the Vizlib Marketplace.

Qlik Sense Cycle Plot Functionality by Karl Pover

One more thing…

For those of you going to Qonnections 2018, I will have a breakout session called Qlik Sense Visualization Extension Boot Camp. This session is for all those who are interested in joining me on this journey to become a full-fledged Qlik Sense Developer, but who don’t have any web development experience. We’ll discuss the basics of web development, get a general idea all the things we need to learn, and develop a learning path to follow during the next year.  I hope to see many of you there.


Tags:

Comments

7 responses to “Cycle Plots in Qlik”

  1. Vlad Gutkovsky Avatar
    Vlad Gutkovsky

    Nice work, Karl! There are a couple issues that I can see from a dataviz perspective though. Truly mean these constructively, not to detract from your great work.

    There are a ton of data points (12 * 31 = 372 points total + 12 mean lines). That’s a lot. The monthly plots are tiny and there’s a whole heap of unused whitespace. I wonder, is there actually an advantage here in putting 12 months next to each other in a single horizontal row? This would seem to lend itself well to a 3 x 4 trellis. You would lose the benefit of having Jan and Dec in the same row, but I doubt anyone can compare those numbers effectively anyway, they’re so far apart from each other. You might also split the trellis into seasons, such that spring is on one row, summer on another, etc. You’d want your Y axis to be frozen at the same minimum value for all rows, of course, but I don’t think there’s a real need to make that value 0; Mexico doesn’t get that cold and you’re looking for trends, not volume comparisons.

    On an unrelated note, I’ve recently taken a shine to violin plots, which I feel would be pretty interesting with your data set. The idea is that you remove years as a secondary dimension and just leave month. Each month would have a box plot that represents the usual box plot stuff (mean, first quartile, third quartile). The violin portion would give viewers an indication of how many samples of each temperature were taken. This is useful because obviously there are different ways of arriving at the same mean. 3 readings of 21, 22, and 23 degrees would result in a mean of 22. But 3 readings of 16, 22, and 28 would also result in a mean of 22. A violin plot would call out data point concentrations. Of course, what it doesn’t do is show change over time. So I’m not suggesting that it would show the same story, but the story it would show be very effective in its own right.

    Like

    1. Karl Pover Avatar

      Hello Vlad, It’s good to talk to you again, and it’s always great to get feedback from you. No need to be so delicate with me.

      First, thank you for introducing me to the violin plot. I had not see that before, and even though it wouldn’t reveal how some months’ temperatures have risen through the years, it would show a different perspective, and possibility, another interesting story.

      Second, you are correct about forcing the y-axis to zero. Since this chart can be used to only analyze trends then there should be an option to not force the y-axis to zero. Again, if your aim is to analyze trends then this would eliminate excessive whitespace. If your aim is to measure magnitude and trend, whitespace isn’t excessive because it has meaning.

      Third, since a trellis chart uses a y-axis with the same range for each individual chart, I don’t think it would have any less whitespace than the complete chart. I also think there is some value to seeing the overall shape of the data over the entire time period. This would be more difficult to perceive if it were broken up into a series of small multiples. A trellis chart that would show several cycle plots of monthly temperatures by state or country would be great.

      If, as you said, I would break the months down by season into different charts and not force the axes to zero then it would be as if I zoomed in closer to the data, and yes, I would have less whitespace. However, I believe I would lose an overall perspective of the data when I display it this way.

      I know you would know this Vlad, but for other readers who are interested in cycle plots and not familiar with Qlik, a user can dynamically zoom into specific months for more detail once she has an idea of the overall trend.

      Karl

      Like

      1. Vlad Gutkovsky Avatar
        Vlad Gutkovsky

        Very cool GIF! What tool do you use to make that? Valid point about clicking to zoom in.

        Regarding violin plots, I’d like to do a write up on my own blog to introduce folks to this little-known type of chart. Would you mind if I link back to your blog? You inspired me to use average temps in Mexico City (very effective dataset for demo purposes) and I’d like to use your post to discuss how it’s important to see trends over time as well, in order to get a complete picture.

        Like

      2. Karl Pover Avatar

        I use SnagIt. I use it so much that I gladly pay for it.

        Please go ahead and use the same data. I look forward to seeing another side of the story. I think it’s important that people realize that data visualization is not about finding and using one perfect chart. It’s about knowing the strengths (and weaknesses) of various chart types to tell a complete story.

        Give me a heads-up the moment you post it and I’ll add the link to my post as while.

        Like

  2. […] put together a view of the same data as a cycle plot. I recommend that everyone check out his post here. Our two views together paint a much more complete and powerful picture of average temperatures in […]

    Like

  3. […] Before I continue with my blog series about becoming a Qlik Sense Developer, I’d like to share my current progress and confirm that it has been well worth the extra time and effort.  I’ve found out that there are manifold ways to apply web development skills to extend Qlik Sense’s functionality —  Cycle Plots in Qlik by Harvesting Wisdom […]

    Like

Leave a comment