pythonmatplotlib绘图技巧(1)-plt.legend()
import tensorflow as tflinspace函数python
from matplotlib import pyplot as plt
import numpy as np
train_x = np.linspace(-1, 1, 100)
train_y_1 = 2*train_x + np.random.rand(*train_x.shape)*0.3
train_y_2 = train_x**2+np.random.randn(*train_x.shape)*0.3
plt.scatter(train_x, train_y_1, c='red', marker='v' )
plt.scatter(train_x, train_y_2, c='blue', marker='o' )
plt.legend(["red","Blue"])
plt.show()
plt.legend()函数主要的作⽤就是给图加上图例,plt.legend([x,y,z])⾥⾯的参数使⽤的是list的的形式将图表的的名称喂给这和函数。2.
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论