How to display the value on horizontal bars

Update: there’s a built in method for this now! Scroll down a couple answers to “New in matplotlib 3.4.0”. If you can’t upgrade that far, it doesn’t take much code. Add: for i, v in enumerate(y): ax.text(v + 3, i + .25, str(v), color=”blue”, fontweight=”bold”) result: The y-values v are both the x-location and the … Read more

How to scale Seaborn’s y-axis with a bar plot

Considering your question mentions barplot I thought I would add in a solution for that type of plot also as it differs from the factorplot in @Jules solution. import matplotlib.pyplot as plt import seaborn as sns sns.set(style=”whitegrid”) xs = [“First”, “First”, “Second”, “Second”, “Third”, “Third”] hue = [“Female”, “Male”] * 3 ys = [1988, 301, … Read more

plotting value_counts() in seaborn barplot

In the latest seaborn, you can use the countplot function: seaborn.countplot(x=’reputation’, data=df) To do it with barplot you’d need something like this: seaborn.barplot(x=df.reputation.value_counts().index, y=df.reputation.value_counts()) You can’t pass ‘reputation’ as a column name to x while also passing the counts in y. Passing ‘reputation’ for x will use the values of df.reputation (all of them, not … Read more

How to add group labels for bar charts

Since I could not find a built-in solution for this in matplotlib, I coded my own: #!/usr/bin/env python from matplotlib import pyplot as plt def mk_groups(data): try: newdata = data.items() except: return thisgroup = [] groups = [] for key, value in newdata: newgroups = mk_groups(value) if newgroups is None: thisgroup.append((key, value)) else: thisgroup.append((key, len(newgroups[-1]))) … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)