1 | #Stacked histogram on a log scale |
2 | import matplotlib.pyplot as plt |
3 | import matplotlib as mpl |
4 | #conda install -c anaconda seaborn |
5 | import seaborn as sns |
6 | sns.set_theme(style = "ticks" ) |
7 |
8 | def 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 |
26 | if __name__ = = '__main__' : |
27 | main() |
Recent Comments