Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 18:04
    jklymak closed #19064
  • 18:04
    jklymak commented #19064
  • 17:58
    Mastiff37 commented #19064
  • 17:27
    jklymak commented #19064
  • 17:10
    Mastiff37 opened #19064
  • 17:10
    Mastiff37 labeled #19064
  • 16:56
    justingruenberg commented #19058
  • 16:50
    alexiscoutinho edited #19054
  • 16:30
    anntzer commented #19052
  • 15:56
    brunobeltran edited #18544
  • 15:49
    brunobeltran opened #19063
  • 15:43
    tacaswell commented #19052
  • 15:40
    brunobeltran synchronize #18544
  • 15:31
    tacaswell commented #19058
  • 14:44
    tacaswell labeled #13306
  • 14:43
    tacaswell ready_for_review #13306
  • 14:43
    tacaswell commented #13306
  • 14:43
    tacaswell milestoned #13306
  • 14:43
    tacaswell demilestoned #13306
  • 13:24
    apacha commented #19000
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.
Jody Klymak
@jklymak

I guess the issue is that we do import matplotlib everywhere so adding to matplotlib.__init__ is problematic. But we don't have to do that. If we rewrote all of matplotlib, would we really have every submodule import the parent, or would we have made a matplotlib.common and imported that?

It seems from a user's perspective that having one import that gives the way into the package is a nice spelling - I almost only ever import pyplot, and then I only use it to make a figure and/or axes.

Making a new namespace is one way to do that, but

import matplotlib
fig, axs = matplotlib.subplots()

would be super intuitive.

matrixbot
@matrixbot
physkets Antony Lee (Gitter): I'm not sure it is that. I already do declare the appropriate unicode replacement. This is something else.
Antony Lee
@anntzer
please provide a full repro, then
matrixbot
@matrixbot
physkets repro?
Jody Klymak
@jklymak
... on discourse, not here
Reproducible example
matrixbot
@matrixbot
physkets oh reproducible.... okay, ya, I'll make a new topic there
matrixbot
@matrixbot
physkets Sorry, I made the images too small
Antony Lee
@anntzer
I think you need \DeclareUnicodeCharacter{2212}{\ensuremath{-}}, not $-$?
otherwise likely you have $ wrapping one another...
matrixbot
@matrixbot
physkets Antony Lee (Gitter): Oh My God! Thank you so much!!!
If I remember correctly, I did copy what I was using, from the header of the pgf file, a long time ago. It now says:
\usepackage[utf8]{inputenc}\DeclareUnicodeCharacter{2212}{-} Should that be updated to what you wrote?
Antony Lee
@anntzer
yes
matrixbot
@matrixbot
physkets Oh, you did say that in that issue you linked to.
Thomas A Caswell
@tacaswell
The way Python's import system works if you import foo.bar than foo/__init__.py will be executed. Anything we do in __init__.py is something the user can never opt-out of
Jody Klymak
@jklymak
Sure but instatiating a pointer to None and then only populating it if the user calls mpl.figure() seems possible?
Tim Hoffmann
@timhoffm
Yes, I think it's possible to defer any creation of state to the creation of the first figure.
Thomas A Caswell
@tacaswell
but then you have indeterminacy if the state has been created