I am aware of how to plot a line graph on top of scatter plot of the same data but is there a way to bring the line graph forward so it sits on top of the markers rather than behind?
Example code:
import numpy as np
x=np.array([1,2,3,4,5])
y=np.array([1,2,3,4,5])
plt.errorbar(x,y,xerr=0.1,yerr=0.1, fmt="x",markersize=5, color = "orange")
plt.plot(x,y)
This code outputs a scatter graph with a line graph behind it. When you increase the number of data points it becomes harder to see the line behind them all. Other than decreasing the marker size can I bring the line on top of all the points?
I think you are intending to draw things at different levels of z-order on the screen. This is done like such:
plt.plot(x,y, zorder=10)
Note 10 is arbitrarily large and this will likely plot on top of your legend too, so you may need to adjust it!
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