# How to visualize categorical data over time?

I'm visualizing results from lab tests. Most of these results are numerical and therefore easily communicated using line graphs, where the x-axis is time and the y-axis is determined by the range of possible values, like [0, 100].

EDIT: To be clear, I'm not measuring frequency. I'm displaying an individual's lab test results for one specific test (like cholesterol) over time. Since most people don't get more than 1 or 2 lab tests a year, most people's graphs will have less than a dozen (x,y) values.

I'm less sure how to visualize this information when the y-axis values are categorical:

• Sometimes the possible values are themselves ranges. A test value will be something like 2-6, meaning that the value falls between 2 and 6 — and that's all we need to know. Would it make sense to graph these values with something like error bars? Or would it make more sense to graph the average of the range (in this case, 4) as a regular line chart?

• The other types involve categories which are non-numerical. Sometimes these are ordinal. In the ordinal case the categories might be something like [none, few, moderate, many]. Does it make sense to just assign an index to each [0, 1, 2, 3] and use a standard line graph? If not, what would make more sense?

• Lastly, non-numerical, nominal types. These are categories with no clear rank hierarchy, like colors: [yellow, orange, red]. In this case, I think it might be misleading to use a standard line graph, because it would imply that certain colors are "higher" or "better" than others. What would be appropriate?

I'll give it a go, but a lot depends on how you want to communicate your results.

1. try to keep the buckets, and add counts to them, so you end up with something like:
date bucket count
2015-09-11 2-6 6
2015-09-12 2-6 9
2015-09-13 2-6 2
2015-09-11 10-16 9
2015-09-12 10-16 15
2015-09-13 10-16 4


This you can communicate either via a line chart, but I would go with side by side bar charts per period, maybe aggregated to week or month depending your timeline. If you have many ranges, splitting them in different graphs.

1. Don't index the ordinal values. The reader of the graph should not look somewhere else to figure out what the numbers mean. Just use counts with the ordinals and use line charts or bar charts, summary tables or a cross(table)

2. Count the occurences and use side-by-side or stacked bar charts and color the bars according to the colors you have. But human perception will always give a higher bar / line / area more weight than a smaller / lower one. Or just represent it as a table. That way you don't give any opinion except that some colors might occur more frequently than other.

• I really appreciate the detailed answer, but I think I might not have phrased my question clearly. Only 1 value (X) will ever be shown for a time value (Y). There's no need to bucket as what's being graphed are an individual's test results.
– jd87
Sep 13, 2015 at 14:16

X and Y, Size, Texture, Shape, Orientation, Color are some common encodings for data visualization. Some of them have implied orders (X and Y, Size). In your case, I feel that you may use an unordered encoding such as color.

FYR. The following website have a rather comprehensive explanation. https://www.safaribooksonline.com/library/view/designing-data-visualizations/9781449314774/ch04.html