use matplotlib to draw scatter plot
2024-09-02 22:09:03
There are many pionts in this kind of table.
How to do it? We can use scatter() to draw it.
Code:
import matplotlib.pyplot as plt
plt.scatter(1,4)
plt.show()
The result :
now,we can use scatter() to draw many pionts.Just like this:
code:
import matplotlib.pyplot as plt
x=[1,2,3,4,5,6]
y=[2,4,6,8,10,11]
plt.scatter(x,y,s=50)
plt.show()
现在试试绘制更多的点,代码如下:
import matplotlib.pyplot as plt
x_values=list(range(1,1001))
y_valuse=[x**2 for x in x_values]
plt.scatter(x_values,y_valuse,s=40)
plt.axis([0,1100,0,1100000])#参数从左向右含义一次是:横坐标的起始点、横坐标的最大值,纵坐标的起始点,纵坐标的最大值
plt.show()
绘制效果如下图所示:
最新文章
- MVC中使用[ValidateAntiForgeryToken]防止CSRF 注入攻击
- c# 支付宝查单补单
- @Entity设置OneToMany
- Event Delivery: The Responder Chain(事件传递,响应链)
- AVAudioPlayer音频播放器-备用
- mysqli连接数据库函数
- powerdesigner反向MySQL5.1数据库 生成ER图
- ubuntu16.04搭建ftp服务器
- 4.5管道实现机制和模拟构建管道「深入浅出ASP.NET Core系列」
- MT【311】三角递推数列
- 修改OBS为仅直播音频
- openLayers 4 canvas图例绘制,canvas循环添加图片,解决图片闪烁问题
- 利用for循环如何判定是水仙花数
- js函数前加分号和感叹号是什么意思?有什么用?
- linux nc命令使用详解(转)
- 二叉树的java实现
- 本地oracle的配置连接
- (java基础)抽象类加泛型的理解
- Python的函数一
- Android——Activity的生命周期
热门文章
- 初探网络流:dinic/EK算法学习笔记
- 题解 P3950 【部落冲突】
- redis之Set(有序)类型常用方法总结
- mysql遇到java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowed
- ajax Ajax处理下载文件response没有反应
- Eclipse - 常见问题 - Refresh
- 「CF286C」Main Sequence
- 图的数据结构的实现与遍历(DFS,BFS)
- 阿里云服务器win2003下iis整合tomcat共享80端口
- Socket传输大文件(发送与接收)