import matplotlib.pyplot as plt
x = [1,2,3,5,6,8,9,15]
plt.boxplot(x, vert=False)
plt.show()
import matplotlib.pyplot as plt
x = [1,2,3,5,6,8,9,15]
y = [3,5,7,9,5,1,2]
z = [5,1,3,4,7]
plt.boxplot((x, y, z), labels=('x', 'y', 'z'))
plt.show()
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
df = pd.DataFrame({
'a':range(10),
'b':range(12, 22),
'c':np.random.randint(1, 10, 10)
})
df.plot.box(title='Box Plot')
plt.show()
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif'] = 'Microsoft YaHei'
plt.rcParams['axes.unicode_minus'] = False
plt.style.use('ggplot')
x = [1200, 1300, 1400, 500,1500, 1600, 1700, 1800, 1900, 2000, 2100,4000]
plt.boxplot(x=x,
patch_artist=True,
showmeans=True,
boxprops = {'color':'black', 'facecolor':'#9999ff'},
flierprops = {'marker':'o','markerfacecolor':'red','color':'black'},
meanprops = {'marker':'D','markerfacecolor':'indianred'},
medianprops = {'linestyle':'--','color':'orange'})
plt.ylim(0, 5000)
plt.savefig(r'./xxx.png', bbox_inches='tight')
plt.show()