Note that there are some explanatory texts on larger screens.

plurals
  1. POmatplotlib pan-zoom colorbar axis
    primarykey
    data
    text
    <p>Matplotlib allows for the creation of nice interactive plots. Dragging while holding the left mouse button allows us to pan the plot left-right or top-bottom. Dragging while holding the right mouse button allows us to zoom on the axis parallel to the direction that you drag the plot. I would like to be able to replicate this sort of behavior by dragging on the colorbar. When the mouse is over the colorbar, the little hand appears, but dragging does nothing. It would be nice if dragging along the colorbar with the left mouse button would change the colorbar range (keeping the difference between cmin and cmax constant) and dragging with the right mouse button would change the difference between cmin and cmax (e.g. zoom) Is there any way for this to be possible?</p> <p>Thus far, it looks like the solution will involve some form of callback function registered by <code>fig.canvas.mpl_connect('button_press_event', func)</code>. e.g.:</p> <pre><code>def onclick(event): tb = plt.get_current_fig_manager().toolbar print repr(tb.mode),bool(tb.mode) if tb.mode != '': print 'button=%d, x=%d, y=%d, xdata=%f, ydata=%f'%( event.button, event.x, event.y, event.xdata, event.ydata) cid = fig.canvas.mpl_connect('button_press_event', onclick) </code></pre> <p>And it looks like the events are described <a href="http://matplotlib.org/api/backend_bases_api.html#matplotlib.backend_bases.FigureCanvasBase.mpl_connect" rel="nofollow">here</a>, but I can't seem to figure out how to know if I'm on the colorbar or the rest of the plot.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload