1#Stacked histogram on a log scale
2import matplotlib.pyplot as plt
3import matplotlib as mpl
4#conda install -c anaconda seaborn
5import seaborn as sns
6sns.set_theme(style="ticks")
7 
8def main():
9    diamonds = sns.load_dataset("diamonds")
10    f, ax = plt.subplots(figsize=(7, 5))
11    sns.despine(f)
12    sns.histplot(
13        diamonds,
14        x="price", hue="cut",
15        multiple="stack",
16        palette="light:m_r",
17        edgecolor=".3",
18        linewidth=.5,
19        log_scale=True,
20        )
21    ax.xaxis.set_major_formatter(mpl.ticker.ScalarFormatter())
22    ax.set_xticks([500, 1000, 2000, 5000, 10000])
23    plt.savefig("ex377.png", dpi=100)
24    plt.show()
25 
26if __name__ == '__main__':
27    main()

Discover more from Tips and Hints for Aerospace Engineers

Subscribe now to keep reading and get access to the full archive.

Continue reading