# How to visualize three different data sets on the same graph?

First of all, I would just like to point out I have next to nothing knowledge about data representation, so I would be more then thankful if someone could answer this question on as basic level as it could be.

I have three different data sets which I need to plot on the very same graph. The first data set is calculated for each year (each graph represents one year) and its purpuse is to show borders between data (e.g. below that value discard all data, between this and this value use weight X, etc). The other data sets represent non-cloudy days wihtin the year and the third set of data are actual values measured every hour for the observed day (14 hours per day). As you can see, in theory, for one year I could have no data at all (all days in the year are cloudy) and for the next year I could have 365 days with each of them carrying 14 different values.

Plain and simple, are there any known graphs for as simple as possible representing this kind of data?

To explain a little bit I'm pasting one homemade graph for this problem. However, I fear that this kind of graph could turn to be pretty messy if there are lots of sunny days in the year. P.S. Attached dummy .csv. In the first column are values for given year (in the picture red line); in the second column are dates (black lines) for a gives year; in the rest of columns are values for a particular day in a year (blue curve).

• Could you attach a simple csv spreadsheet with sample data? – Stephan Kolassa Jan 16 '13 at 15:13
• @StephanKolassa Done. If you prefer a different document type, let me know. – StupidOne Jan 16 '13 at 17:10

I am going to use R. I used dput after reading in the data to make all this reproducible. Define the data and the levels:

example <- structure(list(
V1 = structure(c(4L, 7L, 8L, 3L, 6L, 10L, 11L, 1L, 5L, 12L, 2L, 9L),
.Label = c("12.7.", "14.11.", "14.4.", "15.1.", "15.10.", "15.5.", "17.2.",
"18.3.", "22.12.", "22.6.", "24.6.", "27.10."), class = "factor"),
V2 = c(NA, NA, NA, 7L, 42L, 57L, 41L, 17L, NA, NA, NA, NA),
V3 = c(NA, NA, 22L, 71L, 135L, 175L, 139L, 103L, 29L, NA, NA, NA),
V4 = c(NA, 43L, 109L, 175L, 244L, 256L, 299L, 240L, 152L, 77L, 22L, NA),
V5 = c(95L, 165L, 245L, 300L, 374L, 375L, 400L, 375L, 299L, 200L, 95L, 45L),
V6 = c(180L, 252L, 334L, 421L, 470L, 400L, 529L, 555L, 440L, 330L, 175L, 125L),
V7 = c(237L, 325L, 495L, 500L, 540L, 535L, 626L, 616L, 557L, 440L, 225L, 189L),
V8 = c(257L, 356L, 450L, 575L, 600L, 602L, 650L, 663L, 616L, 475L, 303L, 199L),
V9 = c(245L, 355L, 455L, 550L, 597L, 602L, 657L, 678L, 643L, 499L, 357L, 232L),
V10 = c(259L, 401L, 500L, 521L, 576L, 575L, 655L, 645L, 375L, 400L, 295L, 218L),
V11 = c(222L, 295L, 375L, 495L, 527L, 579L, 599L, 585L, 518L, 400L, 245L, 175L),
V12 = c(157L, 230L, 313L, 398L, 415L, 425L, 517L, 481L, 400L, 310L, 166L, 120L),
V13 = c(67L, 121L, 195L, 255L, 299L, 305L, 382L, 332L, 275L, 99L, 65L, 21L),
V14 = c(NA, NA, 89L, 109L, 208L, 265L, 225L, 201L, 118L, 43L, NA, NA),
V15 = c(NA, NA, NA, 48L, 108L, 121L, 118L, 70L, 12L, NA, NA, NA),
V16 = c(NA, NA, NA, NA, 22L, 39L, 21L, NA, NA, NA, NA, NA)),
.Names = c("V1", "V2", "V3", "V4", "V5", "V6", "V7", "V8",
"V9", "V10", "V11", "V12", "V13", "V14", "V15", "V16"),
class = "data.frame",
row.names = c(NA, -12L))
example.levels <- c(115,170,250,330,385,600)


Then we plot twelve subplots. In each subplot, we add your levels as horizontal lines. Note that I am constraining the $y$ axis to be identical across plots so we can visually compare them:

opar <- par(mfrow=c(3,4),mai=c(.2,.3,.3,.1)+.02)
for ( ii in 1:12 ) {
plot(1:15,as.numeric(example[ii,-1]),xlab="",ylab="",
xaxt="n",main=example[ii,1],ylim=c(0,700),type="o")
abline(h=example.levels,col="grey")
}
par(opar)


I am not putting the times on the x axis since they will be hard to read anyway, but perhaps one could truncate the minutes and just note the hours. Result: • You're welcome! Please consider accepting the answer if it helps (by clicking on the small checkmark under the answer's votes) - this is good for you, good for me, good for everyone. – Stephan Kolassa Jan 17 '13 at 9:04
• I know. I just have habbit of leaving question "open" for at least a day after the last answer is posted. – StupidOne Jan 17 '13 at 9:11
• Sure, no problem. I'd be interested in any other approaches to visualizing these data, as well. – Stephan Kolassa Jan 17 '13 at 9:12

Firstly, I wouldn't use your style, the rotational 3D nature of display is going to making it almost impossible to compare values with any degree of accuracy.

I think what you want is to use some kind of what R's ggplot2 calls "facet grids" - see Cookbook for R >> Facets - and/or just plotting multiple lines on the same graph. I'd strongly suggest, however, that trying to force all your data into a single plot is going to be unreadable. Even a hundred days of data is going to be essentially unintelligible. I would consider subdividing by month, for example.

Finally, I'm not clear on what exactly you are trying to get out of your data. How exactly you visualise it will depend on what you want to be able to see in the data, perhaps if you were to explain what you data actually is and what you want to be able to deduce from your graphs it would help?