0

I have multiple dataframes like this:

Scn 2005 2010 2015 2020 2025 2030
E0W1 0.00 0.00 0.00 0.00 0.00 0.00
E1W1 -0.09 1.32 0.89 -0.65 -0.68 -0.64
E2W1 -10.49 -11.20 -12.45 -11.38 -12.37 -13.63

I am using Seaborn Relplot to create a scatter plot of the dataframe, where x= year and hue/category is the index (first column). Y is the value in the table.

For each plot that I create, I want the line for the x-axis to be at y=0. I have tried a few different things but can't figure out how to set it so the axis is there.

I have attached my code:

scatter= sns.relplot(data=WM_percent_diff.transpose(), kind="scatter")
scatter.set(xlabel="Years",ylabel=variable_name)
nameplot= file_name2.replace("csv","pdf")
plt.savefig(nameplot, dpi=300)

This is what I'm getting: plot with x axis at the bottom

This is what I want: image of quadrent plot with x-axis line at y=0 (except I only want quadrant 1 and 4,X=<0)

Thank you :)

  • Note that `relplot` is a figure level function (a `FacetGrid` with one or more subplots). You can do `for ax in scatter.axes.flat: ax.spines['bottom'].set_position('zero')`. – JohanC Nov 24 '21 at 22:30

0 Answers0