0

Good day! I have this code on 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")

Is there a way to combine these two plots shown below? Since this is technically a plot of land and I have to show the points of each coordinates. Or is there a better way to approach this?

enter image description here

If needed here are the coordinates contained in the "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
1
  • 2
    You could do ax = data.plot(x="Northings", y="Eastings")followed by data.plot.scatter(x="Northings", y="Eastings", ax=ax) to plot both on the same ax. In matplotlib an ax is a representation for a subplot. Commented Apr 16, 2021 at 19:15

1 Answer 1

2

You should be able to use matplotlib to create an Axes object, then pass that Axes object to each of your plotting methods like so:

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)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.