数据分析折线图

import matplotlib.pyplot as plt

input_values = [1, 2, 3, 4, 5]
squares = [1, 4, 9, 16, 25]
x_value = list(range(1, 1001))
y_value = [x ** 2 for x in x_value]

plt.plot(input_values,squares,linewidth=5)#linewidth线条粗细

edgecolors()删除数据点的轮廓

c()自定义颜色

使用颜色映射

plt.scatter(x_value, y_value, c=y_value, cmap=plt.cm.Reds, edgecolors=‘none’, s=40)

plt.scatter(x_value, y_value, c=‘red’, edgecolors =‘none’, s=20)

设置图标标题,并给坐标轴加标签

plt.title(“squares numbers”, fontsize=24)
plt.xlabel(“value”, fontsize=14)
plt.ylabel(“squares of value”, fontsize=14)

设置刻度标记的大小

plt.tick_params(axis=‘both’, labelsize=14)

设置每个坐标的取值范围

plt.axis([0, 1100, 0, 1100000])
plt.show()

自动保存图表

plt.savefig('suqares_plot.png ', bbox_inches=‘tight’)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值