# Data visualization for missing data

I am a designer and am trying to plot a set of data over time. For example,

Day1     Day2     Day3      Day4      Day5
10       53       21        67        38


I am using a normal line chart to plot this, but when there is no data available for a day or two in between (like below, for example) the developers are assuming it to be zero and the plot actually dips down to zero and goes up. I somehow feel this is not correct.

Day1     Day2     Day3      Day4      Day5
10                          67        38


When I use MS Excel to plot the above data (with missing values in between), it draws a line from 67 to 38 (Line Chart). If I enter say, 25 in Day2, I see a line from 10 to 25 and then a gap then from 67 to 38.

1. Now, my question is, is it correct to simply join the line from 25 (Day2) to 67 (Day3), so that I may get a continuous graph?

I see some designs containing splines instead if straight lines connecting two points. This is visually appealing, but I know splines are used to for data interpolation (correct me if I am wrong) and not in such cases as I have described.

1. Can I still plot the known points using a spline? Is this acceptable?

I am sorry if my questions are lame, because my knowledge in statistics and data visualization is less.

I would honestly simply leave data points without information empty. In R:

foo <- structure(c(10,NA,NA,67,38),.Names=paste0("Day",1:5))
plot(foo,xaxt="n",xlab="",ylab="",pch=19,type="o",
ylim=c(0,max(foo,na.rm=TRUE)))
axis(1,seq_along(foo),names(foo))


Anything else is defensible if it reflects information you have about your data. For instance, if your database recorded sales and your store was open on days 2 & 3, but nobody wanted to buy your widgets, then you can validly infer and plot zeros. (If the store was closed or you were out of stock in widgets, you should not, since any demand could not have been satisfied.)

You could linearly interpolate if this is a "good guess" at what "really" happened during the periods with no data. Of course, what is a "good guess" will depend on your specific situation.

I would not use splines, unless I had a very good reason. Linear interpolation is simpler, and one should always use a simpler approach unless a more complex one like splines is warranted (Occam's razor). Plus, higher-order splines can explode, depending on your specific data.

• Thank you, Stephan for quick reply. My problem is when I show data for a long period of time, there's a possibility of data not being available for three or four days in between, in which case, according to your suggestion, there would be a break in line (while showing the timeline). I am showing the number of reviews received over time. So, if there were no reviews given on a specific date(s) I would have a break in the line. – user2637926 Jun 30 '15 at 12:19
• If reviews could have been received but were not (because nobody wanted to review), then interpolating zeros makes sense. Otherwise (e.g., reviews were not received because the system was down), I'd leave holes for however many days there are. I often have exactly this situation in plotting supermarket sales that can be zero for an item, or can be missing if the store is closed (on Sundays in Germany). – Stephan Kolassa Jun 30 '15 at 12:23
• I see what you are saying. That helps. Coming back to my other question regarding splines, is this something I can use (mainly for aesthetic purpose)? I have, say 10 reviews for Day 1 and 20 for Day 2, can I join the two points using a curve? Or is this statistically a wrong representation? – user2637926 Jun 30 '15 at 12:30
• I'd go with a straight line for simplicity. Anything "curvy" (like here) suggests that you know that the dynamics differ over the interval you are interpolating. If you do know that, great, and go wild - if not, don't give the impression that you do. – Stephan Kolassa Jun 30 '15 at 12:34
• If you have any idea about the intra-day pattern, you can think about including it, but that would be a different plot. What does the vertical position of the line 1/3 of the way from Wed to Thu mean? It can't be that at this point in time, there is a value of (say) 1,200, because the interpolated values already give daily totals. No, the only reason for the lines is to join the dots. And there, I'd go with a simpler rather than a more complex solution. (If three dots form a descending pattern, why should the line have a zero derivative at the central one?) Call me simplicity-obsessed ;-) – Stephan Kolassa Jun 30 '15 at 12:56