Skip to content

Instantly share code, notes, and snippets.

@pfandzelter
Last active September 2, 2024 14:21
Show Gist options
  • Save pfandzelter/0ae861f0dee1fb4fd1d11344e3f85c9e to your computer and use it in GitHub Desktop.
Save pfandzelter/0ae861f0dee1fb4fd1d11344e3f85c9e to your computer and use it in GitHub Desktop.
Bar Chart With a Broken Y Axis in Python Using Seaborn
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@MeerkatPerson
Copy link

MeerkatPerson commented Aug 3, 2020

Offiziell Most Savage Plot Ive Seen today

@rafmora
Copy link

rafmora commented Mar 7, 2022

I wonder if the "looking break-like" between both graphs is because of the subplot definition "f, (ax1, ax2) = plt.subplots(ncols=1, nrows=2 sharex=True)". Particularly, the common 'y-axis' and the absence of a 'x-axis title" for the upper graphs creates an effect of "break-like"
I hope this insight is beneficial

@pfandzelter
Copy link
Author

@rafmora Yes I think you're exactly right. The "broken" look is exactly what we wanted to achieve to present the data without cutting off outliers or using a logarithmic scale, which can both be misleading

@gcolmenarejo
Copy link

Hi pfandzelter

running your code I get this:
image

I have pandas 1.4.2 and seaborn 0.11.2.

Do you know why the bars are not displaying in the correct scale and inside the y-axis limits?

Thanks a lot
Gonzalo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment