0

Writing the follow code:

sns.jointplot(x="horsepower", y="mpg", data=df, kind='scatter', color="black", height=14, hue="origin");

LSL = 20
USL = 30

plt.axhline(y=LSL, color="b", linestyle="--")
plt.axhline(y=USL, color="b", linestyle="--")

# Fill the area between the LSL and USL reference lines with green color
plt.fill_between([df["horsepower"].min(), df["horsepower"].max()], LSL, USL, color="g", alpha=0.1)

plt.show()

I get the output as: plot

The reference lines and green fill are getting placed to the right of the plot.

I tried changing the x range to hardcoded values [0,250] for example and it didn't work.

  • With `g = sns.jointplot(...)`, use `g.ax_joint.axhline(...)` and `g.ax_joint.fill_between(...)`. Or upgrade to the latest seaborn version, which by default will draw on the joint ax. – JohanC Jan 02 '23 at 19:32

0 Answers0