【发布时间】:2021-07-11 18:33:53
【问题描述】:
美好的一天!我在 jupyter 上有这段代码
import pandas as pd
import matplotlib.pyplot
data = pd.read_csv("data.txt")
data.plot(x="Northings", y="Eastings")
data.plot.scatter(x="Northings", y="Eastings")
有没有办法将下面显示的这两个图结合起来?因为这在技术上是一块土地,我必须显示每个坐标的点。还是有更好的方法来解决这个问题?
如果需要这里是“data.txt”中包含的坐标
Station Northings Eastings
1 10001.00 10001.00
2 10070.09 10004.57
3 10105.80 10001.70
4 10110.55 9964.66
5 10117.83 9908.10
6 10062.37 9893.94
7 10007.37 9902.18
8 10003.68 9943.23
【问题讨论】:
-
您可以在
ax = data.plot(x="Northings", y="Eastings")后跟data.plot.scatter(x="Northings", y="Eastings", ax=ax)将两者绘制在同一个ax上。在 matplotlib 中,ax是子图的表示。
标签: python pandas matplotlib scatter-plot