question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Adding annotations option (attributes) to barplot and countplot

See original GitHub issue

I propose for adding annotations option (attributes) to barplot and countplot Lets start with an example import pandas as pd import matplotlib.pyplot as plt import seaborn as sns %matplotlib inline

df = sns.load_dataset('tips')

Plotting a simple barplot

splot = sns.barplot(data=df, x = 'sex', y = 'total_bill') default

Annotating bars plt.figure(figsize=(6, 8)) splot = sns.barplot(data=df, x = 'sex', y = 'total_bill', ci = None) for p in splot.patches: splot.annotate(format(p.get_height(), '.2f'), (p.get_x() + p.get_width() / 2., p.get_height()), ha = 'center', va = 'center', xytext = (0, 10), textcoords = 'offset points')

annotated

This seems a simple addition. But, someone requiring to add some more highlights by annotating those bar would require to add some more lines of code.

Instead, adding a single attribute would reduce this efforts and make them more expressive !!!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:9
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

10reactions
alberduriscommented, May 19, 2020

I would really like to see this or something like this added.

The annotation on barplots should be simple.

1reaction
mwaskomcommented, Oct 7, 2018

I won’t be adding this, sorry.

Read more comments on GitHub >

github_iconTop Results From Across the Web

seaborn.countplot — seaborn 0.12.1 documentation - PyData |
Show the counts of observations in each categorical bin using bars. A count plot can be thought of as a histogram across a...
Read more >
How to Make a Seaborn Countplot - Sharp Sight
This tutorial explains how to create a Seaborn countplot. It explains the syntax of sns.countplot and shows clear examples.
Read more >
How to Annotate Bars in Grouped Barplot in Python?
Explanation: In the above code, we have used the 'patches' attribute of the seaborn plot object to iterate over each bar. We have...
Read more >
Seaborn countplot with normalized y axis per group
Pass the count function the name of the variable you would like to count and it will automatically produce a bar plot of...
Read more >
Pandas .values_count() & .plot() | Python Analysis Tutorial
Bar charts are a visual way of presenting grouped data for comparison. You can visualize the counts of page visits with a bar...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found