python 曲线图
时间: 2023-10-12 07:08:01 浏览: 101
python数据可视化——曲线图
要绘制Python曲线图,你可以使用matplotlib这个Python库。下面是一个绘制曲线图的示例代码:
```
import matplotlib.pyplot as plt
import numpy as np
X = np.linspace(0, 10, 100)
Y = X * X
plt.figure(figsize=(8, 6))
plt.xlabel("time(s)")
plt.ylabel("Volt")
plt.title("Example")
plt.plot(X, Y)
plt.show()
```
在这段代码中,我们首先导入matplotlib和numpy库。然后,使用numpy的linspace函数生成X轴的坐标数据,再根据X轴的值计算对应的Y轴的值。接下来,我们创建一个图形窗口,设置X轴和Y轴的标签,以及图形的标题。最后,使用plt.plot函数绘制曲线图,将X和Y传入,然后使用plt.show()函数显示图形。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [Python绘制简单的曲线图·](https://blog.csdn.net/K_AAbb/article/details/116304206)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *3* [Python笔记.docx](https://download.csdn.net/download/bxy0806/88235414)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文