MCPcopy Index your code
hub / github.com/PySimpleGUI/PySimpleGUI / ArtistBoxplot2

Function ArtistBoxplot2

DemoPrograms/Demo_Matplotlib_Browser.py:148–192  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

146 return fig
147
148def ArtistBoxplot2():
149
150 # fake data
151 np.random.seed(937)
152 data = np.random.lognormal(size=(37, 4), mean=1.5, sigma=1.75)
153 labels = list('ABCD')
154 fs = 10 # fontsize
155
156 # demonstrate how to customize the display different elements:
157 boxprops = dict(linestyle='--', linewidth=3, color='darkgoldenrod')
158 flierprops = dict(marker='o', markerfacecolor='green', markersize=12,
159 linestyle='none')
160 medianprops = dict(linestyle='-.', linewidth=2.5, color='firebrick')
161 meanpointprops = dict(marker='D', markeredgecolor='black',
162 markerfacecolor='firebrick')
163 meanlineprops = dict(linestyle='--', linewidth=2.5, color='purple')
164
165 fig, axes = plt.subplots(nrows=2, ncols=3, figsize=(6, 6), sharey=True)
166 axes[0, 0].boxplot(data, boxprops=boxprops)
167 axes[0, 0].set_title('Custom boxprops', fontsize=fs)
168
169 axes[0, 1].boxplot(data, flierprops=flierprops, medianprops=medianprops)
170 axes[0, 1].set_title('Custom medianprops\nand flierprops', fontsize=fs)
171
172 axes[0, 2].boxplot(data, whis='range')
173 axes[0, 2].set_title('whis="range"', fontsize=fs)
174
175 axes[1, 0].boxplot(data, meanprops=meanpointprops, meanline=False,
176 showmeans=True)
177 axes[1, 0].set_title('Custom mean\nas point', fontsize=fs)
178
179 axes[1, 1].boxplot(data, meanprops=meanlineprops, meanline=True,
180 showmeans=True)
181 axes[1, 1].set_title('Custom mean\nas line', fontsize=fs)
182
183 axes[1, 2].boxplot(data, whis=[15, 85])
184 axes[1, 2].set_title('whis=[15, 85]\n#percentiles', fontsize=fs)
185
186 for ax in axes.flatten():
187 ax.set_yscale('log')
188 ax.set_yticklabels([])
189
190 fig.suptitle("I never said they'd be pretty")
191 fig.subplots_adjust(hspace=0.4)
192 return fig
193
194def PyplotScatterWithLegend():
195 import matplotlib.pyplot as plt

Callers

nothing calls this directly

Calls 1

set_titleMethod · 0.80

Tested by

no test coverage detected