-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Give plot_directive output a max-width: 100%
#19063
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from pathlib import Path | ||
|
||
_static_path = Path(__file__).resolve().parent / Path('static') |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* plot_directive.css | ||
* ~~~~~~~~~~~~ | ||
* | ||
* Stylesheet controlling images created using the `plot` directive within | ||
* Sphinx. | ||
* | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sphinx includes some copyright/license stuff here, presumably since this file will be redistributed independently of the repository. I figure I don't mind my whole three lines of very advanced CSS becoming public domain upon distribution, but wanted to flag this in case there are legal ramifications I don't understand. https://github.com/sphinx-doc/sphinx/blob/3.x/sphinx/templates/graphviz/graphviz.css#L7 |
||
* :copyright: Copyright 2020-* by the Matplotlib development team. | ||
* :license: Matplotlib, see LICENSE for details. | ||
* | ||
*/ | ||
|
||
img.plot-directive { | ||
border: 0; | ||
max-width: 100%; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -141,3 +141,23 @@ using the :caption: option: | |
|
||
.. plot:: range4.py | ||
:caption: This is the caption for plot 18. | ||
|
||
Plot 19 uses shows that the "plot-directive" class is still appended, even if | ||
we request other custom classes: | ||
|
||
.. plot:: range4.py | ||
:class: my-class my-other-class | ||
|
||
Should also have a caption. | ||
|
||
Plot 20 shows that the default template correctly prints the multi-image | ||
scenario: | ||
|
||
.. plot:: | ||
:caption: This caption applies to both plots. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This caption is repeated verbatim after each plot with my changes. This may not be what I would have expected to happen, but it is the existing behavior. |
||
|
||
plt.figure() | ||
plt.plot(range(6)) | ||
|
||
plt.figure() | ||
plt.plot(range(4)) |
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.
As found in https://github.com/sphinx-doc/sphinx/blob/3.x/sphinx/ext/graphviz.py#L390