AttributeError: module ‘seaborn’ has no attribute ‘histplot’

If you have a standard python installation, update with pip: pip install -U seaborn If you are using an Anaconda distribution, at the anaconda prompt (base) environment, or activate the appropriate environment: # update all the packages in the environment conda update –all # or conda update seaborn See Anaconda: Managing Packages

How to make a histogram from a list of strings

Very easy with Pandas. import pandas from collections import Counter a = [‘a’, ‘a’, ‘a’, ‘a’, ‘b’, ‘b’, ‘c’, ‘c’, ‘c’, ‘d’, ‘e’, ‘e’, ‘e’, ‘e’, ‘e’] letter_counts = Counter(a) df = pandas.DataFrame.from_dict(letter_counts, orient=”index”) df.plot(kind=’bar’) Notice that Counter is making a frequency count, so our plot type is ‘bar’ not ‘hist’.

How to format axis tick labels from number to thousands or Millions (125,436 to 125.4K)

IIUC you can format the xticks and set these: In[60]: #generate some psuedo data df = pd.DataFrame({‘num’:[50000, 75000, 100000, 125000], ‘Rent/Sqft’:np.random.randn(4), ‘Region’:list(‘abcd’)}) df Out[60]: num Rent/Sqft Region 0 50000 0.109196 a 1 75000 0.566553 b 2 100000 -0.274064 c 3 125000 -0.636492 d In[61]: import matplotlib.pyplot as plt import matplotlib.ticker as ticker import seaborn as … Read more

Increase tick label font size in seaborn

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()

How to add edge color to a histogram

As part of the update to matplotlib 2.0 the edges on bar plots are turned off by default. However, this behavior can be globally changed with rcParams. plt.rcParams[“patch.force_edgecolor”] = True Alternatively, set the edgecolor / ec parameter in the plot call, and potentially increase the linewidth / lw parameter. Tested in python 3.11.4, pandas 2.0.3, … Read more

Seaborn Bar Plot Ordering

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