Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 22:50
    has2k1 edited #19071
  • 18:46
    jklymak labeled #19070
  • 18:45
    jklymak commented #19070
  • 18:21
    has2k1 edited #19071
  • 18:20
    has2k1 edited #19071
  • 18:18
    has2k1 opened #19071
  • 17:26
    ianhi synchronize #19059
  • 16:54
    jklymak closed #19069
  • 16:54
    jklymak commented #19069
  • 16:51
    jklymak labeled #19069
  • 16:48
    jklymak edited #19069
  • 15:27
    anntzer commented #19066
  • 15:03
    anntzer commented #19066
  • 14:40
    iamz33 opened #19070
  • 14:26
    Andrej-BG edited #19069
  • 13:36
    Andrej-BG opened #19069
  • 08:16
    Dreamingnoisy labeled #19068
  • 08:16
    Dreamingnoisy opened #19068
Antony Lee
@anntzer
we could always switch to backend_agg...
(or whatever is relevant)
Thomas A Caswell
@tacaswell
also, I am 100% sure we have users abusing this
Antony Lee
@anntzer
ok, but that's actually warnable
set a flag on close, and warn if people try to ressucitate stuff
Thomas A Caswell
@tacaswell
That will hopefully bring some people out of the woodwork to comment on why this is happening :-p
Antony Lee
@anntzer
actually I don't even think saving is going to be a problem, at worse we'll have to sprinkle a few sip.isdeleted here and there, but the actual rendering is done by something fully managed by ourselves
fwiw tk and gtk3 both call destroy on the widgets on manager destruction
indeed a quick try suggests only qt supports ressucitation currently (and per the above that's basically an implementation choice)
Jody Klymak
@jklymak

@tacaswell @anntzer: So we seem to have three alternatives:

import matplotlib as mpl
fig, axs = mpl.subplots()

or

import matplotlib.figure as mfigure
fig = mfigure.figure()
axs = fig.subplots()

or

import matplotlib.figwrapper as mfigwrap
fig, axs = mfigwrap.subplots()
Number 2 seems strained. Number 3 is going to be hard to convince most folks that its better than matplotlib.pyplot
Thomas A Caswell
@tacaswell
and I do not think that number 1 is a valid option due to the implicit configuration and global state issues
Jody Klymak
@jklymak
OK, and sorry if I'm being dumb, but I don't understand why thats a problem? What wires can get crossed?
I'm definitely not arguing with you - I just am ignorant
Thomas A Caswell
@tacaswell
Jody Klymak
@jklymak
OK, I find that very confusing, because the only way I know to switch the backend is matplotlib.use
Thomas A Caswell
@tacaswell
Matplotlib has two (ish) faces, one is very application like (pyplot which "just works" guesses the right GUI etc) and the library side (which you have be more explicit with)
Antony Lee
@anntzer
it's not obvious to me we absolutely do not want to move that to the toplevel; I guess I sort of see your point but heh
Thomas A Caswell
@tacaswell
if you have not imported pyplot yet mpl.use only sets a value in rcparams
and we do some sys.modules sniffing to sort out if you have already imported pyplot and we should try to be more helpful
Jody Klymak
@jklymak
OK, but none of that happens until a call to *.figure()?
Thomas A Caswell
@tacaswell
no, it is called on import of pyplot
but it does not lock its self until you make the first figure
Jody Klymak
@jklymak
OK, so you are saying importing pyplot does a bunch more than importing matplotlib, and that that extra state if imported by matplotlib may cause problems for folks who just want to use matplotlib in an embedded GUI
Thomas A Caswell
@tacaswell
yes
if anything we probably want to import fewer things in the __init__.py not more
There is another option which is
from matplotlib.backends.backend_qt5agg import figure, subplots
fig, ax = subplots()
Jody Klymak
@jklymak
ha, well thats definitely explicit
Thomas A Caswell
@tacaswell
which we almost have already
Jody Klymak
@jklymak
While figwrap is definitely a terrible name, a module like that would nicely separate the gcf scaffolding from the pyplot implicit axes-state, which are different things. We can give people a guiapp without it having all the implicit features of pyplot.
import matplotlib.figgui as mfig

fig, axs = mfig.subplots()
Isn't too bad and gives us the separation we want. We could even do mfig.use('backendname')
Thomas A Caswell
@tacaswell
Currently we also rely on the global registry for IPython to identify stale figures and ask for them to be re-drawn exactly once right before we return control to the user
we could always do the non-IPython method and just always call draw_idle when the figure gets marked as stale
Jody Klymak
@jklymak
I think my (fuzzy) conception wrapfig or figgui would be exactly what we currently have, and would even be interoperable with pyplot. It would just be a more restrictive version of pyplot that would protect the user from all the other things we don't like about pyplot, but keep all the same figure management.
Thomas A Caswell
@tacaswell
the easiest way to get that would be to put figure and subplots in a simple namespace and then have people do
from matplotlib.pyplot import restricted as plt
Jody Klymak
@jklymak
Sure... But that is harder to explain to people than: 1) here is the module you need to make a GUI figure, or figure you will save somehow 2) here is a different module that tracks what axes you are on and draws to that.
My point is that I think they are separate functionalities that we have mushed into one thing called pyplot.
Thomas A Caswell
@tacaswell
actually, I think the super explicit version works today...I have had a fact incorrect in my head, for approximately forever ...
Thomas A Caswell
@tacaswell
on one of our channels there was a report about set_window_title not working right with notebook
the workaround is to do fig.set_label and I have a still hacky, but better fix coming
Thomas A Caswell
@tacaswell
Elliott Sales de Andrade
@QuLogic
Fix v3.3.x CI: #18850
Thomas A Caswell
@tacaswell
merged
matrixbot
@matrixbot
physkets Hi! When I set useMathText=True in AXES.ticklabel_format(), and savefig as a PGF plot,
it gets stuck later when compiling with pdflatex, saying:
 ! Missing } inserted
<inserted text>
                }
l.277 ...selectfont \(\displaystyle \times{10^{−
                                                  1}}{}\)}%
! Extra }, or forgotten $.
l.277 ...lectfont \(\displaystyle \times{10^{−1}
                                                  }{}\)}%
Antony Lee
@anntzer
I think that's basically tracked by matplotlib/matplotlib#18826
Tim Hoffmann
@timhoffm
pyplot currently does two things: 1) Setup a backend and manage active figures 2) Provide the state-based ("current figure/axes") API. It would be good to separate these and move 1) to a dedicated module. Exact naming etc. t.b.d.
Antony Lee
@anntzer
actually, thinking about it again I guess I can accept exposing subplots()/subplot_mosaic() in the new namespace as they always return a new figure instead of operating on an already existing ("current") figure
Jody Klymak
@jklymak
Out of ignorance, though, I’m still not sure that this can’t be done at the top level namespace. @tacaswell says it would cause problems, but I’m not entirely sure I understand why. But I’ve never embedded a GUI.