matplotlib interactive alteration of line properties - python

I've been looking for a graphical / ipython console based means to turn lines on and off in a 2D graph generated with matplotlib, but I haven't found anything thus far.
Does anyone know a way to do something like this? What I have in mind specifically is incorporated in MATLAB, and can be seen here:
http://matlab.izmiran.ru/help/techdoc/creating_plots/plot_to5.html
All of the check boxes in the plot browser window will turn the lines on and off; their properties can also be altered graphically in another dialogue box. For now, I've been clicking on the properties button, and setting linetype to none, but this is cumbersome for a graph with many lines...

Thanks Vadim for your answer - you're right that the widgets provide an example with this functionality - to an extent. The example you provide doesn't give the graphical feedback I had in mind; instead, the widgets example closest to my request is actually check_buttons.py (see: http://matplotlib.org/examples/widgets/check_buttons.html)
Here, a side-box of labelled check buttons can be created, where upon clicking the checked buttons, it will turn the lines on and off - see the figure below. I suppose this could be built up into something along the lines of a plot browser like in matlab, but would require additional work to incorporate simple changes to the line style, etc.
I am still interested to know if someone has already done all of the work in making such functionality available; if not, I will post my best attempt when I get around to it.
plot_browser
I don't have sufficient rep points to add the image inline; my apologies.

Yes, there exists module named matplotlib.widgets. There are some example here. It allows you to do exactly what you asked for (source):

Related

PySimpleGui - window size doesnt autofit dynamically

I'm trying to auto resize a PySimpleGUI window.
consider the following:
import PySimpleGUI as sg
CommandWindow = sg.Multiline(size=(80,20),echo_stdout_stderr=True,key=OUTPUT_KEY,visible=False)
window = sg.Window("FOO", layout=[CommandWindow],element_justification='center')
when the event is triggered, a sg.Multiline element's visible trait is updated to True.
then I refresh the window and it resizes (expands) to fit the element shown inside.
when I change the visible trait to False again, the window maintain its size and doesnt shrink back.
the execution as follows:
window[OUTPUT_KEY].update(visible=True/False)
window.refresh()
I think this will perhaps be the best answer I can come up with since StackOverflow answers do not age well, especially for the PySimpleGUI project which is ever-evolving.
The Demo Browser utility is made specifically to help answer questions like this. Of course, the documentation should also be used (PySimpleGUI.org).
The Demo Programs serve many purposes. One is to show specific techniques. The Demo Browser is a way for you to quickly and easily search, edit, and execute this code.
The attached screenshot is what I see when searching for "shrink" using this tool (as of Aug 2022...). The first item answers this specific issue. Maybe I got lucky? "I would rather be lucky than good". The docs and tools provided with PySimpleGUI are the best place to turn for questions rather than SO. They'll be the most accurate, the most up to date, and are part of the project itself.
Good lucky Jedi!
what solved it for me, Thanks to #Mike from PSG,
is using:
sg.Pin(,shrink=True)
as shown in docs: https://www.pysimplegui.org/en/latest/call%20reference/#layout-helper-funcs

How to remove borders on Tkinter buttons & frames?

I am currently building a simple app to encrypt files using AES encryption in python but the biggest downside of using Tkinter is the look of the UI. I did some research and found examples of what I want but do not know how to recreate it. (Example)
My problem is that when I replace buttons with images (like the OP of the Reddit post said he did in order to have a decent looking UI) I end up with an ugly bar of grey. (Image of the button)
I also want to remove the same type of bar with frames so if you have the answer for specifically that it would still be appreciated.
Support for for styles and themes has existed in tkinter for some time. A theme being a collection of styles for different widgets.
You can read more about style and themes here.
To the best of my knowledge, the standard widgets to not support rounded corners. All widgets have rectangular shapes.
You might be able to create something like that using a Canvas, but it would be a significant amount of work.
A more relevant point is that it might confuse your users if you don't reproduce the way the standard controls work.
UI elements are standardized for the same reason the controls in a car are; once you know one of them you can use all of them.

How can I manually interact with a custom Graph Editor in Maya (Using Python)

I've been practicing my python/mel coding and have been interested in creating a graph editor. I did a lot of research online and found this previous question (How can I keep an object selected in the outliner after physically deselecting it in the 3d view?) that helped me out a lot. However, I am having an issue were I cannot manually edit the curves that are generated. I'm unsure as to why this is happening and can't seem to find any clear documentation. (I've looked up the command references for mel/python in Maya but it doesn't seem to have detailed explanations).
To be more clear, my goal is to use my mouse to move the curve information based on keyframe data (Exactly like Maya's own graph editor). I am using the code solution from the previous example (edited to include my own selection connections and frame conventions).
So after some research I decided the easiest thing was to use Maya's own graph editor within my interface
# GRAPH ROW
# Section for the graph editor to allow the user to change attributes
paneLayout( configuration='single', parent=form, width=620, height=320 )
# queries Maya's graph editor and places it within my frame
graph = cmds.getPanel(scriptType='graphEditor')
cmds.scriptedPanel( graph[0], e=True, unParent=True)
cmds.scriptedPanel( graph[0], e=True, parent=frame1)

How to open a window by clicking on a specific point on a chart?

I have the task to build up an interactive plot which i have already done more or less. But now I am supposed to give specific information about a point in a graph for example P(8|6) and by clicking on this point there should open a new window with specific information. Adding the information to the window wont be the problem but the window itself. How I can open a window by clicking on this specific point (keep in mind, it is no button since it changes from graph to graph)?
The answer is qwt! Study the documentation and examples for that project like your life depended on it, and you will find exactly what you need.
I wrote up a pretty complete example a year or so ago; but it is in C++; converting it to python should be pretty straight forward.
https://github.com/peteristhegreat/qwt_generic
Hope that helps.

Bokeh Gmap hide/unhide background

I have a Bokeh image made with patches onto a google map as background.
http://giove.units.it:5000
Is there a tool (or javascript code) to hide/unhide the background ? and is there way to save in png the background too ?
thanks
As of Bokeh 0.11.1 (and soon to be 0.12) there is no mechanism to hide the map portion. It seems like a reasonable feature though, an probably not terribly difficult to implement. I encourage you to submit a feature request on the project's GitHub issue tracker.
There might be some roundabout ways to do what you want currently, by setting map_options from a JS callback or something. But figuring that out would take discussion and experimentation and iteration, and StackOverflow is not very good for that kind of thing. I encourage you to bring the question to the project's public mailing list where more of a back-and-forth dialogue is possible.

Categories