plt.style.use

print(plt.style.available) # 打印样式列表
['bmh', 'classic', 'dark_background', 'fast', 
'fivethirtyeight', 'ggplot', 'grayscale', 'seaborn-bright', 
'seaborn-colorblind', 'seaborn-dark-palette', 'seaborn-dark', 'seaborn-darkgrid',
 'seaborn-deep', 'seaborn-muted', 'seaborn-notebook', 'seaborn-paper', 
'seaborn-pastel', 'seaborn-poster', 'seaborn-talk', 'seaborn-ticks',
 'seaborn-white', 'seaborn-whitegrid', 'seaborn', 'Solarize_Light2', 
'tableau-colorblind10', '_classic_test']

 

plt.style.use('bmh')

plt.style.use('bmh')

# 正常显示中文字体
plt.rcParams['font.sans-serif']=['Microsoft YaHei']

# 生成一张12*4的图
fig = plt.figure(figsize=(12,4))

# 生成第一个子图在1行2列第一列位置
ax1 = fig.add_subplot(121)

# 生成第二子图在1行2列第二列位置
ax2 = fig.add_subplot(122)

# 柱状图数据
x1 = [0.3, 1.7, 4, 6, 7]
y1 = [5, 20, 15, 25, 10]

# 折线图数据
x2 = np.arange(0,10)
y2 = [25,2,12,30,20,40,50,30,40,15]

# 第一个子图绘图和设置
ax1.bar(x1,y1)
ax1.set(xlabel='横坐标',ylabel='纵坐标',title='我在第一列位置')

# 第二个子图绘图和设置
ax2.plot(x2,y2)
ax2.set(xlabel='横坐标',ylabel='纵坐标',title='我在第二列位置')

plt.show()

bmh

plt.style.use('classic')

plt.style.use('classic')

# 正常显示中文字体
plt.rcParams['font.sans-serif']=['Microsoft YaHei']

# 生成一张12*4的图
fig = plt.figure(figsize=(12,4))

# 生成第一个子图在1行2列第一列位置
ax1 = fig.add_subplot(121)

# 生成第二子图在1行2列第二列位置
ax2 = fig.add_subplot(122)

# 柱状图数据
x1 = [0.3, 1.7, 4, 6, 7]
y1 = [5, 20, 15, 25, 10]

# 折线图数据
x2 = np.arange(0,10)
y2 = [25,2,12,30,20,40,50,30,40,15]

# 第一个子图绘图和设置
ax1.bar(x1,y1)
ax1.set(xlabel='横坐标',ylabel='纵坐标',title='我在第一列位置')

# 第二个子图绘图和设置
ax2.plot(x2,y2)
ax2.set(xlabel='横坐标',ylabel='纵坐标',title='我在第二列位置')

plt.show()

classic

plt.style.use('dark_background')

plt.style.use('dark_background')

# 正常显示中文字体
plt.rcParams['font.sans-serif']=['Microsoft YaHei']

# 生成一张12*4的图
fig = plt.figure(figsize=(12,4))

# 生成第一个子图在1行2列第一列位置
ax1 = fig.add_subplot(121)

# 生成第二子图在1行2列第二列位置
ax2 = fig.add_subplot(122)

# 柱状图数据
x1 = [0.3, 1.7, 4, 6, 7]
y1 = [5, 20, 15, 25, 10]

# 折线图数据
x2 = np.arange(0,10)
y2 = [25,2,12,30,20,40,50,30,40,15]

# 第一个子图绘图和设置
ax1.bar(x1,y1)
ax1.set(xlabel='横坐标',ylabel='纵坐标',title='我在第一列位置')

# 第二个子图绘图和设置
ax2.plot(x2,y2)
ax2.set(xlabel='横坐标',ylabel='纵坐标',title='我在第二列位置')

plt.show()

dark_background

plt.style.use('fast')

plt.style.use('fast')

# 正常显示中文字体
plt.rcParams['font.sans-serif']=['Microsoft YaHei']

# 生成一张12*4的图
fig = plt.figure(figsize=(12,4))

# 生成第一个子图在1行2列第一列位置
ax1 = fig.add_subplot(121)

# 生成第二子图在1行2列第二列位置
ax2 = fig.add_subplot(122)

# 柱状图数据
x1 = [0.3, 1.7, 4, 6, 7]
y1 = [5, 20, 15, 25, 10]

# 折线图数据
x2 = np.arange(0,10)
y2 = [25,2,12,30,20,40,50,30,40,15]

# 第一个子图绘图和设置
ax1.bar(x1,y1)
ax1.set(xlabel='横坐标',ylabel='纵坐标',title='我在第一列位置')

# 第二个子图绘图和设置
ax2.plot(x2,y2)
ax2.set(xlabel='横坐标',ylabel='纵坐标',title='我在第二列位置')

plt.show()

fast

plt.style.use('fivethirtyeight')

plt.style.use('fivethirtyeight')

# 正常显示中文字体
plt.rcParams['font.sans-serif']=['Microsoft YaHei']

# 生成一张12*4的图
fig = plt.figure(figsize=(12,4))

# 生成第一个子图在1行2列第一列位置
ax1 = fig.add_subplot(121)

# 生成第二子图在1行2列第二列位置
ax2 = fig.add_subplot(122)

# 柱状图数据
x1 = [0.3, 1.7, 4, 6, 7]
y1 = [5, 20, 15, 25, 10]

# 折线图数据
x2 = np.arange(0,10)
y2 = [25,2,12,30,20,40,50,30,40,15]

# 第一个子图绘图和设置
ax1.bar(x1,y1)
ax1.set(xlabel='横坐标',ylabel='纵坐标',title='我在第一列位置')

# 第二个子图绘图和设置
ax2.plot(x2,y2)
ax2.set(xlabel='横坐标',ylabel='纵坐标',title='我在第二列位置')

plt.show()

fivethirtyeight

plt.style.use('ggplot')

plt.style.use('ggplot')

# 正常显示中文字体
plt.rcParams['font.sans-serif']=['Microsoft YaHei']

# 生成一张12*4的图
fig = plt.figure(figsize=(12,4))

# 生成第一个子图在1行2列第一列位置
ax1 = fig.add_subplot(121)

# 生成第二子图在1行2列第二列位置
ax2 = fig.add_subplot(122)

# 柱状图数据
x1 = [0.3, 1.7, 4, 6, 7]
y1 = [5, 20, 15, 25, 10]

# 折线图数据
x2 = np.arange(0,10)
y2 = [25,2,12,30,20,40,50,30,40,15]

# 第一个子图绘图和设置
ax1.bar(x1,y1)
ax1.set(xlabel='横坐标',ylabel='纵坐标',title='我在第一列位置')

# 第二个子图绘图和设置
ax2.plot(x2,y2)
ax2.set(xlabel='横坐标',ylabel='纵坐标',title='我在第二列位置')

plt.show()

ggplot

plt.style.use('grayscale')

plt.style.use('grayscale')

# 正常显示中文字体
plt.rcParams['font.sans-serif']=['Microsoft YaHei']

# 生成一张12*4的图
fig = plt.figure(figsize=(12,4))

# 生成第一个子图在1行2列第一列位置
ax1 = fig.add_subplot(121)

# 生成第二子图在1行2列第二列位置
ax2 = fig.add_subplot(122)

# 柱状图数据
x1 = [0.3, 1.7, 4, 6, 7]
y1 = [5, 20, 15, 25, 10]

# 折线图数据
x2 = np.arange(0,10)
y2 = [25,2,12,30,20,40,50,30,40,15]

# 第一个子图绘图和设置
ax1.bar(x1,y1)
ax1.set(xlabel='横坐标',ylabel='纵坐标',title='我在第一列位置')

# 第二个子图绘图和设置
ax2.plot(x2,y2)
ax2.set(xlabel='横坐标',ylabel='纵坐标',title='我在第二列位置')

plt.show()

grayscale

plt.style.use('seaborn-bright')

plt.style.use('seaborn-bright')

# 正常显示中文字体
plt.rcParams['font.sans-serif']=['Microsoft YaHei']

# 生成一张12*4的图
fig = plt.figure(figsize=(12,4))

# 生成第一个子图在1行2列第一列位置
ax1 = fig.add_subplot(121)

# 生成第二子图在1行2列第二列位置
ax2 = fig.add_subplot(122)

# 柱状图数据
x1 = [0.3, 1.7, 4, 6, 7]
y1 = [5, 20, 15, 25, 10]

# 折线图数据
x2 = np.arange(0,10)
y2 = [25,2,12,30,20,40,50,30,40,15]

# 第一个子图绘图和设置
ax1.bar(x1,y1)
ax1.set(xlabel='横坐标',ylabel='纵坐标',title='我在第一列位置')

# 第二个子图绘图和设置
ax2.plot(x2,y2)
ax2.set(xlabel='横坐标',ylabel='纵坐标',title='我在第二列位置')

plt.show()

seaborn-bright

plt.style.use('seaborn-colorblind')

plt.style.use('seaborn-colorblind')

# 正常显示中文字体
plt.rcParams['font.sans-serif']=['Microsoft YaHei']

# 生成一张12*4的图
fig = plt.figure(figsize=(12,4))

# 生成第一个子图在1行2列第一列位置
ax1 = fig.add_subplot(121)

# 生成第二子图在1行2列第二列位置
ax2 = fig.add_subplot(122)

# 柱状图数据
x1 = [0.3, 1.7, 4, 6, 7]
y1 = [5, 20, 15, 25, 10]

# 折线图数据
x2 = np.arange(0,10)
y2 = [25,2,12,30,20,40,50,30,40,15]

# 第一个子图绘图和设置
ax1.bar(x1,y1)
ax1.set(xlabel='横坐标',ylabel='纵坐标',title='我在第一列位置')

# 第二个子图绘图和设置
ax2.plot(x2,y2)
ax2.set(xlabel='横坐标',ylabel='纵坐标',title='我在第二列位置')

plt.show()

seaborn-colorblind

plt.style.use('seaborn-dark-palette')

plt.style.use('seaborn-dark-palette')

# 正常显示中文字体
plt.rcParams['font.sans-serif']=['Microsoft YaHei']

# 生成一张12*4的图
fig = plt.figure(figsize=(12,4))

# 生成第一个子图在1行2列第一列位置
ax1 = fig.add_subplot(121)

# 生成第二子图在1行2列第二列位置
ax2 = fig.add_subplot(122)

# 柱状图数据
x1 = [0.3, 1.7, 4, 6, 7]
y1 = [5, 20, 15, 25, 10]

# 折线图数据
x2 = np.arange(0,10)
y2 = [25,2,12,30,20,40,50,30,40,15]

# 第一个子图绘图和设置
ax1.bar(x1,y1)
ax1.set(xlabel='横坐标',ylabel='纵坐标',title='我在第一列位置')

# 第二个子图绘图和设置
ax2.plot(x2,y2)
ax2.set(xlabel='横坐标',ylabel='纵坐标',title='我在第二列位置')

plt.show()

seaborn-dark-palette

plt.style.use('seaborn-dark')

plt.style.use('seaborn-dark')

# 正常显示中文字体
plt.rcParams['font.sans-serif']=['Microsoft YaHei']

# 生成一张12*4的图
fig = plt.figure(figsize=(12,4))

# 生成第一个子图在1行2列第一列位置
ax1 = fig.add_subplot(121)

# 生成第二子图在1行2列第二列位置
ax2 = fig.add_subplot(122)

# 柱状图数据
x1 = [0.3, 1.7, 4, 6, 7]
y1 = [5, 20, 15, 25, 10]

# 折线图数据
x2 = np.arange(0,10)
y2 = [25,2,12,30,20,40,50,30,40,15]

# 第一个子图绘图和设置
ax1.bar(x1,y1)
ax1.set(xlabel='横坐标',ylabel='纵坐标',title='我在第一列位置')

# 第二个子图绘图和设置
ax2.plot(x2,y2)
ax2.set(xlabel='横坐标',ylabel='纵坐标',title='我在第二列位置')

plt.show()

seaborn-dark

plt.style.use('seaborn-darkgrid')

plt.style.use('seaborn-darkgrid')

# 正常显示中文字体
plt.rcParams['font.sans-serif']=['Microsoft YaHei']

# 生成一张12*4的图
fig = plt.figure(figsize=(12,4))

# 生成第一个子图在1行2列第一列位置
ax1 = fig.add_subplot(121)

# 生成第二子图在1行2列第二列位置
ax2 = fig.add_subplot(122)

# 柱状图数据
x1 = [0.3, 1.7, 4, 6, 7]
y1 = [5, 20, 15, 25, 10]

# 折线图数据
x2 = np.arange(0,10)
y2 = [25,2,12,30,20,40,50,30,40,15]

# 第一个子图绘图和设置
ax1.bar(x1,y1)
ax1.set(xlabel='横坐标',ylabel='纵坐标',title='我在第一列位置')

# 第二个子图绘图和设置
ax2.plot(x2,y2)
ax2.set(xlabel='横坐标',ylabel='纵坐标',title='我在第二列位置')

plt.show()

seaborn-darkgrid

plt.style.use('seaborn-deep')

plt.style.use('seaborn-deep')

# 正常显示中文字体
plt.rcParams['font.sans-serif']=['Microsoft YaHei']

# 生成一张12*4的图
fig = plt.figure(figsize=(12,4))

# 生成第一个子图在1行2列第一列位置
ax1 = fig.add_subplot(121)

# 生成第二子图在1行2列第二列位置
ax2 = fig.add_subplot(122)

# 柱状图数据
x1 = [0.3, 1.7, 4, 6, 7]
y1 = [5, 20, 15, 25, 10]

# 折线图数据
x2 = np.arange(0,10)
y2 = [25,2,12,30,20,40,50,30,40,15]

# 第一个子图绘图和设置
ax1.bar(x1,y1)
ax1.set(xlabel='横坐标',ylabel='纵坐标',title='我在第一列位置')

# 第二个子图绘图和设置
ax2.plot(x2,y2)
ax2.set(xlabel='横坐标',ylabel='纵坐标',title='我在第二列位置')

plt.show()

seaborn-deep

plt.style.use('seaborn-muted')

plt.style.use('seaborn-muted')

# 正常显示中文字体
plt.rcParams['font.sans-serif']=['Microsoft YaHei']

# 生成一张12*4的图
fig = plt.figure(figsize=(12,4))

# 生成第一个子图在1行2列第一列位置
ax1 = fig.add_subplot(121)

# 生成第二子图在1行2列第二列位置
ax2 = fig.add_subplot(122)

# 柱状图数据
x1 = [0.3, 1.7, 4, 6, 7]
y1 = [5, 20, 15, 25, 10]

# 折线图数据
x2 = np.arange(0,10)
y2 = [25,2,12,30,20,40,50,30,40,15]

# 第一个子图绘图和设置
ax1.bar(x1,y1)
ax1.set(xlabel='横坐标',ylabel='纵坐标',title='我在第一列位置')

# 第二个子图绘图和设置
ax2.plot(x2,y2)
ax2.set(xlabel='横坐标',ylabel='纵坐标',title='我在第二列位置')

plt.show()

seaborn-muted

plt.style.use('seaborn-notebook')

plt.style.use('seaborn-notebook')

# 正常显示中文字体
plt.rcParams['font.sans-serif']=['Microsoft YaHei']

# 生成一张12*4的图
fig = plt.figure(figsize=(12,4))

# 生成第一个子图在1行2列第一列位置
ax1 = fig.add_subplot(121)

# 生成第二子图在1行2列第二列位置
ax2 = fig.add_subplot(122)

# 柱状图数据
x1 = [0.3, 1.7, 4, 6, 7]
y1 = [5, 20, 15, 25, 10]

# 折线图数据
x2 = np.arange(0,10)
y2 = [25,2,12,30,20,40,50,30,40,15]

# 第一个子图绘图和设置
ax1.bar(x1,y1)
ax1.set(xlabel='横坐标',ylabel='纵坐标',title='我在第一列位置')

# 第二个子图绘图和设置
ax2.plot(x2,y2)
ax2.set(xlabel='横坐标',ylabel='纵坐标',title='我在第二列位置')

plt.show()

seaborn-notebook

plt.style.use('seaborn-paper')

plt.style.use('seaborn-paper')

# 正常显示中文字体
plt.rcParams['font.sans-serif']=['Microsoft YaHei']

# 生成一张12*4的图
fig = plt.figure(figsize=(12,4))

# 生成第一个子图在1行2列第一列位置
ax1 = fig.add_subplot(121)

# 生成第二子图在1行2列第二列位置
ax2 = fig.add_subplot(122)

# 柱状图数据
x1 = [0.3, 1.7, 4, 6, 7]
y1 = [5, 20, 15, 25, 10]

# 折线图数据
x2 = np.arange(0,10)
y2 = [25,2,12,30,20,40,50,30,40,15]

# 第一个子图绘图和设置
ax1.bar(x1,y1)
ax1.set(xlabel='横坐标',ylabel='纵坐标',title='我在第一列位置')

# 第二个子图绘图和设置
ax2.plot(x2,y2)
ax2.set(xlabel='横坐标',ylabel='纵坐标',title='我在第二列位置')

plt.show()

seaborn-paper

plt.style.use('seaborn-pastel')

plt.style.use('seaborn-pastel')

# 正常显示中文字体
plt.rcParams['font.sans-serif']=['Microsoft YaHei']

# 生成一张12*4的图
fig = plt.figure(figsize=(12,4))

# 生成第一个子图在1行2列第一列位置
ax1 = fig.add_subplot(121)

# 生成第二子图在1行2列第二列位置
ax2 = fig.add_subplot(122)

# 柱状图数据
x1 = [0.3, 1.7, 4, 6, 7]
y1 = [5, 20, 15, 25, 10]

# 折线图数据
x2 = np.arange(0,10)
y2 = [25,2,12,30,20,40,50,30,40,15]

# 第一个子图绘图和设置
ax1.bar(x1,y1)
ax1.set(xlabel='横坐标',ylabel='纵坐标',title='我在第一列位置')

# 第二个子图绘图和设置
ax2.plot(x2,y2)
ax2.set(xlabel='横坐标',ylabel='纵坐标',title='我在第二列位置')

plt.show()

seaborn-pastel

plt.style.use('seaborn-poster')

plt.style.use('seaborn-poster')

# 正常显示中文字体
plt.rcParams['font.sans-serif']=['Microsoft YaHei']

# 生成一张12*4的图
fig = plt.figure(figsize=(12,4))

# 生成第一个子图在1行2列第一列位置
ax1 = fig.add_subplot(121)

# 生成第二子图在1行2列第二列位置
ax2 = fig.add_subplot(122)

# 柱状图数据
x1 = [0.3, 1.7, 4, 6, 7]
y1 = [5, 20, 15, 25, 10]

# 折线图数据
x2 = np.arange(0,10)
y2 = [25,2,12,30,20,40,50,30,40,15]

# 第一个子图绘图和设置
ax1.bar(x1,y1)
ax1.set(xlabel='横坐标',ylabel='纵坐标',title='我在第一列位置')

# 第二个子图绘图和设置
ax2.plot(x2,y2)
ax2.set(xlabel='横坐标',ylabel='纵坐标',title='我在第二列位置')

plt.show()

seaborn-poster

plt.style.use('seaborn-talk')

plt.style.use('seaborn-talk')

# 正常显示中文字体
plt.rcParams['font.sans-serif']=['Microsoft YaHei']

# 生成一张12*4的图
fig = plt.figure(figsize=(12,4))

# 生成第一个子图在1行2列第一列位置
ax1 = fig.add_subplot(121)

# 生成第二子图在1行2列第二列位置
ax2 = fig.add_subplot(122)

# 柱状图数据
x1 = [0.3, 1.7, 4, 6, 7]
y1 = [5, 20, 15, 25, 10]

# 折线图数据
x2 = np.arange(0,10)
y2 = [25,2,12,30,20,40,50,30,40,15]

# 第一个子图绘图和设置
ax1.bar(x1,y1)
ax1.set(xlabel='横坐标',ylabel='纵坐标',title='我在第一列位置')

# 第二个子图绘图和设置
ax2.plot(x2,y2)
ax2.set(xlabel='横坐标',ylabel='纵坐标',title='我在第二列位置')

plt.show()

seaborn-talk

plt.style.use('seaborn-ticks')

plt.style.use('seaborn-ticks')

# 正常显示中文字体
plt.rcParams['font.sans-serif']=['Microsoft YaHei']

# 生成一张12*4的图
fig = plt.figure(figsize=(12,4))

# 生成第一个子图在1行2列第一列位置
ax1 = fig.add_subplot(121)

# 生成第二子图在1行2列第二列位置
ax2 = fig.add_subplot(122)

# 柱状图数据
x1 = [0.3, 1.7, 4, 6, 7]
y1 = [5, 20, 15, 25, 10]

# 折线图数据
x2 = np.arange(0,10)
y2 = [25,2,12,30,20,40,50,30,40,15]

# 第一个子图绘图和设置
ax1.bar(x1,y1)
ax1.set(xlabel='横坐标',ylabel='纵坐标',title='我在第一列位置')

# 第二个子图绘图和设置
ax2.plot(x2,y2)
ax2.set(xlabel='横坐标',ylabel='纵坐标',title='我在第二列位置')

plt.show()

seaborn-ticks

plt.style.use('seaborn-white')

plt.style.use('seaborn-white')

# 正常显示中文字体
plt.rcParams['font.sans-serif']=['Microsoft YaHei']

# 生成一张12*4的图
fig = plt.figure(figsize=(12,4))

# 生成第一个子图在1行2列第一列位置
ax1 = fig.add_subplot(121)

# 生成第二子图在1行2列第二列位置
ax2 = fig.add_subplot(122)

# 柱状图数据
x1 = [0.3, 1.7, 4, 6, 7]
y1 = [5, 20, 15, 25, 10]

# 折线图数据
x2 = np.arange(0,10)
y2 = [25,2,12,30,20,40,50,30,40,15]

# 第一个子图绘图和设置
ax1.bar(x1,y1)
ax1.set(xlabel='横坐标',ylabel='纵坐标',title='我在第一列位置')

# 第二个子图绘图和设置
ax2.plot(x2,y2)
ax2.set(xlabel='横坐标',ylabel='纵坐标',title='我在第二列位置')

plt.show()

seaborn-white

plt.style.use('seaborn-whitegrid')

plt.style.use('seaborn-whitegrid')

# 正常显示中文字体
plt.rcParams['font.sans-serif']=['Microsoft YaHei']

# 生成一张12*4的图
fig = plt.figure(figsize=(12,4))

# 生成第一个子图在1行2列第一列位置
ax1 = fig.add_subplot(121)

# 生成第二子图在1行2列第二列位置
ax2 = fig.add_subplot(122)

# 柱状图数据
x1 = [0.3, 1.7, 4, 6, 7]
y1 = [5, 20, 15, 25, 10]

# 折线图数据
x2 = np.arange(0,10)
y2 = [25,2,12,30,20,40,50,30,40,15]

# 第一个子图绘图和设置
ax1.bar(x1,y1)
ax1.set(xlabel='横坐标',ylabel='纵坐标',title='我在第一列位置')

# 第二个子图绘图和设置
ax2.plot(x2,y2)
ax2.set(xlabel='横坐标',ylabel='纵坐标',title='我在第二列位置')

plt.show()

seaborn-whitegrid

plt.style.use('seaborn')

plt.style.use('seaborn')

# 正常显示中文字体
plt.rcParams['font.sans-serif']=['Microsoft YaHei']

# 生成一张12*4的图
fig = plt.figure(figsize=(12,4))

# 生成第一个子图在1行2列第一列位置
ax1 = fig.add_subplot(121)

# 生成第二子图在1行2列第二列位置
ax2 = fig.add_subplot(122)

# 柱状图数据
x1 = [0.3, 1.7, 4, 6, 7]
y1 = [5, 20, 15, 25, 10]

# 折线图数据
x2 = np.arange(0,10)
y2 = [25,2,12,30,20,40,50,30,40,15]

# 第一个子图绘图和设置
ax1.bar(x1,y1)
ax1.set(xlabel='横坐标',ylabel='纵坐标',title='我在第一列位置')

# 第二个子图绘图和设置
ax2.plot(x2,y2)
ax2.set(xlabel='横坐标',ylabel='纵坐标',title='我在第二列位置')

plt.show()

seaborn

plt.style.use('Solarize_Light2')

plt.style.use('Solarize_Light2')

# 正常显示中文字体
plt.rcParams['font.sans-serif']=['Microsoft YaHei']

# 生成一张12*4的图
fig = plt.figure(figsize=(12,4))

# 生成第一个子图在1行2列第一列位置
ax1 = fig.add_subplot(121)

# 生成第二子图在1行2列第二列位置
ax2 = fig.add_subplot(122)

# 柱状图数据
x1 = [0.3, 1.7, 4, 6, 7]
y1 = [5, 20, 15, 25, 10]

# 折线图数据
x2 = np.arange(0,10)
y2 = [25,2,12,30,20,40,50,30,40,15]

# 第一个子图绘图和设置
ax1.bar(x1,y1)
ax1.set(xlabel='横坐标',ylabel='纵坐标',title='我在第一列位置')

# 第二个子图绘图和设置
ax2.plot(x2,y2)
ax2.set(xlabel='横坐标',ylabel='纵坐标',title='我在第二列位置')

plt.show()

Solarize_Light2

plt.style.use('tableau-colorblind10')

plt.style.use('tableau-colorblind10')

# 正常显示中文字体
plt.rcParams['font.sans-serif']=['Microsoft YaHei']

# 生成一张12*4的图
fig = plt.figure(figsize=(12,4))

# 生成第一个子图在1行2列第一列位置
ax1 = fig.add_subplot(121)

# 生成第二子图在1行2列第二列位置
ax2 = fig.add_subplot(122)

# 柱状图数据
x1 = [0.3, 1.7, 4, 6, 7]
y1 = [5, 20, 15, 25, 10]

# 折线图数据
x2 = np.arange(0,10)
y2 = [25,2,12,30,20,40,50,30,40,15]

# 第一个子图绘图和设置
ax1.bar(x1,y1)
ax1.set(xlabel='横坐标',ylabel='纵坐标',title='我在第一列位置')

# 第二个子图绘图和设置
ax2.plot(x2,y2)
ax2.set(xlabel='横坐标',ylabel='纵坐标',title='我在第二列位置')

plt.show()

tableau-colorblind10

plt.style.use('_classic_test')

plt.style.use('_classic_test')

# 正常显示中文字体
plt.rcParams['font.sans-serif']=['Microsoft YaHei']

# 生成一张12*4的图
fig = plt.figure(figsize=(12,4))

# 生成第一个子图在1行2列第一列位置
ax1 = fig.add_subplot(121)

# 生成第二子图在1行2列第二列位置
ax2 = fig.add_subplot(122)

# 柱状图数据
x1 = [0.3, 1.7, 4, 6, 7]
y1 = [5, 20, 15, 25, 10]

# 折线图数据
x2 = np.arange(0,10)
y2 = [25,2,12,30,20,40,50,30,40,15]

# 第一个子图绘图和设置
ax1.bar(x1,y1)
ax1.set(xlabel='横坐标',ylabel='纵坐标',title='我在第一列位置')

# 第二个子图绘图和设置
ax2.plot(x2,y2)
ax2.set(xlabel='横坐标',ylabel='纵坐标',title='我在第二列位置')

plt.show()

_classic_test

 

 

 

 

  • 40
    点赞
  • 269
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
数据分析案例--红酒数据集分析 介绍: 这篇⽂章主分析了红酒的通⽤数据集,这个数据集⼀共有1600个样本,11个红酒的理化性质,以及红酒的品质(评分从0到10)。这⾥主 要⽤python进⾏分析,主要内容分为:单变量,双变量,和多变量分析。 注意:我们在分析数据之前,⼀定要先了解数据。 1.导⼊python中相关的库 import numpy as np import pandas as pd import matplotlib.pyplot as plt %matplotlib inline import seaborn as sns # 颜⾊ color = sns.color_palette() # 数据print精度 pd.set_option('precision',3) 2.读取数据 注意:读取数据之前应该先看⼀下数据⽂件的格式,再进⾏读取 我们看到这个数据使⽤';'进⾏分隔的,所以我们⽤';'进⾏分隔读取 pandas.read_csv(filepath, sep=', ' ,header='infer', names=None) filepath:⽂本⽂件路径;sep:分隔符;header默认使⽤第⼀⾏作为列名,如果header=None则pandas为其分配默认的列名;也可使⽤ names传⼊列表指定列名 data=pd.read_csv(r'H:\阿⾥云\红酒数据集分析\winequality-red.csv',sep=';') data.head() 先读取数据的前五⾏ 然后我们也可以把这个整理好的数据,再另存为csv⽂件或者excel⽂件 data.to_csv(r'H:\阿⾥云\红酒数据集分析\winequality-red2.csv') data.to_excel(r'H:\阿⾥云\红酒数据集分析\winequality-red3.xlsx') winequality-red2.csv如图: winequality-red3.xlsx如图: 这样呢,我们就保存好了⽂件。这也是整理⽂件的⼀种⽅式 3.查看数据集的数据类型和空值情况等 可以看出没有缺失值,数据整齐 4.单变量分析 #简单的数据统计 data.describe() 5.绘图 # 获取所有的⾃带样式 plt.style.available # 使⽤⾃带的样式进⾏美化 plt.style.use('ggplot') #获取所有列索引,并且转化成列表格式 colnm = data.columns.tolist() fig = plt.figure(figsize = (10, 6)) for i in range(12): #绘制成2⾏6列的图 plt.subplot(2,6,i+1) #绘制箱型图 #Y轴标题 sns.boxplot(data[colnm[i]], orient="v", width = 0.5, color = color[0]) plt.ylabel(colnm[i],fontsize = 12) #plt.subplots_adjust(left=0.2, wspace=0.8, top=0.9) plt.tight_layout() print('\nFigure 1: Univariate Boxplots') colnm = data.columns.tolist() plt.figure(figsize = (10, 8)) for i in range(12): plt.subplot(4,3,i+1) #data.hist绘制直⽅图 data[colnm[i]].hist(bins = 100, color = color[0]) plt.xlabel(colnm[i],fontsize = 12) plt.ylabel('Frequency') plt.tight_layout() print('\nFigure 2: Univariate Histograms') 品质 这个数据集的⽬的是研究红酒品质和理化性质之间的关系,品质的评价范围是0-10,这个数据集中的范围是3到8,有82%的红酒品质是5 或6 酸度相关的特征 这个数据集有7个酸度相关的特征:fixed acidity, volatile acidity, citric acid, free sulfur dioxide, total sulfur dioxide, sulphates, pH。前6个特征都与红酒的pH的相关。pH是在对数的尺度,下⾯对前6个特征取对数然后作histogram。另外,pH值主要是与fixed acidity有关fixed acidity⽐volatile acidity和citric acid⾼1到2个数量级(Fi

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值