Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/358.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 在matplotlib中将散点图覆盖到线图_Python_Pandas_Matplotlib_Scatter Plot - Fatal编程技术网

Python 在matplotlib中将散点图覆盖到线图

Python 在matplotlib中将散点图覆盖到线图,python,pandas,matplotlib,scatter-plot,Python,Pandas,Matplotlib,Scatter Plot,你好!我在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") 有没有办法将下面显示的这两个图合

你好!我在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”中包含的坐标


您应该能够使用matplotlib创建一个
对象,然后将该
对象传递给每个打印方法,如下所示:

import pandas as pd
import matplotlib.pyplot as plt

data = pd.read_csv("data.txt")

fig, ax = plt.subplots()
data.plot(x="Northings", y="Eastings", ax=ax)
data.plot.scatter(x="Northings", y="Eastings", ax=ax)

您可以执行
ax=data.plot(x=“Northings”,y=“Eastings”)
然后执行
data.plot.scatter(x=“Northings”,y=“Eastings”,ax=ax)
以在同一
ax上同时进行绘图。在matplotlib中,
ax
是子批次的表示。
import pandas as pd
import matplotlib.pyplot as plt

data = pd.read_csv("data.txt")

fig, ax = plt.subplots()
data.plot(x="Northings", y="Eastings", ax=ax)
data.plot.scatter(x="Northings", y="Eastings", ax=ax)