Let's track the falling gasoline prices!

13

When I fill up my daily-driver Prius, the price of gasoline isn't that important. But when I occasionally take a trip in my V8 Suburban, I pay a lot more attention! Therefore I was pleasantly surprised when I noticed that gasoline prices have been falling. How much have they fallen, and how do the current prices compare with the past prices? ... Let's graph some data, and find out!

But before we get into the data analysis, here's a picture to get you into the right mood... My friend David recently took this picture at a gas station just north of Raleigh, NC. Did you ever think you'd see gasoline prices less than $2/gallon again?!? What's the lowest price you've seen in your area? (feel free to post your price in the comments!)

Now, let's analyze that price data! Fortunately, the Energy Information Administration tracks the average price of gasoline in the US on a weekly basis, and has that data available on their web page. I downloaded their Excel spreadsheet, imported it into SAS, and created a preliminary plot.

That's a fine starting place, but let's make a few improvements. Series/line plots typically auto-scale the y-axis, so that you can see as much detail as possible. But in this case I'd like the axis to start at zero, so the values are plotted in such a way that you can visually compare them proportionally (for example, a price of $2 is twice as 'high' in the y-direction as a price of $1). Also, I don't want to go too far back in time, because inflation makes it difficult to compare the prices (unless you apply a price index to convert all values to a certain year). I decided that the year 2000 seemed to make a good starting point. I also added grid lines, so it is easier to compare values over time. Here's the slightly improved version of the graph:

Now that my y-axis starts at zero, it becomes more evident that what I'm really wanting to show & compare is the value under the line. A bar chart is typically used for such comparisons, but in this case there are way to many weekly values to plot using bars - or are there?... What's the skinniest 'bar' we could use? How about using a bar that's 1 pixel wide ... which we call a 'needle'! A needle plot simply draws a line from the data point to the horizontal axis, and functions like a bar chart with very skinny bars. Below I have changed from a series plot to a needle plot, and also added a second y-axis on the right (to make it easier to see the prices, for the most recent data).

Although the graph has grid lines and two y-axes, it's still a bit of mental work to 'see' when the gasoline prices crossed certain milestones. Why not add another visual dimension to help - lets add color! I assigned a different color for each needle line, with the color getting darker at every 50-cent increment (which corresponds to my grid lines). I think this color dimension is what makes the graph!

You might think we're done ... but let's add two more finishing touches. Often when the price in a graph is dropping or climbing very quickly, it's difficult to see where the final data point is located. Therefore I like to add a marker on the final price (in this case, I add an 'x' marker). And I also like to add a footnote, indicating where and when the data is from. Here is my final graph:

From this graph, you can see that average US gasoline prices peaked in 2008 (just before the big worldwide recession) at over $4/gallon. The current price is $2.25, which is fairly low, but not as low as it dipped in 2016. What are your predictions for gasoline prices this year (feel free to discuss in the comments section).

Here's a link to the SAS code used to create all these graphs, if you'd like to see all the tricks used!

 

Share

About Author

Robert Allison

The Graph Guy!

Robert has worked at SAS for over a quarter century, and his specialty is customizing graphs and maps - adding those little extra touches that help them answer your questions at a glance. His educational background is in Computer Science, and he holds a BS, MS, and PhD from NC State University.

13 Comments

  1. I really enjoyed this post, Robert! The progression, with steps, of the initial data load to your "final product", was really helpful.

    In The Bahamas, where I am from, gas was around $4.95 cents a gallon when it was at it's lowest here in the USA over the last month.

  2. This might be an off topic question—but any specific reason you used sgplot and not gplot for this one? I ask because you usually favor gplot.

  3. I saw a $1.94 in Cary, NC today 1/16/19. Does diesel#2 follow the same comparison as well as any other intermodal or commercial fuels like CNG or coal for power generation or commodity fuels for trains, planes, and ships? Would be insightful to see those patterns? If you forecasted this, what would it look like?

  4. Always love seeing our data work. Looking ahead though usually what goes up must go down, and vice versa. Even if not this year my bet is that gas prices will go up again which is why I bought a hybrid that gives me 600m per gallon on regular gas. :-)

Leave A Reply

Back to Top