54321

import matplotlib.pyplot as plt

 

labels = ['Class 1', 'Class 2', 'Class 3']

 

sizes=[30.521, 40.3, 50.536]

 

explode =[0.1, 0, 0]

 

colors = ['r','g','b]

 

plt.pie(sizes, explode = explode, labels = labels, colors= colors,autopct =%4.2f%%, shadow = False, startangle = 98)plt.show()

import matplotlib. pyplot as plt

 

import numpy as np

 

mu=100

 

sigma=20

 

#设置均#用于将x中的点分布在m 旁边,以mu为中x=mu+sigma*np. random. randn(20000)t bins 设置分组的个数100(显示有!p1t.hist(x, bins=100, color= green plt. show)

#条形图(bar)

 

import matplotlib.pyplot as plt

 

import numpy as np

 

y=[20, 10,30, 25, 15, 34, 22,11]x=np.arange(8) #0---7 plt. show()

 

plt. bar(x,height=y, color=' green',width=0.5)

 

import matplotlib.pyplot as plt

 

x= ['a',b,

 

y=[80,100,

 

p1 = plt.bar(x, height =y, width = 0.5)

 

plt.show()

import matplotlib.pyplot as plt

 

country = ['USA', 'China','Japan',

 

'Germany'GDP =[209328, 147228, 50487, 38030, 27110]plt.barh(country

 

GDP)

 

from matplotlib impont pyplot as plt

 

import numpy as np

 

a=np.array([1,2,3,4,5,12,13,14,15,19])plt.hist(a, bins= [0,5,10,15,201)plt.title("histogram")

 

plt.show()

 

# -*- coding:utf-8 一*一

 

import numpy as np

 

import matplotlib. pyplot as plt

 

plt.figure(1)

 

# 创建图表1

 

plt. figure(2)

 

# 创建图表2

 

ax1 = plt. subplot (211)# 在图表2中ax2 = plt. subplot(212)# 在图表2中x= np.linspace(0,3, 100)

 

for i in x:

 

plt.figure(1)

 

)# 选择图表1 plt.p1ot (x, np.exp(i*x/3))plt.sca(axl)

 

#选择图表2的子plt.sca(ax2) = 选择图表2的子图

 

plt.plot(x, np.sin(i*x))plt.plot(x, np.cos(i*x))plt.show()

 

#箱形图

 

import numpy as np

 

import matplotlib. pyplot as plt

 

np.random. seed(100)

 

data = np. random, normal(size = (1000, ), loc = 0, scale= 1)

 

#sym 调整好异常值的点的形状

 

#whis 默认是1.5,

 

通过调整它的竖直来设置异常值显示的数量,# 如果想显示尽可能多的异常值,whis设置很小,否则很大plt.boxplot (data, sym ="o

 

# plt. boxplot (data,

 

,whis = 1.5)

 

plt.show()

 

。whis = 0.01)

 

 

import matplotlib.pyplot as plt

 

import numpy as np

 

numberOfPoints=16

 

theta = np.linspace(0.0, 2*np.pi, numberofPoints)

 

r= 30 *np.random.rand(number0fPoints)

 

elt.polar(theta,r, linewidth =2, c ='g', marker ="o", mfc = "n", ms = 8)

 

plt.show()

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

你可能感兴趣的:(python)