Matplotlib Slider Widget and changing colorbar threshold

K

kevin.khan27

I am currently trying to work on a program that will allow the user to display their dataset in the form of a colormap and through the use of sliders,it will also allow the user to adjust the threshold of the colormap and thus update the colormap accordingly. The best to describe this would be through the use of a picture: ![enter image description here][1]


[1]: http://i.stack.imgur.com/1T9Qp.png


This image shows how the colorbar should look before (the image on the left) and after (the image on the right) the adjustment. As the threshold values of the colrobar are changed, the colormap would be updated accordingly.

Now I am mainly using matplotlib and I found that matplotlib does support some widgets, such as a slider. However the area I need help in is devisinga piece of code which will update the colorbar and colormap (like the way shown in the picture above) when the slider is adjusted. I was wondering if anyone has done this before and might have a piece of code they would be willing to share and might have pointers as to how this can be achieved.
 
M

matt.newville

I am currently trying to work on a program that will allow the user to display their dataset in the form of a colormap and through the use of sliders, it will also allow the user to adjust the threshold of the colormap and thus update the colormap accordingly. The best to describe this would be through the use of a picture: ![enter image description here][1]





[1]: http://i.stack.imgur.com/1T9Qp.png





This image shows how the colorbar should look before (the image on the left) and after (the image on the right) the adjustment. As the threshold values of the colrobar are changed, the colormap would be updated accordingly..



Now I am mainly using matplotlib and I found that matplotlib does supportsome widgets, such as a slider. However the area I need help in is devising a piece of code which will update the colorbar and colormap (like the way shown in the picture above) when the slider is adjusted. I was wonderingif anyone has done this before and might have a piece of code they would be willing to share and might have pointers as to how this can be achieved.

An example using wxPython and matplotlib:
http://newville.github.com/wxmplot/imagepanel.html#examples-and-screenshots

might be close to what you're looking for. This does allow the user to re-scale the intensity of the colorbar and the corresponding map, as well as change colormaps, smoothing, and explicitly set intensity ranges. This image display frame might cover most of what you need -- if not, I'd be interested to hear what else might be useful.

The specific code building the control is at https://github.com/newville/wxmplot/blob/master/lib/imageframe.py

Hope that helps,

--Matt Newville
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top