3

I am new to Python and figured out that I can plot color maps the following way:

    import matplotlib.pyplot as plt
    #some image generating code
    
    plot = plt.imshow(image)
    plot.set_cmap(cmap)
    plot.set_interpolation(interpolation_method)
    plt.show()

Where image is an 2-dimensional numpy array in my case. As result I get a beautiful colormap (could not post an image of it since I am new to this platform). Link to my color map: http://s7.directupload.net/images/131017/t9aczkmq.png)

enter image description here

My Question

Is there a way to display the current value of a position/pixel in the upper colormap on mouse hovering? I need to display the actual value (within the array that has been plotted) not the color value.

Additional Question

Is there also a way to add a slicer to the output in order to change the cuts of the color map dynamically (similar to a FITS viewer).

Probably I just need the right modules, but I could not find any fitting my needs yet. Thanks in advance!

Community
  • 1
  • 1
linksfate
  • 101
  • 1
  • 8
  • 1
    I think [this neat little matplotlib tool](http://stackoverflow.com/a/4674445/1460057) could be adapted for your mouse-hovering purposes. As is it's designed to show the x-y coordinates, but it could be changed to output your array values instead. – Brionius Oct 17 '13 at 09:41
  • @Brionius Thanks for your hint, I realized that the tool you mentioned is designed for 2 dimensional plots. It will be difficult for me to adapt it to the 3 dimensional case (color maps), since its an complete different class that I have to deal with called AxesImage generated by plt.imshow(image). Still hoping for more replies or help with the code adaption of the mentioned tool. – linksfate Oct 17 '13 at 10:31
  • 1
    @user2889722 - The "full" tool that Brionius mentioned ( https://github.com/joferkington/mpldatacursor#working-with-images ) does more-or-less exactly what you want. Also, for your second question, are you asking for something like this? http://stackoverflow.com/a/5613068/325565 (Sorry to plug my own answer on both of these, but hopefully it helps, regardless.) – Joe Kington Oct 17 '13 at 11:42
  • 1
    http://stackoverflow.com/questions/14754931/matplotlib-values-under-cursor/14755358#14755358 and http://matplotlib.org/examples/api/image_zcoord.html @JoeKington I see no problem with you plugging your own answers or tool – tacaswell Oct 17 '13 at 16:03

0 Answers0