plt.figure(figsize=(5, 3))x = np.linspace(0, 2*np.pi)y = np.sin(x)plt.plot(x, y, c="r")# option# square: 让画布呈现正方形,x轴和y轴宽高一致plt.axis("square")plt.show()7.标题和网格线 titlegrid plt.figure(figsize=(5, 3))x = np.
ax.plot(...,linestyle='--',...) matplotlib支持如下线型: 二:scatter 散点图,直接看代码: 代码语言:javascript 代码运行次数:0 运行 AI代码解释 importmath fig=plt.figure()ax=fig.subplots()x=[0,2,4,6,8,10,12,14,16,18]s_exp=[20*2**nforninrange(len(x))]s_square=[20*n**2for n...
函数原型:matplotlib.pyplot.plot(*args, scalex=True, scaley=True, data=None, **kwargs) >>> plot('xlabel', 'ylabel', data=obj) 解释:All indexable objects are supported. This could e.g. be a dict, a pandas.DataFame or a structured numpy array. data 参数接受一个对象数据类型,所有可被...
plt.plot(x,color='g') plt.plot(x+1,color='0.5') plt.plot(x+2,color='#FF00FF') plt.plot(x+3,color=(0.1,0.2,0.3)) plt.show() 具体实现效果: 7. 切换线条样式-marker 如果想改变线条的样式,我们可以使用修改 plot() 绘图接口中 mark ...
# plot_multi_curve.py import numpy as np import matplotlib.pyplot as plt x = np.linspace(0.1, 2 * np.pi, 100) y_1 = x y_2 = np.square(x) y_3 = np.log(x) y_4 = np.sin(x) plt.plot(x,y_1) plt.plot(x,y_2) ...
# 绘制特殊点 mp.scatter(x_tck, # x坐标数组 x_tck ** 2, # y坐标数组 marker="s", # 点形状 s:square s=40, # 大小 facecolor="blue", # 填充色 zorder=3) # 图层编号 # marker点型可参照:help(matplotlib.markers) 1. 2. 3. 4. 5. 6. 7. 8. 7. 备注 # 在图表中为某个点添加...
x=[1,2,3,4,5]y1=[2,4,6,8,10]y2=[1,3,5,7,9]plt.plot(x,y1,color='blue',marker='s',markerfacecolor='yellow',label='Square')plt.plot(x,y2,color='red',marker='^',markerfacecolor='cyan',label='Triangle')plt.title('Different Marker Styles and Colors - how2matplotlib.com'...
plot() 绘图接口中 mark参数 点标记名称 标记 点(point marker) . 像素点(pixel marker) , 圆形(circle marker) o 正方形(square marker) s’ 三角形(向下,上,左,右) v, ^, <, > 三角星(向下,上,左,右) 1, 2, 3, 4 五边星(pentagon marker) p 星型(star marker) * 1 号六角形(hexagon1...
x=np.linspace(0,10,10)y=np.sin(x)plt.figure(figsize=(10,6))plt.plot(x,y,'o-',label='Circle')plt.plot(x,y+0.5,'s-',label='Square')plt.plot(x,y-0.5,'^-',label='Triangle')plt.title('How to use markers in Matplotlib - how2matplotlib.com')plt.legend()plt.grid(True)plt...
a[0][0].plot(x,x*x) a[0][0].set_title('square') #绘制平方根图像 a[0][1].plot(x,np.sqrt(x)) a[0][1].set_title('square root') #绘制指数函数 a[1][0].plot(x,np.exp(x)) a[1][0].set_title('exp') #绘制对数函数 ...