# Plots, DataFrames, composite x-axis

**URL:** <https://discourse.julialang.org/t/plots-dataframes-composite-x-axis/75458>\
**Category:** General Usage\
**Tags:** dataframes, plots\
**Created:** [January 30, 2022, 9:01am UTC](https://discourse.julialang.org/t/plots-dataframes-composite-x-axis/75458 "2022-01-30T09:01:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![maajdl](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maajdl/32/22838_2.png) [@maajdl](https://discourse.julialang.org/u/maajdl)\
**Post date:** [January 30, 2022, 9:01am UTC](https://discourse.julialang.org/t/plots-dataframes-composite-x-axis/75458/1 "2022-01-30T09:01:42Z")

</div>

Hello

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,

Michel

 ![Picture1](https://global.discourse-cdn.com/julialang/original/3X/1/d/1d841439bd5977de04cbd977eb2a6d550a574b17.png)

---

<div class="post-metadata">

**Author:** ![cjdoris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cjdoris/32/213133_2.png) [@cjdoris](https://discourse.julialang.org/u/cjdoris)\
**Post date:** [January 30, 2022, 10:13am UTC](https://discourse.julialang.org/t/plots-dataframes-composite-x-axis/75458/2 "2022-01-30T10:13:59Z")

</div>

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](http://juliaplots.org/AlgebraOfGraphics.jl/dev/gallery/gallery/layout/faceting/#Faceting)

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

---

<div class="post-metadata">

**Author:** ![maajdl](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maajdl/32/22838_2.png) [@maajdl](https://discourse.julialang.org/u/maajdl)\
**Post date:** [January 30, 2022, 10:23am UTC](https://discourse.julialang.org/t/plots-dataframes-composite-x-axis/75458/3 "2022-01-30T10:23:27Z")

</div>

Thanks  
Reminds me of Holoviews in Python!  
Not so enthousiast to use an additionl plot package 🥲.  
But maybe!  
Michel

---

<div class="post-metadata">

**Author:** ![cjdoris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cjdoris/32/213133_2.png) [@cjdoris](https://discourse.julialang.org/u/cjdoris)\
**Post date:** [January 30, 2022, 10:45am UTC](https://discourse.julialang.org/t/plots-dataframes-composite-x-axis/75458/4 "2022-01-30T10:45:37Z")

</div>

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.
