I'm trying to plot scatter with over lined line plot. I have two sets of data and if I plot both of them as scatter plots it works, but if I try to plot the second one as a line graph (connected scatter plot), it won't even show.
plt.scatter(column1,column2,s=0.1,c='black')
plt.plot(column3,column4, marker='.', linestyle=':', color='r',)
(I tried using plt.scatter, I tried changing the markers and linestyle, tried without these as well and I still can't get it to work, I sometimes get the dots, but once I want them to be connected they disappear or nothing happens.)
plt.gca().invert_yaxis()
plt.show()
That's what I get: Plot 1
matplotlib
simply overlays plot commands in the called order as long as you do not create a new figure
.
As an example, try this code:
import matplotlib.pyplot as plt
import numpy as np
np.random.seed(19680801)
N = 100
x = 0.9 * np.random.rand(N)
y = 0.9 * np.random.rand(N)
plt.scatter(x, y, c='green')
plt.plot(np.linspace(0, 1, 10), np.power(np.linspace(0, 1, 10), 2), c= "red", marker='.', linestyle=':')
plt.gca().invert_yaxis()
plt.show()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With