Home > Net >  Seaborn axvspan alterating x-axis
Seaborn axvspan alterating x-axis

Time:01-13

I'm trying to create some scatter plots, with seaborn with a specific area of each plot highlighted in red. However when I add the code for axvspan, it changes the x-axis. This is how the plots look prior to axvspan being applied.

enter image description here

When i apply the line for axvpsan:

fig, (ax0, ax1) = plt.subplots(2,1, figsize=(5,10))

ax0.axvspan("0.4", "0.8", color='red', alpha=0.3, label ='Problem Area')
sns.scatterplot(x='Values_1', y='Values_2', data=df3, color='green', ax=ax0)
sns.scatterplot(x='Values_3', y='Values_4', data=df3, color='green', ax=ax1)
plt.show()

It sends up looking like this:

enter image description here

Ultimately, the red section needs to only cover the data between 0.4 and 0.7, but by altering the x-axis it ends up covering all of it.

Any advice?

CodePudding user response:

The unexpected behavior is resulting from passing the xmin and xmax arguments to enter image description here

  • Related