Control Axis Limits of Plot


This post provides a reproducible code to plot a basic scatterplot with seaborn. The example shows how to control x and y axis limits of the plot using matplotlib functions plt.xlim() and plt.ylim().

Basic Scatterplot with Defined Axis Limits

You can control the limits of X and Y axis of your plots using matplotlib function plt.xlim() and plt.ylim(). In this example, lmplot() function of seaborn is used to plot a basic scatterplot with iris dataset. There are 2 arguments in these functions;

  • plt.xlim() : (left, right)
  • plt.ylim() : (buttom, top)
# library & dataset
import seaborn as sns
import matplotlib.pyplot as plt
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
plt.ylim(0, 20)
plt.xlim(0, None)
 
plt.show()

Scatterplot

Heatmap

Correlogram

Bubble

Connected Scatter

2D Density

Contact & Edit

👋 This document is a work by Yan Holtz. Any feedback is highly encouraged. You can fill an issue on Github, drop me a message onTwitter, or send an email pasting yan.holtz.data with gmail.com.

This page is just a jupyter notebook, you can edit it here. Please help me making this website better 🙏!

Violin

Density

Histogram

Boxplot

Ridgeline

Scatterplot

Heatmap

Correlogram

Bubble

Connected Scatter

2D Density

Barplot

Spider / Radar

Wordcloud

Parallel

Lollipop

Circular Barplot

Treemap

Venn Diagram

Donut

Pie Chart

Dendrogram

Circular Packing

Line chart

Area chart

Stacked Area

Streamgraph

Timeseries with python

Timeseries

Map

Choropleth

Hexbin

Cartogram

Connection

Bubble

Chord Diagram

Network

Sankey

Arc Diagram

Edge Bundling

Colors

Interactivity

Animation with python

Animation

Cheat sheets

Caveats

3D