Bar plot with groupby
I think you need add unstack for DataFrame: df.groupby(‘year’).case_status.value_counts().unstack().plot.barh() Also is possible change level: df.groupby(‘year’).case_status.value_counts().unstack(0).plot.barh()
I think you need add unstack for DataFrame: df.groupby(‘year’).case_status.value_counts().unstack().plot.barh() Also is possible change level: df.groupby(‘year’).case_status.value_counts().unstack(0).plot.barh()
There isn’t a clear and quick answer to this at the top of search engine results so I provide simple examples here: .1e = scientific notation with 1 decimal point (standard form) .2f = 2 decimal places .3g = 3 significant figures .4% = percentage with 4 decimal places A more detailed explanation on the … Read more
To ensure the labels are visible, you have to set the parameters xticklabels, yticklabels to True, like so. import seaborn as sns sns.heatmap(dataframe, xticklabels=True, yticklabels=True) Here’s the documentation for the heatmap function.
As part of the update to matplotlib 2.0 the edges on bar plots are turned off by default. However, you may use the rcParam plt.rcParams[“patch.force_edgecolor”] = True to turn the edges on globally. Probably the easiest option is to specifically set the edgecolor when creating a seaborn plot, using the hist_kws argument, ax = sns.distplot(x, … Read more
The answer from here makes fonts larger in seaborn … import pandas as pd, numpy as np, seaborn as sns from matplotlib import pyplot as plt # Generate data df = pd.DataFrame({“Draughts”: np.random.randn(100)}) # Plot using seaborn sns.set(font_scale = 2) b = sns.violinplot(y = “Draughts”, data = df) plt.show()
Have you tried the ci argument? According to the documentation: ci : float or None, optional Size of confidence intervals to draw around estimated values. If None, no bootstrapping will be performed, and error bars will not be drawn. sns.barplot(x=df[‘Time’], y=df[‘Volume_Count’], ax=ax7, ci=None)
If by “6 digit code” you mean a hex code, you can also do: pal = sns.color_palette(…) pal.as_hex()
You get that error because matplotlib and its objects are completely unaware of seaborn functions. Pass your axes objects (i.e., ax1 and ax2) to seaborn.regplot or you can skip defining those and use the col kwarg of seaborn.lmplot With your same imports, pre-defining your axes and using regplot looks like this: # create df x … Read more
you can use the order parameter for this. sns.barplot(x=’Id’, y=”Speed”, data=df, order=result[‘Id’]) Credits to Wayne. See the rest of his code. This link is still working for me. But, for the sake of convenience, I’m pasting the author’s code here. result = df.groupby([“Id”])[‘Speed’].aggregate(np.median).reset_index().sort_values(‘Speed’) sns.barplot(x=’Id’, y=”Speed”, data=df, order=result[‘Id’]) plt.show() df Id Speed 0 1 30 1 … Read more
Adding annotations / text also works in seaborn axes-level plots with the same methods. For seaborn figure-level plots, you must iterate through each axes, which isn’t shown. Bold text can be specified with .text or .annotate matplotlib.pyplot.text Use the weight or fontweight parameter. matplotlib.pyplot.annotate, which uses the same kwargs as .text. Note: If LaTex fonts, … Read more