在Matplotlib绘制的图形中,图形中包含多条曲线和散点,为它们添加图例,请从以下选项中选出你认为正确的答案:( ) 公共代码如下: import numpy as np import matplotlib. pyplot as plt x=np.linspace(0,6,1024) data = np.random.standard_normal((150,2)) y_1=np.sin(x) y_2=np.cos(x)
选项:
A:plt.plot(x,y_1,c='m',lw=3.,text='sin(x)')\nplt.plot(x,y_2,c='c',lw=3.,Is='-',text='cos(x)')\nplt.scatter(data:,0],data:,1],c='y',text='random')\nplt.legend()\nplt.show()
B:plt.plot(x,y_1,c='m',lw=3.,title='sin(x)')\nplt.plot(x,y_2,c='c',lw=3.,ls='-',title='cos(x)')\nplt.scatter(data:,0],data:,1],c='y',title='random')\nplt.legend ()\nplt.show()
C:plt.plot(x,y_1,c='m',lw=3.,label='sin(x)')\nplt. plot (x, y_2, c='c',lw=3.,ls='-',label='cos(x)')\nplt.scatter(data:,0],data:,1],c='y',label='random')\nplt.legend ()\nplt.show ()
D:plt.plot(x,y_1,c='m',lw=3.,legend='sin(x)')\nplt.plot(x,y_2,c='c',lw=3.,ls='-',legend='cos(x)')\nplt.scatter(data:,0],data:,1],c='y',legend='random')\nplt.legend ()\nplt.show()
发布时间:2024-04-19 21:39:06