different figures on different canvases using matplotlib? - python

I have written a python script consisting of a canvas with two graphs and a slider, all of which are working as per requirements. I now wish to add a new canvas containing new graphs, the intention is to add a tab or a button so that i can switch from one page to the other, are there any examples someone can provide?
thanks in advance!

Related

How to programmatically delete a specific plot in mayavi

I made a bunch of plots using stuff like
plot_to_delete_later = mlab.points3d(...)
I want to remove this later on, but keep the other plots. I can do this in the GUI (see image), but can't seem to find the trick to doing it in code.
Any help much appreciated.

plot multiple figures in the same window but different "tabs" with matplotlib

I know that you can plot multiple figures in the same window by arranging them in a grid layout. However, I want to plot multiple figures, showing only one at a time and be able to move to the next or previous figure with buttons in the UI. I see arrows in the default UI which makes me think there's a way to do this.

How to remove renderers from a plot?

I'm experimenting with Bokeh server. I have a document with three figures and I'm trying to update two of them depending on the selection I perform on the third. The number of lines to plot in the two figures changes every time.
If I could use multi_line, this would be trivial: I would change the xs and ys in the data_source of the multi_line.
Alas, I need to use multiple scatter plots because multi_line does not support hover and I need it.
So, what I would like to accomplish is to clear the two plots every time I select something in the third, and display the scatter plots corresponding to the new selection.
There are a few possible workarounds, of course (appending scatter points to have a single GlyphRenderer with all scatter plots together, for example, but this would mean using very clunky ways to send the right hover message...). But if it was possible to just clear and update single figures, everything would be cleaner. I couldn't find anything in the docs, however.
I have read the thread you created on the mailing list and this other thread where Bryan says:
Technically, glyph renderers are stored in the .renderers property of
Plots, but I would not recommend rooting around there by hand.
Specifically the "Continuous Updating" notebook I linked earlier has
an example of updating both the data and appearance of an existing
glyph using python and push_notebook. There is not any easy way to remove glyphs at the moment,
other options would be:
recreate a new plot
set the glyph to be invisble
update the glyphs data
So it seems they are the only solutions at the moment

Changing parameters while plotting in python

I have a code for plotting 3d scatterplot in python that updates after every 2 seconds (plot is dynamic). I wish to be able to adjust the values of some of the parameters on line (while plotting happens) based on which the plotting happens. Is it possible to give a textbox along with the plot from which we can take as input the required parameter value based on which this plot will then be subsequently modified?
Matplotlib does not have a textbox (or other text entry) widget. To use a textbox, you would need to embed a matplotlib graph within a separate GUI framework. To do this, decide on the GUI framework you want to use (qt, wx, gtk, or tkinter), and a textbox widget from the gui framework, and then add the plot from matplotlib. This isn't difficult and there are lots of available examples, generally best found for each specific framework you're interested in.
There might also be other pure matplotlib approaches that could work for you, such as using a matplotlib slider widget, or you could directly capture keyboard events, but without knowing exactly what you're going to for, it's hard to say.

How to draw a graph that can indicate the values when the mouse moves to some part of the graph in python and put it on the web page?

I'm writing a web interface for a database of genes values of some experiments with CGI in Python and I want to draw a graph for the data queried. I'm using matplotlib.pyplot, draw a graph, save it, and perform it on the web page. But usually there are many experiments queried hence there are a lot of values. Sometimes I want to know which experiment does one value belong to because it's a big value, whereas it's hard to identify because the picture is small in size. The names of the experiments are long strings so that it will mess the x axis if I put all the experiment names on the x axis.
So I wonder if there is a way to draw a graph that can interact with users, i.e. if I point my mouse to some part on the graph, there would be one small window appears and tells me the exact value and what is the experiment name here. And the most important is, I can use this function when I put the graph on the web page.
Thank you.
What you want is basically D3.js rendering of your plots. As far as I know, there are currently three great ways of achieving this, all under rapid development:
MPLD3 for creating graphs with Matplotlib and serving them as interactive web graphics (see examples in Jake's blog post).
Plotly where you can either generate the plots directly via Plotly or from Matplotlib figures (e.g. using matplotlylib) and have them served by Plotly.
Bokeh if you do not mind moving away from Matplotlib.

Categories

Resources