#44 Control axis limits of plot | seaborn





Control the limits of the X and Y axis of your plot using the matplotlib function plt.xlim and plt.ylim.








# library & dataset
import seaborn as sns
df = sns.load_dataset('iris')

# basic scatterplot
sns.lmplot( x="sepal_length", y="sepal_width", data=df, fit_reg=False)

# control x and y limits
sns.plt.ylim(0, 20)
sns.plt.xlim(0, None)


  • Sponsors

  • 1 comment

    • Copy and past the code mentioned above raises the following error “‘module’ object has no attribute ‘plt'”
      I think the correct way to control x and y limits are the following:
      plt.ylim(0, 20)
      plt.xlim(0, None)



    Leave a Reply to Djaber Berrian Cancel reply

    Your email address will not be published.