【matplotlib 实战】--饼图】的更多相关文章

import matplotlib.pyplot as pltx = [4, 9, 21, 55, 30, 18]labels = ['math', 'history', 'chemistry', 'physics', 'biology','Enrlish']explode = [0, 0.01, 0.01, 0.02, 0.03, 0]plt.pie(x, labels=labels, explode=explode,shadow=True,autopct='%1.1f%%',startang…
我在网上随便找了一组数据,用它来学习画图.大家可以直接把下面的数据复制到excel里,然后用pandas的read_excel命令读取.或者直接在脚本里创建该数据. 饼图: ax.pie(x,labels=...,explode=...) 代码如下: import numpy as np import matplotlib from matplotlib import pyplot as plt matplotlib.rcParams['font.sans-serif']='Microsoft…
原文:https://www.cnblogs.com/ws0751/p/8361330.html https://www.cnblogs.com/ws0751/p/8313017.html---matplotlib常用操作2 https://www.cnblogs.com/ws0751/p/8312980.html---matplotlib 常用操作 https://blog.csdn.net/u014453898/article/details/73395522----python3 的 ma…
plt.imshow(face_image.mean(axis=2),cmap='gray') 图片灰度处理¶   size = (m,n,3) 图片的一般形式就是这样的 rgb 0-255 jpg图片 166,255,89 0.0-1.0 png图片 0.1,0.2,0.6 灰度处理以后 rgb---->gray 166,255,89 ---> 190 0.1,0.2,0.6 -- > 0.4 size = (m,n) import scipy.misc as misc import…
import matplotlib.pyplot as plt import numpy as np import matplotlib import sys 1.主体函数 #饼图 def die(labels,sizes,s=0): figure() #突出最大部分 explode =np.zeros(len(sizes)) explode[np.argmax(sizes)]=0.1 explode=tuple(explode) plt.pie(sizes,explode=explode,la…
有个瑕疵,某一块儿比例过小时,文字会重叠. 1 def pizza(data,labs,title): 2 import matplotlib 3 import matplotlib.pyplot as plt 4 cols=[col for col in matplotlib.colors.TABLEAU_COLORS][:len(data)] 5 plt.pie(data,labels=labs,colors=cols,startangle=90, 6 textprops={'fontsiz…
import numpy as np import matplotlib.pyplot as plt def main(): #scatter fig = plt.figure() ax = fig.add_subplot(3,3,1) n = 128 X = np.random.normal(0,1,n) Y = np.random.normal(0,1,n) T = np.arctan2(Y,X) #plt.axes([0.025,0.025,0.95,0.95]) ax.scatter(X…
import numpy as np def main(): # print("hello") # line import matplotlib.pyplot as plt x = np.linspace(-np.pi, np.pi, 256, endpoint=True) # print(x) c, s = np.cos(x), np.sin(x) plt.figure(1) # 绘制第一个图 plt.plot(x, c, color="blue", linewi…
# 使用matplotlib绘制饼图 import numpy as np import matplotlib.pyplot as plt # 设置全局字体 plt.rcParams['font.sans-serif'] = ['SimHei'] # 解决'-'表现为方块的问题 plt.rcParams['axes.unicode_minus'] = False data = { '南京':(60, '#7199cf'), '上海':(45, '#4fc4aa'), '北京':(120, '#f…
Matplotlib有两种接口,一种是matlab风格接口,一种是面向对象接口.在这里,统一使用面向对象接口.因为面向对象接口可以适应更复杂的场景,在多图之间进行切换将变得非常容易. 首先导入matplotlib:from matplotlib import pyplot as plt.plt是最常用的接口. 一. 创建图像和坐标轴 fig=plt.figure()   ---   创建图像 ax=plt.axes()   ---   创建坐标轴 在matplotlib中,可以把figure看成…