matplotlib toolbar with control of marker options etc? - python

I'm 100% certain that I have, in the past, seen a matplotlib toolbar with a button which brought up a dialogue allowing the marker styles, line colours etc for the plot to be changed interactively.
This seemed really useful but it's definitely not in the current standard toolbar as documented here and I cannot remember what I was using at the time!
Does anyone have any ideas?!
thanks

As bmu says, it is possible in Spyder (and as far as I know it is so by default). There is an extra button on the toolbar (a green check), as you can see here:

This option must be somewhere in matplotlib. When I do a GUI with matplotlib widget with toolbar, the button for the "figure options" is available. If I just use the plot command, the button is missing.
Edit:
I found http://matplotlib.1069221.n5.nabble.com/How-to-modify-the-navigation-toolbar-easily-in-a-matplotlib-figure-window-td39172.html . If you change your backend in matplotlibrc to Qt4Agg ("backend : Qt4Agg") the button is shown.

Related

Vscode atom dark theme not highlighting tkinter

When I use from tkinter import * in vscode with atom one dark theme, I get no highlights from tkinter functions, though my code is still working.
In the picture, pack(), Tk(), Label and mainloop() is supposed to be highlighted (I know this, cause they are in the actual atom software).
Is there anyway to fix this?
Thanks!
There is nothing wrong with the code editor nor the theme. Its just how most of the theme works. Which part do you expect to be highlighted? All tkinter widgets(Label,Entry,etc.) are classes, and most themes do not have any highlighting for classes. I don't think much themes would have highlighting on class names and function names as its used very frequently.
"In the picture, pack(), Tk(), Label and mainloop() is supposed to be highlighted. Is there anyway to fix this?"
"Is supposed to be highlighted" is wrong words to use, as most themes does not highlight classes.
What usually has highlighting is, all the keywords and keyword arguments and string, etc. Since these are highlighted in your code, its working perfectly. I don't think there are any "special effects" for tkinter, as any theme for python is same as any theme for tkinter.
One way to get your desired effect, is to use a different theme, that actually will highlight classes (maybe monokai or some material themes?). I personally don't prefer alot of theme around, so something like this is perfect. Or the other way is to make or customize your themes, which can mess up the color if you are not sure what your doing.
I'm going to guess this is a problem on tkinters part and not the color theme but if it works on other themes and not one dark pro you can always try to change the exisiting colors using "yo generator code"
css-tricks does a good job showing how to install it: https://css-tricks.com/creating-a-vs-code-theme/
Altough they go through how to create your own theme. But you can always choose to import an existing theme.

Automatically cleaning the plot pane in Python Spyder

I would like to delete all the plots in the plot pane with some code so I can automatically "clear" the interface. I am aware there is a button you can click that deletes them all. However, I would like to avoid having to click manually on the plot pane to delete all the plots generated in the previous runs.
Right now I am already clearing the console and the variable explorer by using (which I got from link):
try:
from IPython import get_ipython
get_ipython().magic('clear')
get_ipython().magic('reset -f')
except:
pass
Now I would like to add there something that also clears the plot pane.
(Spyder maintainer here) It is not possible to remove all plots from the Plots pane using code, sorry.

Distinguish button_press_event from matplotlib zoom and pan

This is an extension of the question asked here. I was not allowed to comment there.
#ImportanceOfBeingErnest provided an excellent answer to distinguish matplotlib button_press_events from zoom and pan clicks by connecting the motion_notify_event. In my experience, this works very well when using a trackpad. However, in practice, when I run my tkinter app with a sensitive mouse, it is difficult to click without also incorporating a subtle motion prior to releasing the button.
Any suggestions? I was considering setting a flag based on the time between the button_press_event and the button_release_event.

How to programmatically select pan/zoom in pyqt/matplotlib navigation

I have a pyqt4 matplotlib application and I would like the figure to start out (default) to the pan zoom mode when the application opens. I can't find any example or clue from the documentation on how to do this programmatically.
Also along this same line how would I enable the shortcut keys in my application (http://matplotlib.sourceforge.net/users/navigation_toolbar.html)
Thanks for any suggestions.
Colin
I had a similar issue and in my case I solved it by using toolbar.zoom():
import pylab
plt.Figure()
thismanager = get_current_fig_manager()
thismanager.toolbar.zoom()
In that case the figure will appear with the zoom tool already selected

Matplotlib's GUI doesn't allow typing in save box?

I've been using matplotlib in python for some time now and I've finally gotten around to asking this question about an issue on my mac. When a plot shows up (after the plot() command, draw(), or show()), I have all the functionality I could want; I can move, zoom, etc. that I didn't do in the code.
When I go to save a figure with the view as I desire the save as box opens up and prompts for a filename. Anything I type appears in the terminal I used to execute the command! Selecting X11 and then typing has same result. Nothing seems to put the keyboards output into that box, but I can paste into the box using the mouse->Paste action and I can select files in the menu to overwrite and it works fine.
What's up with this?
Update:
The problem was wonderfully outlined and now has some solutions posted in this post: Why doesn't the save button work on a matplotlib plot?
Just installed matplotlib 0.99.1 on Python 2.6.2 on Snow Leopard and ran the following code:
from pylab import *
plot([1,2,3])
show()
Then, I fiddled around with the plot for a while and clicked the save button. The save dialog box popped up normally and allowed me to save (and type) fine. This was using the TkAgg backend. However, I did get this error:
2009-12-08 00:40:18.772 Python[728:60f] -deltaZ is deprecated for NSEventTypeMagnify. Please use -magnification.
Which seems to be something to do with Snow Leopard changing some APIs.
Sorry for using typing this as a post instead of a comment, but code tags aren't allowed in comments :(

Categories