4
$\begingroup$

I have a dataset that has several machines, the quality of two components over time, and the number of breakdowns in a given year. Simulated Random Data:

enter image description here

Real data consists of 100K machines, the simulated data 1K. The 3 continuous measures I'm interested in are - for each quality level of each component and the combinations thereof, count of machines, number of breakdowns, and number of machines with breakdowns.

The goal is to visualize how each component is performing, and which component is causing more breakdowns, or if it's by some effect of both together.

My question revolves around visualizing how each combination performs. Ignoring the third continuous measure for the moment, I've got single-year heatmaps of the contingency tables:

enter image description here enter image description here

Is there a simple way to plot the contingency table over time? So far I've got facetplots of the heatmap, faceted by year, but that gets clunky real quick.

$\endgroup$

1 Answer 1

3
$\begingroup$

I'm not sure what you mean by "facetplots of the heatmap, faceted by year", but an option may be to draw upon the heatmap/contingency table design, and plot the evolution of each interaction in its own cell (year on the x-axis, the number of interest on the y-axis). It comes down to using line charts in a facet grid.

Here's an example with some made up data:

A facet grid, where each cell contains a x-axis representing the year, and a y-axis representing the number of interest.

Now, it might not be perfect if you want to compare lines together. So you could compress all the facets into a single one. Which gives a single line chart:

Lineplot with year on the horizontal axis, number of breakdowns on the vertical axis, and each of the 9 lines representing an interaction between Q1 and Q2

A single line chart is borderline non-readable with 9 variables, and it would probably not work if you had a larger contingency table. But I think the graph is still understandable even if it requires some attention.

You'll probably get a very different result with your actual dataset. The graph can be probably largely improved with a different choice of colors, increasing the graph size, etc.

You get the general idea: each line representing a different interaction, with time on the x-axis, and the y-axis representing your variable of interest (here I used the number of breakdowns, but you could use the number of machines, or the average number of breakdowns by machine).

An issue you may run into is if several lines are very close to each other, or if some lines are particularly far away from others (making the others looking very close), which can make the graph difficult to read.

In this case, one solution is to transform the data (e.g. taking the power of 2 of the values, exponentiate them, take their logarithm, etc.) to modify the gap between the lines. This may or may not be a good solution depending on what your actual data look like, and what you want to show or to learn from your graph.

Otherwise, you probably have to go back to square one, with the facet grid. It's basically a trade-off between readibility and saving space.

$\endgroup$
1
  • 1
    $\begingroup$ There are 9 lines, but in another sense, it's 3x3, so you might try the combinations of 3 colors with 3 line styles. With some experimenting, you might be able to make the plot more readable. $\endgroup$ Commented Nov 2, 2022 at 16:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.