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.
Related
I have built a GUI with matplotlib and it contains several plots of values versus time. Now I need a special plot which just shows if a value is on or off (binary state).
Kinda like a control lamp on an analog control panel. I have 5 of those on/off values and I dont know how to do it the best way.
The "lamps" must be updateable because I stream the data from serial and analyze it in real time in my GUI.
I attached a picture where you see my current GUI. In the bottom right corner is now a bar chart, I tried to visualize the ON/OFF state with a bar, but it didn't work well and I wasn't able to animate it.
So yeah, how could I display 5 values with each an ON/OFF state in that area?
Instead of passing via bar charts I would directly plot a number of rectangles and then dynamically change their color.
You can find the documentation for rectangular patches here: http://matplotlib.org/api/patches_api.html#matplotlib.patches.Rectangle
If you need some pointers on how to animate such a patch have a look here:
https://nickcharlton.net/posts/drawing-animating-shapes-matplotlib.html
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
I have created a little GUI with QT which set's up a single matplotlib figure and axes.
The GUI has controls to change just about everything to do with the appearance of the axes.
Basically, it does this by each widget emitting signals back up to the main frame and it calls the appropriate matplotlib setters on the axes and figure objects.
However, it is possible for the axes (and therefore the image displayed on the FigureCanvas) to change without input from the GUI (e.g. when autoscaling, or adding certain plots which adjust the axes automatically).
In this case, a widget controlling e.g. the limits of the x axis will now be displaying the wrong values.
I would like all the relevant widgets to update when the axes updates....how could I possible achieve this?
I'm thinking that this is a problem that has been solved before - how to enable a two-way communication between distinct objects?
fig.canvas.draw()
time.sleep(1e-2)
whenever anything writes to the plot? however it's hard to help with no code.
Showing an example of how your code is not working would help a lot.
EDIT:
I'll try this again then:
What about getting the state of the plot you are updating? I guess its what #Ajean means by updater method. I know that Artists in matplotlib have an Artist.properties() method that returns all of the properties and values.
I imagine Axes would have a similar method.
A quick look at the matplotlib docs yielded 2 interesting methods of axes:
ax.get_autoscale_on()
and
ax.set_autoscale_on().
ax.set_autoscale_on(False) will prevent plots from updating the state of the axes.
I am working on a python 2.7+matplotlib+tkinter project where I need to plot up to 60 plots on 1 figure (I can show/hide them then by pressing corresponding legend title and do some other interactive stuff). What I want is to get an annotation box on mouse-over event with the label of current plot. I was thinking about text annotation, but I haven't found any ways to do it interactively.
If it is crucial for an answer - I am working with step and scatter figures. I am ready to provide any information needed, for now I just can't think of something necessary to post here (in terms of source code)
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!