I have to translate an image plotting script from matlab to matplotlib/pylab, and I'm trying to achieve the same effect as the matlab image below:
As you can see, the z order of the plots seem to be higher than the z order of the grid, so the markers are not hidden by the axes. However, I can't figure out a way to do the same with my matplotlib image:
I'm wondering if it is possible to get the same display without having to increase the limits of the y axis.
In Matplotlib, to set a legend outside of a plot you have to use the legend() method and pass the bbox_to_anchor attribute to it. We use the bbox_to_anchor=(x,y) attribute. Here x and y specify the coordinates of the legend.
MatPlotLib with PythonUsing plt. get_current_fig_manager() and mng. full_screen_toggle() methods, we can maximise a plot.
To get the marker to show beyond the axes you can turn the clipping off. This can be done using the keyword argument in the plot
command clip_on=False
.
For example:
import matplotlib.pyplot as plt plt.plot(range(5), range(5), 'ro', markersize=20, clip_on=False, zorder=100) 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