Skip to content

Feature request: Adding XClass property to interactively created figures #6743

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
00tau opened this issue Jul 15, 2016 · 12 comments
Closed

Feature request: Adding XClass property to interactively created figures #6743

00tau opened this issue Jul 15, 2016 · 12 comments

Comments

@00tau
Copy link

00tau commented Jul 15, 2016

I need your help. I would like to have the window manager to, well, manage the plots, I am creating interactively during an ipython session. When I create a plot:

from numpy import arange
import matplotlib
matplotlib.use('Qt5Agg')
import matplotlib.pyplot as pt
pt.ion()

x = arange(-10,10,step=.1)
pt.plot(x, x**2)

And check for the window properties, I get nothing.

% xprop | grep CLASS
WM_CLASS(STRING) = " ", " "

Is it possible to configure matplotlib to add some X-window properties to its plots?

I have installed matplotlib using pip.

pip freeze | grep '\(matplotlib==\)\|\(ipython==\)'
ipython==4.2.0
matplotlib==1.5.1

Thanks!

@tacaswell tacaswell added Difficulty: Medium https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues New feature labels Jul 15, 2016
@tacaswell tacaswell added this to the unassigned milestone Jul 15, 2016
@tacaswell
Copy link
Member

I would also love to be able to do this. Any help sorting out how to do this through the GUI toolkits would be great!

@dstansby dstansby modified the milestones: 2.2 (next next feature release), unassigned Feb 5, 2017
@CJ-Wright
Copy link

I'd very much like this as well!

@anntzer
Copy link
Contributor

anntzer commented Jan 10, 2018

Is this not closed by #8394 (i.e. mpl2.1)? (see also #4746 (comment))
Feel free to request a reopen if I missed something...

@anntzer anntzer closed this as completed Jan 10, 2018
@CJ-Wright
Copy link

I still get

$ xprop | grep "WM_CLASS(STRING)"
WM_CLASS(STRING) = " ", " "

when running

In [1]: import matplotlib.pyplot as plt

In [2]: %matplotlib
Using matplotlib backend: Qt5Agg

In [3]: plt.plot()
Out[3]: []

In [4]: 

with matplotlib installed from conda-forge

conda list matplotlib
# packages in environment at foo/mc/envs/dp_dev:
#
matplotlib                2.1.1                    py35_0    conda-forge
ipython                   6.2.1                    py35_0    conda-forge
ipython_genutils          0.2.0                    py35_0    conda-forge

@anntzer anntzer reopened this Jan 10, 2018
@anntzer
Copy link
Contributor

anntzer commented Jan 10, 2018

Well, that's because in your case IPython is setting up the QApplication, not matplotlib. Can you try without IPython?
matplotlib could use setApplicationName to update the QApp's WM_CLASS, but I think it should not (because in general, matplotlib could just be embedded in some other application that does not want WM_CLASS to be fiddled with).
So I'd say the issue (if any) should be reported to IPython.

@CJ-Wright
Copy link

Without IPython it does work. Would it be possible to have this be settable somewhere?

@anntzer
Copy link
Contributor

anntzer commented Jan 10, 2018

It's just a matter of calling QApplication.instance().setApplicationName(...). Again I think this should be IPython's job, because they own the QApp.

@tacaswell
Copy link
Member

@CJ-Wright you can also do that call and set it to what ever you want (such as xpdacq ;) )

attn @Carreau can we do this on the IPython side?

@CJ-Wright
Copy link

@tacaswell The hope was to use Awesome both at xpd and on my local to place the various windows where they needed to go at instantiation time. What is the best way to access the QApplication and such for an individual plot?

@takluyver
Copy link
Contributor

We (IPython) create the QApplication at a point where we don't know that it's for matplotlib, so we can't set the application name to be matplotlib at that point. But if you can find the right place to put it in our code, a PR would be welcome.

@tacaswell
Copy link
Member

@CJ-Wright The QApplication is a process singleton, QApplication.instance() will either return the singleton or None.

Please do not install Awesome on the beamline. If you are going to fill a screen with a fixed set of plots you are probably better off building a Qt Application with embeds all of your plots. That way you only have to maximize it reliably.

@anntzer
Copy link
Contributor

anntzer commented May 9, 2018

Closing, as "not a matplotlib issue" (IMO) per the discussion above.

@anntzer anntzer closed this as completed May 9, 2018
@anntzer anntzer removed the Difficulty: Medium https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues label May 9, 2018
@anntzer anntzer removed this from the needs sorting milestone May 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants