Plots, DataFrames, composite x-axis


I would like to create a plot similar to this shown below.
It would be based on a dataframe and I would like to use Plots.
The x axis data would come from two columns.
Like a country-code and a date, as shown.
I am long used to the way Excel does that for PivotCharts.
This is how I created the attached chart.

I have tried a few solutions based on creating an extra column that combine the two original columns for the x axis. But that is hardly readable.

Thanks for you suggestions,


I’m not sure with Plots, but with AlgebraOfGraphics (or other grammar-of-graphics-style packages like Gadfly or VegaLite) you can achieve approximately this with a facet chart: Faceting · Algebra of Graphics

In your case you’d have something like mapping(:date, :y, col=:country).

Reminds me of Holoviews in Python!
Not so enthousiast to use an additionl plot package :smiling_face_with_tear:.
But maybe!

You can probably do the same thing in Plots “by hand” by making a subplot for each country, layed out in a row, with the axes linked.

1 Like