| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
There was a problem hiding this comment.
Looks great asside frm the small formatting issues! Thanks!
Sorry, something went wrong.
| Add any :class:`~matplotlib.artist.Artist` to the figure. | ||
|
|
||
| If the added artist has no transform set to it previously, its | ||
| transform will be set to ``transFigure``. |
There was a problem hiding this comment.
figure.transFigure?
Sorry, something went wrong.
There was a problem hiding this comment.
I think ideally this docstring would be numpydoc compliant. Most of figure.py is not, but can't hurt to make this new one compliant.
Sorry, something went wrong.
| If the added artist has no transform set to it previously, its | ||
| transform will be set to ``transFigure``. | ||
|
|
||
| Use ``add_artist`` only in cases you really need to add an artist to |
There was a problem hiding this comment.
This has a lot of "only" and "most often". Note a big reason to do this is if you don't want the artist in the tighbbox of the axes. Maybe:
Usually artists are added to axes objects using :meth:matplotlib.axes.Axes.add_artist, but use this method in the rare cases that adding directly to the figure is necessary.
Sorry, something went wrong.
|
|
||
| In case the added artist has no transform set previously, it will assume | ||
| set it the figure transform (``fig.transFigure``). | ||
| This new mathod may be useful for adding artists to figures without axes or to |
There was a problem hiding this comment.
method
Sorry, something went wrong.
| fig.add_artist(circ) | ||
|
|
||
| In case the added artist has no transform set previously, it will assume | ||
| set it the figure transform (``fig.transFigure``). |
There was a problem hiding this comment.
Broken sentence
Sorry, something went wrong.
| transform set to it previously, its transform will be set to | ||
| ``figure.transFigure``. | ||
| clip : bool, optional, default ``False`` | ||
| An optional parameter ``clip`` may be used to determine whether the |
There was a problem hiding this comment.
Shorter: „Determines whether ...“
Sorry, something went wrong.
|
It doesn't seem like the failing test is due to anything commited here. |
Sorry, something went wrong.
Sorry, something went wrong.
|
Rebasing didn't change anything. |
Sorry, something went wrong.
|
try running boilerplate.py and commit the results. On the plus side, this means that test is working! On the down side it is a bit annoying.... |
Sorry, something went wrong.
|
I suspect what happened is that between when the tests on #11204 ran and it got merged something that changed pyplot got merged into master. |
Sorry, something went wrong.
There was a problem hiding this comment.
I think the 'clip' kwarg can be removed.
Sorry, something went wrong.
| The artist to add to the figure. If the added artist has no | ||
| transform set to it previously, its transform will be set to | ||
| ``figure.transFigure``. | ||
| clip : bool, optional, default ``False`` |
There was a problem hiding this comment.
I don't understand this parameter for a Figure artist; I would not expect that anything could be drawn outside the Figure patch boundaries. I did a little test that seemed to confirm that even with the ps backend, so there is white space around the figure, a Figure.figimage is clipped, regardless of whether get_clip_on() returns True or False.
Sorry, something went wrong.
There was a problem hiding this comment.
What if you do savefig(bbox_inches='tight')? If clipping is on, it'll clip the tight bbox (I think, or maybe it will when some of my PRs on this get merged). If clipping is off the figure will get larger...
Sorry, something went wrong.
| @@ -0,0 +1,16 @@ | |||
| Figure has an `~.figure.Figure.add_artist` method | |||
There was a problem hiding this comment.
"an" -> "a"
Sorry, something went wrong.
There was a problem hiding this comment.
The ~ cuts it to just add_artist, so 'an' is correct here.
Sorry, something went wrong.
| @@ -0,0 +1,16 @@ | |||
| Figure has an `~.figure.Figure.add_artist` method | |||
There was a problem hiding this comment.
The ~ cuts it to just add_artist, so 'an' is correct here.
Sorry, something went wrong.
| ------------------------------------------------- | ||
|
|
||
| A method `~.figure.Figure.add_artist` has been added to the | ||
| :class:`~.figure.Figure` class, which allows to add artists directly to a |
There was a problem hiding this comment.
allows to add artists -> allows artists to be added
Sorry, something went wrong.
| ---------- | ||
| artist : `~matplotlib.artist.Artist` | ||
| The artist to add to the figure. If the added artist has no | ||
| transform set to it previously, its transform will be set to |
There was a problem hiding this comment.
set to it previously -> previously set
Sorry, something went wrong.
| artist.set_transform(self.transFigure) | ||
|
|
||
| if clip: | ||
| artist.set_clip_path(self.patch) |
There was a problem hiding this comment.
This should always be passed, unless you can guarantee that the clip path was always False, or it should default to None if you really don't want to change the existing setting. That is, assuming it has an effect (re. @efiring's comment).
Sorry, something went wrong.
There was a problem hiding this comment.
Actually, I think I misread this, and thought clip was being passed down. Since it isn't, this doesn't really matter.
Sorry, something went wrong.
|
The difference between clip=False and clip=True can be observed when saving the figure with the bbox_inches="tight" option. Default (i.e. clip=False) import matplotlib.pyplot as plt
plt.rcParams["figure.figsize"] = (3,2)
plt.rcParams["figure.dpi"] = 72
fig, ax = plt.subplots()
c = plt.Circle((0,0),0.2)
fig.add_artist(c)
fig.savefig("test1.png", facecolor="azure", bbox_inches="tight")
With clip=True: If people think this should be handled differently, I'm happy to change it. Unfortunately I'm not quite sure I understood the comments above. @efiring and @QuLogic, could you explain a bit more in detail what you have in mind concerning the clip option? |
Sorry, something went wrong.
My potential objections have been shown to be invalid.
|
This seems done, and can/should go in for 3.0. Needs a rebase and another approver... |
Sorry, something went wrong.
|
I rebased. There was still a comment by @QuLogic, which I did not fully understand; so maybe he wants to take another look and either approve or clarify that issue? |
Sorry, something went wrong.
|
I needed to rebase yet again; now there is an error from circle/ci saying document not included in any doctree. |
Sorry, something went wrong.
|
Yeah, unfortunately while the release candidate for 3.0 is cut, the whats-new should be moved to the actual whats-new.rst. |
Sorry, something went wrong.
|
Now I get Analysis Failed (could not build the merge commit), but I looking at the log, I don't see what's failing (which is probably due to me not knowing what to look for in this long log file). |
Sorry, something went wrong.
| assert not(fig.get_constrained_layout()) | ||
|
|
||
|
|
||
| def test_add_artist(): |
There was a problem hiding this comment.
You may want to (but don't have to) use #11408 for the test, which has the benefit of directly taking care of all three output formats and generating failure diffs when needed.
Sorry, something went wrong.
There was a problem hiding this comment.
Ok, did that. Locally, the svg test always skips though. Not sure about the reason.
Sorry, something went wrong.
There was a problem hiding this comment.
You just don't have inkscape installed. I wouldn't worry about it...
Sorry, something went wrong.
There was a problem hiding this comment.
I have several inkscape versions installed, maybe that's the problem.
Sorry, something went wrong.
There was a problem hiding this comment.
...sorry, shouldn't have assumed; rephrase - inkscape wasn't callable for some reason 😉
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
PR Summary
As quickly discussed on gitter, an add_artist() of Figure may be useful in some cases.
This PR would add such method.
PR Checklist