Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I let my matplotlib plot go beyond the axes?

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:

image generated using matlab

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:

eimage generated with matplotlib

I'm wondering if it is possible to get the same display without having to increase the limits of the y axis.

like image 325
nay Avatar asked Mar 28 '12 16:03

nay


People also ask

How do I move the legend outside the chart in Matplotlib?

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.

How do I maximize a window in Matplotlib?

MatPlotLib with PythonUsing plt. get_current_fig_manager() and mng. full_screen_toggle() methods, we can maximise a plot.


1 Answers

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() 

enter image description here

like image 152
tom10 Avatar answered Oct 04 '22 09:10

tom10