I am rendering very large X,Y,Z scientific datasets in the lateral plane and would like to click on the results to obtain greater textual detail about the area chosen by mouse-click.
So, for example, imagine a scientific dataset which is rendered as a filled contour plot and there is a bright spot. I would like to click on that spot to obtain a link or other textual information.
This would necessitate having another plane that would provide attribute information.
I would be most appreciative for any direction that others have used in similar cases. I expect this problem has been solved previously so I would prefer not reinventing the wheel.
Sounds like you'll need to dive into matplotlib's event handling code. This allows you to take some action when you click on a piece of the plot, or press a key, or whatever. Here are the example programs on the matplotlib site that have to do with event handling.
Related
I'm wanting to create an animated and interactive skymap using plotly, and I like scatter_geo (https://plotly.com/python-api-reference/generated/plotly.express.scatter_geo) but it seems to only allow for the use with the Earth (hence "geo"). I like the functionality in general of scatter_geo, I just need to be able to map it to sky coordinates (because mapping to Earth's lat/long gets annoying with the Earth's rotation) and to be able to have an image of my choosing as the backdrop (I'm wanting to use the Planck image of the MW). Oh, and it needs to be able to do the Mollweide projection.
I'm basically trying to create something like this animation of Fast Radio Bursts (https://vimeo.com/146295242) but with different data and with more interactivity, and I think plotly has the features I need for that - if I can map my sources to the sky, that is!
Does anyone know either how to make scatter_geo do this, or an alternative I can use? I have not yet been able to find one. It doesn't need to be a plotly function, but I would prefer to stick with Python.
Cheers!
...not sure how you create the flashes, but for the rest have a look at EOmaps
It can do all the stuff that .scatter_geo does, it should be able to handle any projection that pyproj can handle and gives you a map in Mollweide projection if you want :-)
... and on top of that you can interact with the map and assign assign any callbacks you like.
BackGround
I'm making this software right plot data as boxplots and scatter plots. To make the graph more informative and clear I wanted the user to be able to drag-create a textbox on top of the figure if they wanted to add notes. This way when people share the figure it can be explained through these notes.
Current Approach and Problem
I have used annotate function to create a textbox in the upper right corner of the screen to tell the user how many data points have been used, but there are of few problems with this approach.
This is the code I used to create a text box to tell the user how many data pts there are.
self.axes.text(.98, .98, 'Number of Data Points: {}'.format(len(self.cleanedY)),
verticalalignment='top', horizontalalignment='right',
transform=self.axes.transAxes,
color='black', fontsize=9.5)
Extensive input that would have to be asked of the user. This includes the position coordinates, the actual text box, type of alignment.
The only way I know how to collect this info would be to create a Qdialog window prompting for all these inputs, which would be too cumbersome.
User doesn't have much control over being able to freely position the textbox and would have to know exact decimals to position the text box on the figure.
This is incredibly inefficient and inflexible. I want a way for the user to EASILY create these notes on the plot figure.
TLDR: Is there any way to develop a simple drag and create textbox option on a plot figure?
I'm not sure if this is what your looking for, but i found this similar example online. It doesn't allow for user to create a textbox, but adds annotations to the figure and allows you to move them around.
here's the link
http://scipy-cookbook.readthedocs.io/items/Matplotlib_Drag_n_Drop_Text_Example.html
I am plotting some scalar data as a contour plot with matplotlib.contourf. On top of it, I am plotting some vector data with matplotlib.arrow. The basic plot has come along OK, but now I need to put a box on the plot with a default-size arrow plus the data value to which it corresponds, so the viewer will know what kind of scale he is looking at. For instance, I need a box with a horizontal arrow of some length and, below that, some text like "10 cm/sec".
First, if anyone can give me a simple approach to this, I would be grateful.
Second, the approach I have tried is to do the contour plot, then plot the arrows, then add a rectangle to the plot like so:
rect=pl.Rectangle((300,70),15,15,fc='white')
pl.gca().add_patch(rect)
and then, finally, put my scale arrow and text on top of this rectangle.
This isn't working because the rectangle patch covers up the contour, but it doesn't cover up the arrows in the plot. Is there a way to move the patch completely "to the front" of everything else?
Got it. Using pylab.quiver and pylab.quiverkey functions. quiver produces a nice vector field with just a few lines of code, and quiverkey makes it easy to produce a scaling vector with text. And, for some reason, the arrows plotted with quiver are indeed covered by my rectangle, so it is easy to make the scaling arrow very visible. There are still some mysteries in all of this for me. If anyone wants to try to clear them up, would be much obliged. But I have a way now to do what I need in this instance.
I'm using Qt4.8 via PyQt in a Python application. Everything is working fine :-) But I need to present the user with some kind of curve editor, these widgets commonly found in image editing programs for adjusting contrast or color or stuff like this.
So I basically need a widget, which displays a curve with axes and stuff like that and the user should be able to "drop" points onto the curve and adjust the curve.
I thought I could use matplotlib for this, but as far as I see it doesn't provide any "editing" capability...
I wrote a Qt curve editor with OpenGL widget, you can try it.
http://www.shannap.com/qt-curve-editor-en.html
What you probably want is the qwt toolbox. It's like matplotlib for Qt.
http://qwt.sourceforge.net/
It has all kind of neat funcitonality for plots and graphs. Though you won't get the exact thing you need without creating your own subclasses.
You can do curve editor with matplotlib. See for example this YouTube video: http://www.youtube.com/watch?v=nCv_MhaeFo8
And then check the event handling examples: http://matplotlib.sourceforge.net/examples/event_handling/index.html
Matlab and Mathematica both have features that allow the user to manipulate the contents of a plot using, say, a slider. For example, if you have a set of 3D data, it is easy to make a small program that lets you view 2D slices of a set of 3D data where the user can slide a slider to move through which slice is displayed. Is there anything in python that allows for this sort of capability without tons of effort? For example, is it possible to do such a thing in matplotlib, or something similar? I
Thanks.
My first thought would be Mayavi, which is great for data visualization, especially in 3D. It relies on VTK. It is included in the Enthought flavoured version of Python, together with Chaco for 2D plotting. To get an idea, look at Travis Vaught's nice screencast in Multidimensional Data Visualization in Python - Mixing Chaco and Mayavi.
It also possible to embed basic interactive functionalities (like slider) to Matplotlib, see matplotlib.widgets and the widget examples.
Finally, you can use rpy (or better, rpy2) and benefit from the R interface.
Have you looked at Vtk? http://www.vtk.org/ One of their demos does exactly what you're asking.
In principle, you can do it by help of MathGL. This is cross-platform GPL library for plotting.
For each mouse clicks you can find the x,y,z position in plot or clicked object and adjust (replot) some other information correspondingly. However you should handle mouse clicks by yourself (for example, using PyQt).
Another option is to use python within the SAGE computation interface/environment, which has the #interact command (see here for specific help on this command)