#Stacked histogram on a log scale
import matplotlib.pyplot as plt
import matplotlib as mpl
#conda install -c anaconda seaborn
import seaborn as sns
sns.set_theme(style="ticks")

def main():
    diamonds = sns.load_dataset("diamonds")
    f, ax = plt.subplots(figsize=(7, 5))
    sns.despine(f)
    sns.histplot(
        diamonds,
        x="price", hue="cut",
        multiple="stack",
        palette="light:m_r",
        edgecolor=".3",
        linewidth=.5,
        log_scale=True,
        )
    ax.xaxis.set_major_formatter(mpl.ticker.ScalarFormatter())
    ax.set_xticks([500, 1000, 2000, 5000, 10000])
    plt.savefig("ex377.png", dpi=100)
    plt.show()

if __name__ == '__main__':
    main()

Discover more from Tips and Hints for Aerospace Engineers

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

Continue reading