Open twn39 opened 9 years ago
线图:
x = linspace(-5,5,200)
plot(x,sin(x),label='$sin(x)$')
plot(x, cos(x), label='$cos(x)$')
plot(x, sin(x)*cos(x), '--',label='$sin(x)cos(x)$')
title('Matplotlib')
xlabel('$x$')
ylabel('$f(x)$')
text(-0.5, sin(-0.5), '$\leftarrow (-0.5, sin(-0.5))$')
legend()
散点图:
a = linspace(-5,5,200)
b = 3*x+2
bn = b + normal(5, 3.5,size(b)) # 产生数据
scatter(a, bn, color='g', alpha=0.4, s=50)
直方图:
bar = normal(2, 1.5, 100)
hist(bar, label='Normal')
legend()
箱形图:
box = normal(2, 1.5, 100)
sns.boxplot(box)
以下示例使用
pylab
和seaborn
: