0

I'm trying to make a plot of mean slope x elevation for a given area, but I'm a bit lost with the sorting of data in plotnine. The dataframe has 3 cols: Elevation (already ordered from low to high), Slope (unordered, must remain as is), DEM (used for grouping). When ploting in seaborn, I can set the sort option and it works fine:

sns.lineplot(data=pd_areas, x="Slope", y="Elevation", hue="DEM", sort=False)

seaborn plot

but with plotnine, the values are sorted and the result is wrong:

(p9.ggplot(pd_areas)
+p9.geom_line(mapping=p9.aes(x='Slope', y='Elevation', color='DEM', group='DEM'))
)

plotnine plot

Sorry for not providing an MVE, but I can't send the DEMs at this moment.

thanks

1 Answers1

0

Use geom_path instead of geom_line.

has2k1
  • 2,095
  • 18
  • 16