python 画图可显示坐标
时间: 2023-09-11 08:10:25 浏览: 110
绘图范例,可以显示坐标
要在Python中绘制图形并显示坐标,你可以使用matplotlib库。以下是一个示例代码,可以显示坐标:
```python
import matplotlib.pyplot as plt
x = \[1, 2, 3, 4, 5, 6\]
y = \[10, 20, 30, 40, 50, 60\]
plt.plot(x, y, 'r*')
for a, b in zip(x, y):
plt.text(a, b, (a, b))
plt.show()
```
这段代码使用了`plt.plot()`函数来绘制散点图,并使用`plt.text()`函数在每个点上显示坐标。你可以根据需要修改x和y的值来绘制不同的图形。
#### 引用[.reference_title]
- *1* *3* [python画图显示中文标题及显示每个点的坐标](https://blog.csdn.net/qq_28077617/article/details/118197244)[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^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* [Python画图如何显示各点横纵坐标(x, y)?](https://blog.csdn.net/qq_54528857/article/details/125249712)[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^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文