I am tying to make a (x,y) scatter plot using numpy. Right now the axes start from (0,0) and extend to align with the range of the data. I need to plot two points which lie on the x=0 line.
Currently it appears the symbols are being drawn before the axes, and subsequently are being truncated by the axes. I would like this to appear on top of the axes. I believe I can do something with a 'label' however I cannot find any method to make this work.
The markers are somewhat visible, however they are a decently crucial component of the visualization. If someone has a work around this would be wonderful.
plot(...,ax=ax) dictates that plt draws the plots into ax , which is an axis instance. This is used when you have several active axis instances.
To make hollow square marks with matplotlib, we can use marker 'ks', markerfacecolor='none', markersize=15, and markeredgecolor=red.
You can turn off the clip flag of the line object created by plt.plot.
import numpy as np
import matplotlib.pyplot as plt
x = np.array([0,1,2,3,4,5,6])
y = np.array([0,2,0,4.5,0.5,2,3])
line = plt.plot(x,y,'o')[0]
line.set_clip_on(False)
plt.show()
To actually make the markers appear on top of the axes, you can use zorder
:
import numpy as np
import matplotlib.pyplot as plt
x = np.array([0,1,2,3,4,5,6])
y = np.array([0,2,0,4.5,0.5,2,3])
plt.plot(x, y, 'o', zorder=10, clip_on=False)
plt.xlim(0, 6)
plt.ylim(0, 4.5)
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