Commit 4872619
committed
NF+BF: add close-figs option to plot_directive
Add `close-figs` choice to `context` option of plot_directive. This
keeps the current context, but closes any previous figures.
This is necessary because the plot directive first runs the specified
code, then collects figures with:
fig_managers = _pylab_helpers.Gcf.get_all_fig_managers()
If you are using the "context" option, prior figures maybe generated
from a previous plot directive command, are still open, and therefore
collected with the new figure(s). The old figures will usually be
earlier in the list, and so, for something like this ReST block, you
will always get the first generated figure (``range(10)``) repeated in
the second plot directive panel:
#######
A title
#######
.. plot::
:context:
import matplotlib.pyplot as plt
plt.plot(range(10))
Then some text.
.. plot::
:context:
plt.figure()
plt.plot(range(5), 'r')
This PR add a context option of form `:context: close-figs` that closes
any previous figure windows before running the directive code.
It also adds a small test sphinx project to test the directive commands.
See email discussion thread starting here:
https://www.mail-archive.com/matplotlib-devel@lists.sourceforge.net/msg10816.html1 parent d8b2924 commit 4872619
File tree
13 files changed
+526
-15
lines changed- lib/matplotlib
- sphinxext
- tests
- tinypages
- _static
13 files changed
+526
-15
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1440 | 1440 | | |
1441 | 1441 | | |
1442 | 1442 | | |
| 1443 | + | |
1443 | 1444 | | |
1444 | 1445 | | |
1445 | 1446 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
66 | | - | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
67 | 70 | | |
68 | 71 | | |
69 | 72 | | |
| |||
190 | 193 | | |
191 | 194 | | |
192 | 195 | | |
193 | | - | |
| 196 | + | |
194 | 197 | | |
195 | | - | |
196 | | - | |
197 | | - | |
| 198 | + | |
198 | 199 | | |
199 | 200 | | |
200 | 201 | | |
| |||
524 | 525 | | |
525 | 526 | | |
526 | 527 | | |
527 | | - | |
| 528 | + | |
| 529 | + | |
528 | 530 | | |
529 | 531 | | |
530 | 532 | | |
| |||
600 | 602 | | |
601 | 603 | | |
602 | 604 | | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
603 | 608 | | |
604 | 609 | | |
605 | 610 | | |
606 | 611 | | |
607 | | - | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
608 | 615 | | |
609 | 616 | | |
610 | 617 | | |
| |||
644 | 651 | | |
645 | 652 | | |
646 | 653 | | |
647 | | - | |
648 | | - | |
| 654 | + | |
| 655 | + | |
649 | 656 | | |
650 | 657 | | |
651 | 658 | | |
| |||
729 | 736 | | |
730 | 737 | | |
731 | 738 | | |
732 | | - | |
733 | | - | |
734 | | - | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
735 | 748 | | |
736 | 749 | | |
737 | 750 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
Whitespace-only changes.
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
0 commit comments