-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
DOC: fix CL tutorial to give same output from saved file and example #12394
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
DOC: fix CL tutorial to give same output from saved file and example #12394
Conversation
fig.savefig('outname.png', bbox_inches='tight') | ||
|
||
############################################# | ||
# A better way to get around this awkwardness is to simply | ||
# use a legend for the figure: | ||
# use the legend method provided by the figure class: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
simply use `.Figure.legend`:
Yes this works now as expected. Maybe the text should clearly state here that in order to see the effect one would need to compare the shown (add |
Can we include images in the tutorials? I guess I could just include the png. WRT item 3 I was t sure it was necessary but happy to do it if you feel it helps |
I think some of the confusion comes from looking at the produced images, so if at least the code has the savefig command in it, it would point more towards where to look for the feature. I think you can use rst inside the examples, so |
fc9967d
to
e84c56c
Compare
Seems better now, maybe a little small, but I think thats fine: |
What's the reason for the difference? Shouldn't it save with the same dpi as it shows? Ah, you changed the width... Why not produce the figure with |
I had to hard-set the width to 300 px in the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes the Legend section of the constrained layout guide much clearer and it's well suited to prevent misunderstandings as in #12377.
# The saved file looks like: | ||
# | ||
# .. image:: /_static/constrained_layout/CL02.png | ||
# :align: center |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The center alignment seems to be ignored for some reason by the css. I would not consider this crucial at this point. One can revisit the cause of this at a different stage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:-( Oh well I tried. As I'm sure you can tell screwing around w/ rst embedded in python comments isn't my favourite pastime.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is nothing wrong with the rst command itself. It's either sphinx having changed something in their newest version or us screwing up the CSS.
I think adding something like
img.align-center {
display: block;
margin-left: auto;
margin-right: auto;}
in the css file will center the image correctly.
It's something to keep in mind, but somehow unrelated to this PR anyways.
b38f71a
to
d71b44b
Compare
…t from saved file and example
…t from saved file and example
Thanks for the help @ImportanceOfBeingErnest |
…394-on-v3.0.x Backport PR #12394 on branch v3.0.x (DOC: fix CL tutorial to give same output from saved file and example)
…394-on-v3.0.0-doc Backport PR #12394 on branch v3.0.0-doc (DOC: fix CL tutorial to give same output from saved file and example)
It seems one drawback of this is that now every time you build the docs it'll create two png images in the tutorials folder, which will then end up in any commit (if one doesn't pay attention). |
PR Summary
Closes #12391.
When CI passes I'll post the result here for review....
As it'll post in the docs
As it looks in saved file
PR Checklist