Skip to content
Advertisement

How to plot data from multiple dataframes with seaborn relplot

I want to plot two lines on the same set of axes. It seems sns.relplot is creating a facetted figure, and I don’t know how to specify that I want the second line on the same facet as the first.

Here’s a MWE

JavaScript

How do I get the red and blue lines on the same plot? I’ve not had luck with different permutations of map.

Advertisement

Answer

  • seaborn.relplot is a FacetGrid, the dataframes should be combined to plot them together
    • Figure-level interface for drawing relational plots onto a FacetGrid.
      • This function provides access to several different axes-level functions that show the relationship between two variables with semantic mappings of subsets. The kind parameter selects the underlying axes-level function to use:
        • scatterplot() (with kind=”scatter”; the default)
        • lineplot() (with kind=”line”)
  • Tested in python 3.8.12, pandas 1.3.4, matplotlib 3.4.3, seaborn 0.11.2
JavaScript

enter image description here

Alternatives

JavaScript
  • Plot the dataframes directly, without seaborn
JavaScript
Advertisement