圆月山庄资源网 Design By www.vgjia.com

废话不多说,直接上代码吧!

import matplotlib.pyplot as plt
import numpy as np
 
data1 = np.loadtxt('/data_1/SSD/caffe/tools/extra/DSOD300_VOC0712_DSOD300_300x300.log.test')
data2 = np.loadtxt('/data_1/SSD/caffe/tools/extra/DSOD300_VOC0712_DSOD300_300x300.log.train')
 
plt.title('Result Analysis')
 
plt.plot(data1[:,0], data1[:,2], color='skyblue', label='y1')
plt.plot(data2[:,0], data2[:,3], color='blue', label='y2')
plt.legend()
 
plt.xlabel('x')
plt.ylabel('y')
plt.show()

结果:

python通过文本在一个图中画多条线的实例

加一些不同形式的线

import matplotlib.pyplot as plt
import numpy as np
 
data1 = np.loadtxt('/data_1/project_test/teest1.txt')
data2 = np.loadtxt('/data_1/project_test/teest2.txt')
data3 = np.loadtxt('/data_1/project_test/teest3.txt')
 
plt.title('Result Analysis')
 
plt.plot(data1[:,0], data1[:,1], color='skyblue', label='y1',ls='-.')#ls或linestyle
plt.plot(data2[:,0], data2[:,1], color='green', label='y2',ls=':')
plt.plot(data3[:,0], data3[:,1], color='red', label='y3',ls='steps')
plt.legend()
 
plt.xlabel('x')
plt.ylabel('y')
plt.show()

python通过文本在一个图中画多条线的实例


加标记

import matplotlib.pyplot as plt
import numpy as np
 
data1 = np.loadtxt('/data_1/project_test/teest1.txt')
data2 = np.loadtxt('/data_1/project_test/teest2.txt')
data3 = np.loadtxt('/data_1/project_test/teest3.txt')
 
plt.title('Result Analysis')
 
plt.plot(data1[:,0], data1[:,1], color='skyblue', label='y1',ls='-.',marker='*')
plt.plot(data2[:,0], data2[:,1], color='green', label='y2',ls=':',marker='+')
plt.plot(data3[:,0], data3[:,1], color='red', label='y3',ls='steps',marker='D')
plt.legend()
 
plt.xlabel('x')
plt.ylabel('y')
plt.show()

python通过文本在一个图中画多条线的实例

总结:

linestyle or ls:实线'-' , 破折线'--' , 点划线'-.' ,虚线':'

plt.plot()参数设置
Property Value Type
alpha 控制透明度,0为完全透明,1为不透明
animated [True False]
antialiased or aa [True False]
clip_box a matplotlib.transform.Bbox instance
clip_on [True False]
clip_path a Path instance and a Transform instance, a Patch
color or c 颜色设置
contains the hit testing function
dash_capstyle [‘butt' ‘round' ‘projecting']
dash_joinstyle [‘miter' ‘round' ‘bevel']
dashes sequence of on/off ink in points
data 数据(np.array xdata, np.array ydata)
figure 画板对象a matplotlib.figure.Figure instance
label 图示
linestyle or ls 线型风格[‘-' ‘–' ‘-.' ‘:' ‘steps' …]
linewidth or lw 宽度float value in points
lod [True False]
marker 数据点的设置[‘+' ‘,' ‘.' ‘1' ‘2' ‘3' ‘4']
markeredgecolor or mec any matplotlib color
markeredgewidth or mew float value in points
markerfacecolor or mfc any matplotlib color
markersize or ms float
markevery [ None integer (startind, stride) ]
picker used in interactive line selection
pickradius the line pick selection radius
solid_capstyle [‘butt' ‘round' ‘projecting']
solid_joinstyle [‘miter' ‘round' ‘bevel']
transform a matplotlib.transforms.Transform instance
visible [True False]
xdata np.array
ydata np.array

zorder any number

补充拓展:python 画直线和平面实例

画直线

from mpl_toolkits.axisartist.axislines import SubplotZero
import matplotlib.pyplot as plt
import numpy as np
 
fig = plt.figure(1)
ax = SubplotZero(fig, 111)
fig.add_subplot(ax)
 
for direction in ["xzero", "yzero"]:
  # adds arrows at the ends of each axis
  ax.axis[direction].set_axisline_style("-|>")
 
  # adds X and Y-axis from the origin
  ax.axis[direction].set_visible(True)
 
for direction in ["left", "right", "bottom", "top"]:
  # hides borders
  ax.axis[direction].set_visible(False)
  
plt.text(-2, 2, r"y=kx+b",
     horizontalalignment='center', fontsize=20)  
  
x = np.linspace(-2,2,100)  
   
k=-1
b=0  
  
y = k*x + b
 
ax.plot(x, y)
plt.show()

python通过文本在一个图中画多条线的实例

画平面

import matplotlib.pyplot as plt
from matplotlib import cm
import numpy as np
 
fig = plt.figure()
ax = fig.gca(projection='3d')
 
# Make data.
X = np.arange(-5, 5, 0.25)
Y = np.arange(-5, 5, 0.25)
X, Y = np.meshgrid(X, Y)
a1 = 2
a2 = 1
Z = a1*X+a2*Y
 
# Plot the surface.
surf = ax.plot_surface(X, Y, Z, cmap=cm.Blues,
            linewidth=0, antialiased=False)
 
ax.set_xlabel(r'$x_1$',fontsize = 20, color = 'blue')
ax.set_ylabel(r'$x_2$',fontsize = 20, color = 'blue')
ax.set_zlabel(r'$x_3$',fontsize = 20, color = 'blue')

python通过文本在一个图中画多条线的实例

以上这篇python通过文本在一个图中画多条线的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。

标签:
python,文本,图中,画线

圆月山庄资源网 Design By www.vgjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
圆月山庄资源网 Design By www.vgjia.com

RTX 5090要首发 性能要翻倍!三星展示GDDR7显存

三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。

首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。

据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。