1.plt.plot画线画点 

a = np.array([[1, 2], [3, 4]])
print(a[:, 0])
plt.plot(a[:, 0], a[:, 1])
plt.show()
plt.plot(a[:, 0], a[:, 1],  'o',color='red')
plt.show()#添加风格
plt.plot(x,y,color='red',linewidth=1.0,linestyle='--')
#设置x轴范围
plt.xlim((-1,2))
# 设置y轴范围
plt.ylim((-2, 3))

#标题变为figure3,长宽为8,5
plt.figure(num=3,figsize=(8,5))
a = np.array([[1, 2], [3, 4]])
plt.plot(a[:, 0], a[:, 1])
plt.show()

2.plt.scatter散点图

n=1024
X=np.random.normal(0,1,n)
Y = np.random.normal(0, 1, n)
print(Y)
T=np.arctan2(Y,X) #for color value
#c表示颜色序列
plt.scatter(X,Y,s=75,c=T,alpha=0.5)
#不要坐标刻度
plt.xticks(())
plt.yticks(())
plt.show()

3.生成柱状图

方法1:

"""生成柱状图"""
def write_bar():num_list = [0.42974282, 0.08665644 ,0.39311899 ,0.09048176]name_list=['pig_length','pig_photo_center','disk_length','disk_photo_center']plt.ylabel('feature importance')plt.bar(range(len(num_list)), num_list,tick_label=name_list)# plt.xticks(name_list,rotation = 20)plt.xticks(rotation = 20)plt.show()

方法2:

name_list = ['detected', 'Undetectable']
num_list = [91,134-91]
rects = plt.bar(range(len(num_list)), num_list, color='gr')
# X轴标题
index = [0, 1]
plt.xticks(index, name_list)
plt.ylabel('photos')  # X轴标签
for rect in rects:height = rect.get_height()plt.text(rect.get_x() + rect.get_width() / 2, height, str(height), ha='center', va='bottom')
plt.show()

方法3(推荐使用):


import numpy as np
import pandas as pd
import matplotlib.pyplot as plt_, count_values = np.unique([1, 1, 2, 2, 2, 3], return_counts=True)
print('count_values:', count_values)class_names = ['mountain', 'street', 'glacier']#柱状图
pd.DataFrame({'train': count_values,'test': count_values},index=class_names).plot.bar()
plt.show()

4.直方图

    import numpy as npimport matplotlib.mlab as mlabimport matplotlib.pyplot as plt# example datamu = 100  # mean of distributionsigma = 15  # standard deviation of distributionx = mu + sigma * np.random.randn(10000)num_bins = 50# the histogram of the datan, bins, patches = plt.hist(x, num_bins, normed=1, facecolor='blue', alpha=0.5)# add a 'best fit' liney = mlab.normpdf(bins, mu, sigma)plt.plot(bins, y, 'r--')plt.xlabel('Smarts')plt.ylabel('Probability')plt.title(r'Histogram of IQ: $\mu=100$, $\sigma=15$')## Tweak spacing to prevent clipping of ylabelplt.subplots_adjust(left=0.15)plt.show()import seaborn as snssns.set_palette("hls")  # 设置所有图的颜色,使用hls色彩空间sns.distplot(x, kde_kws={'label':"label"},color="r", bins=30, kde=True)plt.xlabel('Smarts')plt.ylabel('Probability')plt.title(r'Histogram of IQ: $\mu=100$, $\sigma=15$')plt.show()

示例:产生均值为0,标准差为0.1的10000个点

mu, sigma = 0, 0.1
y=np.random.normal(mu, sigma,10000)
count, x, ignored=plt.hist(y,bins=50,density=True)
plt.plot(x, 1/(sigma * np.sqrt(2 * np.pi)) * np.exp( - (x - mu)**2 / (2 * sigma**2) ),
linewidth=2, color='r')
plt.show()

"""长度误差直方图"""
pig_length_list = list(map(float, pig_length_list))
pig_error_list = list(map(float, pig_error_list))
print(len(pig_error_list))
# sns.distplot(pig_error_list, hist=True, kde=True)
r=plt.hist2d(pig_length_list,pig_error_list,bins=(30,30),cmap=plt.cm.jet)
plt.xlabel('length')
plt.ylabel('Abs Error')
plt.colorbar(r[3])
plt.show()

from matplotlib import colors
r=plt.hist2d(pig_length_list,pig_error_list,bins=(30,30),cmap=plt.cm.jet,norm=colors.LogNorm())
plt.xlabel('length')
plt.ylabel('ABS Error')
plt.colorbar(r[3])
plt.show()

pig_length_list = list(map(float, pig_length_list))
pig_error_list = list(map(float, pig_error_list))
print(len(pig_error_list))
ax = sns.kdeplot(pig_length_list, pig_error_list, cmap=plt.cm.jet, shade=True, cbar=True, n_levels=30)
ax.set(xlabel='real length', ylabel='length abs error',ylim=(-20, 20))
# r=plt.hist2d(pig_length_list,pig_error_list,bins=(30,30),cmap=plt.cm.jet)
# plt.xlabel('length')
# plt.ylabel('ABS Error')
# plt.colorbar(r[3])
plt.show()

"""长度误差密度图"""
pig_length_list = list(map(float, pig_length_list))
pig_error_list = list(map(float, pig_error_list))
print(len(pig_error_list))
ax = sns.kdeplot(pig_length_list, pig_error_list, cmap=plt.cm.jet, shade=True, cbar=True, n_levels=30,shade_lowest=False)
ax.set(xlabel='real length', ylabel='length abs error',ylim=(-20, 20))
# from matplotlib import colors
# r=plt.hist2d(pig_length_list,pig_error_list,bins=(30,30),cmap=plt.cm.jet,norm=colors.LogNorm())
# plt.xlabel('length')
# plt.ylabel('ABS Error')
# plt.colorbar(r[3])
plt.show()

5.绘制3D曲线

from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax = Axes3D(fig)
X = np.arange(-4, 4, 0.25)
Y = np.arange(-4, 4, 0.25)
X, Y = np.meshgrid(X, Y)
R = X**2 +Y**2
# Z = np.sin(R)# 具体函数方法可用 help(function) 查看,如:help(ax.plot_surface)
ax.plot_surface(X, Y, R, rstride=1, cstride=1, cmap='rainbow')plt.show()

from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax = Axes3D(fig)
X = np.arange(-4, 4, 0.25)
Y = np.arange(-4, 4, 0.25)
X, Y = np.meshgrid(X, Y)
R = np.sqrt(X ** 2 + Y ** 2)# 具体函数方法可用 help(function) 查看,如:help(ax.plot_surface)
#rstride行跨 cstride列跨
ax.plot_surface(X, Y, R, rstride=1, cstride=1, cmap='rainbow')#投影 offset把图形压缩到xoy里面,z=0的位置
ax.contourf(X,Y,R,zdir='z',offset=0,cmap='rainbow')
ax.set_zlim(0,4)
plt.show()

from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax = Axes3D(fig)
X = np.arange(-4, 4, 0.25)
Y = np.arange(-4, 4, 0.25)
X, Y = np.meshgrid(X, Y)
R = X**2 - Y**2
# Z = np.sin(R)# 具体函数方法可用 help(function) 查看,如:help(ax.plot_surface)
ax.plot_surface(X, Y, R, rstride=1, cstride=1, cmap='rainbow')plt.show()

import numpy as np
import matplotlib.pyplot as plt
import math
import mpl_toolkits.mplot3d# x, y = np.mgrid[-2:2:200j, -2:2:200j]
x = np.arange(-6, 6, 0.25)
y = np.arange(-6, 6, 0.25)
x, y = np.meshgrid(x, y)
# z=(1/2*math.pi*3**2)*np.exp(-(x**2+y**2)/2*3**2)
z = np.exp(-(x**2+y**2 - 0)/2*1**2)
ax = plt.subplot(111, projection='3d')
ax.plot_surface(x, y, z, rstride=1, cstride=1, cmap='rainbow', alpha=0.9)#绘面ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_zlabel('z')
plt.show()

X = np.arange(-4, 4, 0.25)
Y = np.arange(-4, 4, 0.25)
X, Y = np.meshgrid(X, Y)
R = np.sqrt(X**2 + Y**2)# 具体函数方法可用 help(function) 查看,如:help(ax.plot_surface)
plt.imshow(R)
plt.colorbar()
plt.show()

6.3D直方图

from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as npfig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
x, y = np.random.rand(2, 100) * 4
hist, xedges, yedges = np.histogram2d(x, y, bins=4, range=[[0, 4], [0, 4]])# Construct arrays for the anchor positions of the 16 bars.
# Note: np.meshgrid gives arrays in (ny, nx) so we use 'F' to flatten xpos,
# ypos in column-major order. For numpy >= 1.7, we could instead call meshgrid
# with indexing='ij'.
xpos, ypos = np.meshgrid(xedges[:-1] + 0.25, yedges[:-1] + 0.25)
xpos = xpos.flatten('F')
ypos = ypos.flatten('F')
zpos = np.zeros_like(xpos)# Construct arrays with the dimensions for the 16 bars.
dx = 0.5 * np.ones_like(zpos)
dy = dx.copy()
dz = hist.flatten()ax.bar3d(xpos, ypos, zpos, dx, dy, dz, color='b', zsort='average')plt.show()

7.3D条状图

from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as npfig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
for c, z in zip(['r', 'g', 'b', 'y'], [30, 20, 10, 0]):xs = np.arange(20)ys = np.random.rand(20)# You can provide either a single color or an array. To demonstrate this,# the first bar of each set will be colored cyan.cs = [c] * len(xs)cs[0] = 'c'ax.bar(xs, ys, zs=z, zdir='y', color=cs, alpha=0.8)ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')plt.show()

8.plt.legend 

steps = np.linspace(0, np.pi*2, 256, dtype=np.float32)
sin_np = np.sin(steps)
print(sin_np.shape)
cos_np = np.cos(steps)
plt.figure()
plt.title('Sin and Cos',fontsize='18')
plt.plot(steps,sin_np,'r-',label='sin')
plt.plot(steps,cos_np,'b-',label='cos')
plt.legend(loc='best')
plt.show()

9.plt.subplot 

x = np.arange(0, 3 * np.pi, 0.1)
y_sin = np.sin(x)
y_cos = np.cos(x)# Set up a subplot grid that has height 2 and width 1,
# and set the first such subplot as active.
plt.subplot(2, 1, 1)
# Make the first plot
plt.plot(x, y_sin)
plt.title('Sine')
# Set the second subplot as active, and make the second plot.
plt.subplot(2, 1, 2)
plt.plot(x, y_cos)
plt.title('Cosine')
# Show the figure.
plt.show()

10.等比显示

plt.gca().set_aspect('equal')

11.画饼状图:


#饼状图
plt.pie(count_values,#和类别数相等的labels=class_names,#加上labelautopct='%1.1f%%')#加上百分比
plt.axis('equal')
plt.title('Proportion of each observed category')
plt.savefig('./pie.jpg')
plt.show()

import numpy as np
import matplotlib.pyplot as plty1 = []
y2 = []
y3 = []
years = []
for i in range(7):years.append(i)y1.append(round(25000*np.exp(0.05*i), 2))y2.append(round(25000 * (1 + 0.06) ** (i),2))y3.append(round(25000 * (1+0.02)**(4*i),2))print(y1)
print(y2)
print(y3)
plt.plot(years, y1, color='red', linewidth=1.0, label='option 1')#, linestyle='--')
plt.plot(years, y2, color='green', linewidth=1.0, label='option 2')#, linestyle='--')
plt.plot(years, y3, color='blue', linewidth=1.0, label='option 3')#, linestyle='--')
#设置x轴范围
plt.xlim((0, 10))
# 设置y轴范围
plt.ylim((25000, 40000))
plt.ylabel('Principal and interest')
plt.xlabel('Year')
plt.legend(loc='best')
# plt.yticks(np.linspace(25000, 40000, 500))
plt.savefig('./hu1.jpg')
plt.show()plt.figure(figsize=(20, 8))
# plt.title('Principal and interest')
col = ['year' + str(i) for i in years]
row = ['op1', 'op2', 'op3']
vals = []
vals.append(y1)
vals.append(y2)
vals.append(y3)
vals = np.array(vals)
# colors = ["#e41a1c","#377eb8","#00ccff"]*7
rcolors = plt.cm.BuPu(np.full(3, 0.1))
ccolors = plt.cm.BuPu(np.full(7, 0.1))
tab = plt.table(cellText=vals,colLabels=col,rowLabels=row,rowColours=rcolors,colColours=ccolors,loc='center',cellLoc='center',rowLoc='center')
tab.scale(1, 2)
plt.axis('off')
plt.savefig('./hu2.jpg')
plt.show()op1_interest = y1[-1] - 25000
op2_interest = y2[-1] - 25000
op3_interest = y3[-1] - 25000
def plot_pie(interest, name):plt.figure()plt.title(name)patches, texts, autotexts = plt.pie(x=[interest, 25000],#指定绘图数据colors=["#d5695d", "#5d8ca8"],labels=['Total interest', 'Initial investment'],autopct='%.2f%%',)plt.legend(patches, ['Total interest', 'Initial investment'],  # 添加图例# title="Pie Learning",loc="best",# fontsize=15,bbox_to_anchor=(1, 0, 0.5, 1))plt.savefig('./hu+{}.jpg'.format(name))plt.show()
plot_pie(op1_interest, 'option1')
plot_pie(op2_interest, 'option2')
plot_pie(op3_interest, 'option3')

12.生成两类数据

import torch
import matplotlib.pyplot as plt
from torch import nn, optim
from torch.autograd import Variableimport numpy as npdef produce_data():# 假数据n_data = torch.ones(100, 2)  # 数据的基本形态x0 = torch.normal(2 * n_data, 1)  # 类型0 x data (tensor), shape=(100, 2)y0 = torch.zeros(100)  # 类型0 y data (tensor), shape=(100, 1)x1 = torch.normal(-2 * n_data, 1)  # 类型1 x data (tensor), shape=(100, 1)y1 = torch.ones(100)  # 类型1 y data (tensor), shape=(100, 1)print(x0.shape)# 注意 x, y 数据的数据形式是一定要像下面一样 (torch.cat 是在合并数据)x = torch.cat((x0, x1), 0).type(torch.FloatTensor)  # FloatTensor = 32-bit floatingprint(x.shape)y = torch.cat((y0, y1), 0).type(torch.FloatTensor)  # LongTensor = 64-bit integerprint(y.shape)# 画图plt.scatter(x.data.numpy()[:, 0], x.data.numpy()[:, 1], c=y.data.numpy(), s=100, lw=0, cmap='RdYlGn')plt.show()return x, y
if __name__ == '__main__':produce_data()

13.plot的一些应用

import numpy as np
import matplotlib.pyplot as plt
import matplotlib
x = np.arange(-4,4,0.5)
# print(x)
# fname 为 你下载的字体库路径,注意 SimHei.ttf 字体的路径
zhfont1 = matplotlib.font_manager.FontProperties(fname='/usr/share/fonts/truetype/arphic/uming.ttc')
plt.rcParams['xtick.direction'] = 'in'#将x周的刻度线方向设置向内
plt.rcParams['ytick.direction'] = 'in'#将y轴的刻度方向设置向内plt.axis([-3, 3, -2, 3])
# plt.title("Matplotlib demo")
plt.xlabel("输入",fontproperties=zhfont1)
plt.ylabel("输出",fontproperties=zhfont1)sigmoid_y = 1/(1+np.exp(-x))
print(sigmoid_y)plt.plot(x,sigmoid_y,'s',color='black',label='Sigmoid')
# plt.show()tanh_y = (np.exp(x)-np.exp(-x))/(np.exp(x)+np.exp(-x))
print(tanh_y)
# plt.rcParams['xtick.direction'] = 'in'#将x周的刻度线方向设置向内
# plt.rcParams['ytick.direction'] = 'in'#将y轴的刻度方向设置向内
plt.plot(x,tanh_y,'.-',color='black',label='Tanh')
# plt.show()relu_y = [i if i>0 else 0 for i in x ]
print(relu_y)
# plt.rcParams['xtick.direction'] = 'in'#将x周的刻度线方向设置向内
# plt.rcParams['ytick.direction'] = 'in'#将y轴的刻度方向设置向内
plt.plot(x,relu_y,'-',color='black',label='Relu')
# plt.show()elu_y = [i if i>0 else 0.3*(np.exp(i)-1) for i in x ]
print(elu_y)
# plt.rcParams['xtick.direction'] = 'in'#将x周的刻度线方向设置向内
# plt.rcParams['ytick.direction'] = 'in'#将y轴的刻度方向设置向内
plt.plot(x,elu_y, '^',color='black',label='Elu')
plt.legend(loc='best')
# plt.show()
plt.savefig('hha.jpg')

14-1.ax画3d图与线段等比缩放


import matplotlib.pyplot as plt
ax = plt.subplot(111, projection='3d')point_a = np.array([[1, 2, 3],[2, 2, 2]]).astype(np.float32)
point_ori_a_length = np.linalg.norm(point_a[1, :] - point_a[0, :])point_b = np.array([[2, 2, 2],[5, 5, 5]]).astype(np.float32)
point_ori_b_length = np.linalg.norm(point_b[1, :] - point_b[0, :])
print('==point_ori_a_length:', point_ori_a_length)
print('==point_ori_b_length:', point_ori_b_length)
print('==point_ori_b_length / point_ori_a_length:', point_ori_b_length / point_ori_a_length)ax.plot(point_a[:, 0], point_a[:, 1], point_a[:, 2])
ax.plot(point_b[:, 0], point_b[:, 1], point_b[:, 2])
plt.xlim(1, 6)
plt.ylim(1, 6)
ax.set_zlim(1, 6)
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_zlabel('z')
plt.show()ax = plt.subplot(111, projection='3d')point_a[1, :] = point_a[0, :] + (point_a[1, :] - point_a[0, :]) / point_ori_a_lengthpoint_b[1, :] = point_b[0, :] + (point_b[1, :] - point_b[0, :]) / point_ori_a_length
dis_ = point_b[1, :] - point_b[0, :]
point_b[0, :] = point_a[1, :]
point_b[1, :] = point_b[0, :] + dis_
point_now_a_length = np.linalg.norm(point_a[1, :] - point_a[0, :])
point_now_b_length = np.linalg.norm(point_b[1, :] - point_b[0, :])
print('==point_now_a_length:', point_now_a_length)
print('==point_now_b_length:', point_now_b_length)
print('==point_now_b_length / point_now_a_length:', point_now_b_length / point_now_a_length)
ax.plot(point_a[:, 0], point_a[:, 1], point_a[:, 2])
ax.plot(point_b[:, 0], point_b[:, 1], point_b[:, 2])
plt.xlim(1, 6)
plt.ylim(1, 6)
ax.set_zlim(1, 6)
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_zlabel('z')
plt.show()

14-2.显示3d手同时用ax.text显示序号

注意的是cv2放在plt后面


import matplotlib.pyplot as plt
import cv2
import mpl_toolkits.mplot3d
import numpy as npcamera_hand_right_3dkpts = np.array([[0.8647481799125671, -38.08830642700195, 335.964599609375], [0.6563963294029236, -38.625457763671875, 332.47576904296875], [0.14763949811458588, -40.26291275024414, 328.74615478515625], [0.006336620077490807, -42.1802978515625, 326.2594909667969], [-0.3949889540672302, -43.737998962402344, 324.50811767578125], [1.0360386371612549, -44.29584503173828, 329.23480224609375], [1.794701099395752, -47.37247085571289, 327.18402099609375], [2.4282193183898926, -49.27631378173828, 326.35888671875], [3.095630407333374, -50.87310791015625, 325.6286926269531], [1.8775584697723389, -45.17683410644531, 330.75909423828125], [3.0296430587768555, -48.540794372558594, 328.830810546875], [4.360949993133545, -50.52870178222656, 327.6854553222656], [5.470311641693115, -52.16162872314453, 326.7551574707031], [2.8303887844085693, -45.574363708496094, 332.34515380859375], [4.117491722106934, -48.58415603637695, 330.589111328125], [5.522796154022217, -50.38448715209961, 329.4515075683594], [6.774843692779541, -51.6481819152832, 328.4239196777344], [3.768697500228882, -45.72537612915039, 333.8792419433594], [4.950739860534668, -48.10667037963867, 332.6934814453125], [6.098034858703613, -49.30638885498047, 331.6702575683594], [7.019787788391113, -50.42774200439453, 330.9171142578125]])
camera_hand_right_3dkpts = camera_hand_right_3dkpts.transpose()
print(camera_hand_right_3dkpts.shape)
hand_edges = np.array([[0, 1], [1, 2], [2, 3], [3, 4],[0, 5], [5, 6], [6, 7], [7, 8],[0, 9], [9, 10], [10, 11], [11, 12],[0, 13], [13, 14], [14, 15], [15, 16],[0, 17], [17, 18], [18, 19], [19, 20]])
ax = plt.axes(projection='3d')
for i, edge in enumerate(hand_edges):ax.plot(camera_hand_right_3dkpts[0, edge], camera_hand_right_3dkpts[1, edge], camera_hand_right_3dkpts[2, edge])
# ax.set_xlabel('x')
# ax.set_ylabel('y')
# ax.set_zlabel('z')
# plt.xlim(-30, -42)
# plt.ylim(-150, -154)
# ax.set_zlim(70, 95)
# axis_limit = 700
x_c = np.mean(camera_hand_right_3dkpts[0, :])
y_c = np.mean(camera_hand_right_3dkpts[1, :])
z_c = np.mean(camera_hand_right_3dkpts[2, :])
# axis_limit = 50
#
# ax.set_xlim3d([x_c - axis_limit / 2, x_c + axis_limit / 2])
# ax.set_ylim3d([y_c - axis_limit / 2, y_c + axis_limit / 2])
# ax.set_zlim3d([3 * z_c / 4, z_c])
ax.set_aspect('auto')
ax.set_xticks([])
ax.set_yticks([])
ax.set_zticks([])
ax.set_xticklabels(['x'])
ax.set_yticklabels(['y'])
ax.set_zticklabels(['z'])
x_3d = camera_hand_right_3dkpts[0, :].transpose()
y_3d = camera_hand_right_3dkpts[1, :].transpose()
z_3d = camera_hand_right_3dkpts[2, :].transpose()ax.scatter(x_3d,y_3d,z_3d,marker='o',color=(0, 0, 1),  # rgb
)
for i, _ in enumerate(hand_edges):ax.text(x_3d[i], y_3d[i], z_3d[i], i)
plt.show()

14-3.变换视角

plt坐标系如下左图,而我们一般3d坐标是如下右图有时候为了与2d图片对上,将x,y变换到x,z方便查看,乘以一个矩阵变换一下.

            vis_R = np.array([[1, 0, 0],[0, 0, -1],[0, 1, 0]])keypoints_3d[:, :3] = keypoints_3d[:, :3] @ vis_R

同时为了,将视角变化一下,在限定一下范围

        axis_azimuth = -90axis_elev = 0ax.view_init(elev=axis_elev,azim=axis_azimuth,)h = 2d_img_hw = 2d_img_wx_c = np.mean(x_3d)y_c = np.mean(y_3d)z_c = np.mean(z_3d)ax.set_xlim3d([x_c - w / 2, x_c + w / 2])# ax.set_ylim3d([y_c - h / 2, y_c + h / 2])ax.set_zlim3d([z_c - h / 2, z_c + h / 2])

不同视角的手,其中负号代码逆时针转

z0y0视角:                   z0y45视角:

  

z45y0视角:                   z45y45视角:

z-90y0视角:

15.plt.text在点处写文字

import matplotlib.pyplot as plt
import numpy as npprecision = np.array([1.        , 1.        , 1.        , 1.        , 1.        ,1.        , 1.        , 1.        , 1.        , 1.        ,1.        , 1.        , 0.99883178, 0.99833749, 0.99833749,0.99833749, 0.99833749, 0.99833749, 0.99785484, 0.99785484,0.99785484, 0.99785484, 0.99785484, 0.99785484, 0.99785484,0.99785484, 0.99785484, 0.99785484, 0.99785484, 0.99785484,0.99785484, 0.99785484, 0.99785484, 0.99785484, 0.99785484,0.99785484, 0.99785484, 0.99785484, 0.99785484, 0.99785484,0.99785484, 0.99776999, 0.99776999, 0.99776999, 0.99776999,0.99776999, 0.99768465, 0.99768465, 0.99768465, 0.99768465,0.99768465, 0.99768465, 0.99768465, 0.99768465, 0.99768465,0.99768465, 0.99768465, 0.99768465, 0.99768465, 0.99768465,0.99768465, 0.99768465, 0.99768465, 0.997593  , 0.997593  ,0.997593  , 0.99744572, 0.99744572, 0.99730402, 0.99730402,0.99694439, 0.99677224, 0.99663965, 0.99650553, 0.99650553,0.99619338, 0.99587397, 0.99571615, 0.99540272, 0.99509893,0.99463807, 0.99403509, 0.99372494, 0.99293591, 0.99118943,0.98993795, 0.98874359, 0.98677335, 0.9854745 , 0.98343158,0.98100471, 0.9796647 , 0.97644179, 0.97417309, 0.97098646,0.96825863, 0.96327888, 0.95922441, 0.94851402, 0.82842664,0.        ])recall = np.linspace(.0, 1.00, int(np.round((1.00 - .0) / .01)) + 1,endpoint=True)
PrecisIndmaxscore = [86, 0.7205873131752014]
APmaxscore = 0.13149480521678925
iouThr = 0.5ap = sum(precision) / len(precision)
x1 = recall[np.nonzero(precision)[0][-1]]
y1 = precision[np.nonzero(precision)[0][-1]]plt.figure()
plt.text(x1, y1, 'ApScore: ' + str(APmaxscore)[:5], fontsize=8)
if PrecisIndmaxscore[0] != -1:x2 = recall[PrecisIndmaxscore[0]]y2 = precision[PrecisIndmaxscore[0]]plt.text(x2, y2, 'PScore: ' + str(PrecisIndmaxscore[-1])[:5], fontsize=8)plt.title('IOU={}'.format(str(iouThr)[:4]))
plt.xlabel("Recall")
plt.ylabel("Precision")
plt.plot(recall, precision, label='AP: ' + str(ap)[:5])#marker='o')
plt.legend()
# plt.savefig(os.path.join(savepath, "iou_{:2}.jpg".format(str(iouThrs[i])[:4])))
plt.show()

15.plt.sublpot

画多个图在一个图上

import matplotlib.pyplot as plt
import numpy as np
import seaborn as snslengths = np.random.randint(0, 10, 1000)
plt.figure(figsize=(12.8, 9.6)) #1280*960
plt.subplot(2, 2, 1, frameon=False) # 两行两列,位置是1的子图
plt.title('One')
plt.xlabel('x1')
plt.ylabel('y1')
sns.set_palette("hls")  # 设置所有图的颜色,使用hls色彩空间
sns.distplot(lengths, kde_kws={'label': "label"}, color="r", bins=30, kde=True)plt.subplot(2, 2, 2, frameon=False)# 两行两列,位置是1的子图
plt.title('Two')
plt.xlabel('x1')
plt.ylabel('y1')
sns.set_palette("hls")  # 设置所有图的颜色,使用hls色彩空间
sns.distplot(lengths, kde_kws={'label': "label"}, color="r", bins=30, kde=True)plt.show()

参考:

Python--matplotlib绘图可视化知识点整理 - 止战 - 博客园

Intel Image Classification (CNN - Keras) | Kaggle

matplotlib与seaborn的一些使用相关推荐

  1. matplotlib中文文档_python绘图库——Matplotlib及Seaborn使用(入门篇1)

    在数据分析过程中,数据及模型可视化是无可避免的,同时这也是展示我们数据分析成果的最佳方式.因此,熟悉掌握绘图库的使用,对精进我们的数据分析技能起着不可替代的作用. 今天,我们就来了解一下python强 ...

  2. Python使用matplotlib或者Seaborn箱图(boxplot)可视化时汉语(中文)标签显示成了框框□□、什么情况、我们有解决方案。

    Python使用matplotlib或者Seaborn箱图(boxplot)可视化时汉语(中文)标签显示成了框框□□.什么情况.我们有解决方案. #仿真数据 import pandas as pd i ...

  3. python绘图库seaborn_python绘图库——Matplotlib及Seaborn使用(入门篇2)

    在数据分析过程中,数据及模型可视化是无可避免的,同时这也是展示我们数据分析成果的最佳方式.因此,熟悉掌握绘图库的使用,对精进我们的数据分析技能起着不可替代的作用. 在上一篇中,我们掌握了Matplot ...

  4. [转载] python可视化分析(matplotlib、seaborn、ggplot2)

    参考链接: Python Matplotlib数据可视化2 python可视化分析总结(matplotlib.seaborn.ggplot) 一.matplotlib库1.基本绘图命令3.图形参数设置 ...

  5. 数据可视化总结——matplotlib、seaborn

    数据可视化总结--matplotlib.seaborn 导包 matplotlib基本参数 折线图 绘制直方图 hist(), plt.bar() 绘制水平方向的柱状图 饼图 散点图 箱线图 seab ...

  6. python可视化分析(matplotlib、seaborn、ggplot2)

    python可视化分析总结(matplotlib.seaborn.ggplot) 一.matplotlib库 1.基本绘图命令 3.图形参数设置 4.特殊统计图的绘制 4.1 数学函数图 4.2 气泡 ...

  7. python绘图库seaborn_python绘图库——Matplotlib及Seaborn使用(入门篇1)

    在数据分析过程中,数据及模型可视化是无可避免的,同时这也是展示我们数据分析成果的最佳方式.因此,熟悉掌握绘图库的使用,对精进我们的数据分析技能起着不可替代的作用. 今天,我们就来了解一下python强 ...

  8. 数据可视化解决方案 Data Visualization with Matplotlib and Seaborn Li

    作者:禅与计算机程序设计艺术 1.简介 Matplotlib 和 Seaborn 是Python数据可视化库,本文将详细阐述如何利用Matplotlib和Seaborn进行数据的可视化,并基于Scik ...

  9. python画图,使用matplotlib和seaborn来设置图形的字体大小,坐标轴的线宽,风格,取值范围

    1. matplotlib 样式的设计 1.1 设置坐标轴的线框 如果我们要设置坐标轴的线宽,我们可以向下面这样做: import matplotlib.pyplot as plt###设置坐标轴的粗 ...

  10. Python_note9 Matplotlib画图 Seaborn画图

    数据处理到人工智能 数据表示 采用合适方式程序表达数据 数据清洗 数据归一化,数据转换,异常值处理 数据统计 数据概要理解,数量,分布,中位数 数据可视化 直观展示数据内涵 数据挖掘 从数据分析获得知 ...

最新文章

  1. 【怎样写代码】工厂三兄弟之工厂方法模式(三):解决方案 II
  2. 过程中存根的作用有_模温机的作用 模压过程中模温机的作用有哪些?
  3. 春节充电 | 文科生都能看懂的机器学习教程:梯度下降、线性回归、逻辑回归(附动图解释)...
  4. .NET Core 中的并发编程
  5. 百度不收录你网站的原因
  6. DEBUG org.springframework.web.servlet.DispatcherServlet - Error rendering view [org.thymeleaf.spring
  7. Android项目笔记【项目管理统计图app】:使用github上的cardslib开源项目实现CardView(1)...
  8. java定义一个方法,返回一个整数数组的元素平均值
  9. 5月25号GE一面经历
  10. 如何才能招到马云这样的人才?海尔张瑞敏这样说...
  11. 批量获得oracle存储过程等
  12. 使用SQLite3支持中文路径
  13. springboot电影院订票售票系统毕业设计毕设作品开题报告开题答辩PPT
  14. QT widget宽高比
  15. 中国将在未来几十年主导电动汽车市场
  16. 使用MP4BOX GUI从MP4中分离(提取)字幕srt文件
  17. 不从Win7/Win8.1升级,直接全新安装并激活Win10方法
  18. SQL面试必考——计算留存率
  19. html页面用excel打印,excel怎么打印不能全部显示出来
  20. Spring5春天还是配置地狱

热门文章

  1. python写名片管理系统_Python实现名片管理系统
  2. 从Java程序员进阶为架构师,全套16张图概括最全技能!建议收藏!
  3. 论文浅尝 | 用于视觉推理的显式知识集成
  4. jieba.cut与jieba.lcut的区别
  5. 机器学习中的特征建模(特征工程)和算法选型建模 - 以暴力破解识别为例
  6. ListView原理简单介绍(着重介绍getView被调用的一系列过程)
  7. Web高效管理多个项目的SVN仓库
  8. background-size 兼容ie8以下浏览器的方法
  9. 两台老机器,AMD K6-2和Intel C366
  10. 计算机网络学习笔记-1.2.3第一章总结