-
Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy pathMEP27.html
More file actions
869 lines (682 loc) · 38 KB
/
MEP27.html
File metadata and controls
869 lines (682 loc) · 38 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />
<title>MEP27: Decouple pyplot from backends — Matplotlib 3.7.3 documentation</title>
<script data-cfasync="false">
document.documentElement.dataset.mode = localStorage.getItem("mode") || "";
document.documentElement.dataset.theme = localStorage.getItem("theme") || "light";
</script>
<!-- Loaded before other Sphinx assets -->
<link href="../../_static/styles/theme.css?digest=796348d33e8b1d947c94" rel="stylesheet">
<link href="../../_static/styles/bootstrap.css?digest=796348d33e8b1d947c94" rel="stylesheet">
<link href="../../_static/styles/pydata-sphinx-theme.css?digest=796348d33e8b1d947c94" rel="stylesheet">
<link href="../../_static/vendor/fontawesome/6.1.2/css/all.min.css?digest=796348d33e8b1d947c94" rel="stylesheet">
<link rel="preload" as="font" type="font/woff2" crossorigin href="../../_static/vendor/fontawesome/6.1.2/webfonts/fa-solid-900.woff2">
<link rel="preload" as="font" type="font/woff2" crossorigin href="../../_static/vendor/fontawesome/6.1.2/webfonts/fa-brands-400.woff2">
<link rel="preload" as="font" type="font/woff2" crossorigin href="../../_static/vendor/fontawesome/6.1.2/webfonts/fa-regular-400.woff2">
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v3.7.3-2-gba2e4a91dc" />
<link rel="stylesheet" type="text/css" href="../../_static/css/style.css?v3.7.3-2-gba2e4a91dc" />
<link rel="stylesheet" type="text/css" href="../../_static/graphviz.css?v3.7.3-2-gba2e4a91dc" />
<link rel="stylesheet" type="text/css" href="../../_static/plot_directive.css?v3.7.3-2-gba2e4a91dc" />
<link rel="stylesheet" type="text/css" href="../../_static/copybutton.css?v3.7.3-2-gba2e4a91dc" />
<link rel="stylesheet" type="text/css" href="../../_static/sg_gallery.css?v3.7.3-2-gba2e4a91dc" />
<link rel="stylesheet" type="text/css" href="../../_static/sg_gallery-binder.css?v3.7.3-2-gba2e4a91dc" />
<link rel="stylesheet" type="text/css" href="../../_static/sg_gallery-dataframe.css?v3.7.3-2-gba2e4a91dc" />
<link rel="stylesheet" type="text/css" href="../../_static/sg_gallery-rendered-html.css?v3.7.3-2-gba2e4a91dc" />
<link rel="stylesheet" type="text/css" href="../../_static/design-style.4045f2051d55cab465a707391d5b2007.min.css?v3.7.3-2-gba2e4a91dc" />
<link rel="stylesheet" type="text/css" href="../../_static/mpl.css?v3.7.3-2-gba2e4a91dc" />
<!-- Pre-loaded scripts that we'll load fully later -->
<link rel="preload" as="script" href="../../_static/scripts/bootstrap.js?digest=796348d33e8b1d947c94">
<link rel="preload" as="script" href="../../_static/scripts/pydata-sphinx-theme.js?digest=796348d33e8b1d947c94">
<script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js?v3.7.3-2-gba2e4a91dc"></script>
<script src="../../_static/jquery.js?v3.7.3-2-gba2e4a91dc"></script>
<script src="../../_static/underscore.js?v3.7.3-2-gba2e4a91dc"></script>
<script src="../../_static/_sphinx_javascript_frameworks_compat.js?v3.7.3-2-gba2e4a91dc"></script>
<script src="../../_static/doctools.js?v3.7.3-2-gba2e4a91dc"></script>
<script src="../../_static/sphinx_highlight.js?v3.7.3-2-gba2e4a91dc"></script>
<script src="../../_static/clipboard.min.js?v3.7.3-2-gba2e4a91dc"></script>
<script src="../../_static/copybutton.js?v3.7.3-2-gba2e4a91dc"></script>
<script src="../../_static/design-tabs.js?v3.7.3-2-gba2e4a91dc"></script>
<script data-domain="matplotlib.org" defer="defer" src="https://views.scientific-python.org/js/script.js"></script>
<script>DOCUMENTATION_OPTIONS.pagename = 'devel/MEP/MEP27';</script>
<script>
DOCUMENTATION_OPTIONS.theme_switcher_json_url = 'https://matplotlib.org/devdocs/_static/switcher.json?v3.7.3-2-gba2e4a91dc';
DOCUMENTATION_OPTIONS.theme_switcher_version_match = '3.7.3';
</script>
<link rel="canonical" href="https://matplotlib.org/stable/devel/MEP/MEP27.html" />
<link rel="search" type="application/opensearchdescription+xml"
title="Search within Matplotlib 3.7.3 documentation"
href="../../_static/opensearch.xml"/>
<link rel="shortcut icon" href="../../_static/favicon.ico"/>
<link rel="search" title="Search" href="../../search.html" />
<link rel="next" title="MEP28: Remove Complexity from Axes.boxplot" href="MEP28.html" />
<link rel="prev" title="MEP26: Artist styling" href="MEP26.html" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="docsearch:language" content="en">
</head>
<body data-spy="scroll" data-target="#bd-toc-nav" data-offset="180" data-default-mode="">
<a class="skip-link" href="#main-content">Skip to main content</a>
<input type="checkbox" class="sidebar-toggle" name="__primary" id="__primary">
<label class="overlay overlay-primary" for="__primary"></label>
<input type="checkbox" class="sidebar-toggle" name="__secondary" id="__secondary">
<label class="overlay overlay-secondary" for="__secondary"></label>
<div class="search-button__wrapper">
<div class="search-button__overlay"></div>
<div class="search-button__search-container">
<form class="bd-search d-flex align-items-center" action="../../search.html" method="get">
<i class="fa-solid fa-magnifying-glass"></i>
<input type="search" class="form-control" name="q" id="search-input" placeholder="Search the docs ..." aria-label="Search the docs ..." autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false">
<span class="search-button__kbd-shortcut"><kbd class="kbd-shortcut__modifier">Ctrl</kbd>+<kbd>K</kbd></span>
</form>
</div>
</div>
<nav class="bd-header navbar navbar-expand-lg bd-navbar" id="navbar-main"><div class="bd-header__inner bd-page-width">
<label class="sidebar-toggle primary-toggle" for="__primary">
<span class="fa-solid fa-bars"></span>
</label>
<div id="navbar-start">
<a class="navbar-brand logo" href="../../index.html">
<img src="../../_static/images/logo2.svg" class="logo__image only-light" alt="Logo image">
<img src="../../_static/images/logo_dark.svg" class="logo__image only-dark" alt="Logo image">
</a>
</div>
<div class="col-lg-9 navbar-header-items">
<div id="navbar-center" class="mr-auto">
<div class="navbar-center-item">
<ul id="navbar-main-elements" class="navbar-nav">
<li class="nav-item">
<a class="reference internal nav-link" href="../../plot_types/index.html">Plot types</a>
</li>
<li class="nav-item">
<a class="reference internal nav-link" href="../../gallery/index.html">Examples</a>
</li>
<li class="nav-item">
<a class="reference internal nav-link" href="../../tutorials/index.html">Tutorials</a>
</li>
<li class="nav-item">
<a class="reference internal nav-link" href="../../api/index.html">Reference</a>
</li>
<li class="nav-item">
<a class="reference internal nav-link" href="../../users/index.html">User guide</a>
</li>
<li class="nav-item">
<a class="reference internal nav-link" href="../index.html">Develop</a>
</li>
<li class="nav-item">
<a class="reference internal nav-link" href="../../users/release_notes.html">Releases</a>
</li>
</ul>
</div>
</div>
<div id="navbar-end">
<div class="navbar-end-item navbar-persistent--container">
<button class="btn btn-sm navbar-btn search-button search-button__button" title="Search" aria-label="Search" data-toggle="tooltip">
<i class="fa-solid fa-magnifying-glass"></i>
</button>
</div>
<div class="navbar-end-item">
<button class="theme-switch-button btn btn-sm btn-outline-primary navbar-btn rounded-circle" title="light/dark" aria-label="light/dark" data-toggle="tooltip">
<span class="theme-switch" data-mode="light"><i class="fa-solid fa-sun"></i></span>
<span class="theme-switch" data-mode="dark"><i class="fa-solid fa-moon"></i></span>
<span class="theme-switch" data-mode="auto"><i class="fa-solid fa-circle-half-stroke"></i></span>
</button>
</div>
<div class="navbar-end-item">
<div class="version-switcher__container dropdown">
<button type="button" class="version-switcher__button btn btn-sm navbar-btn dropdown-toggle" data-toggle="dropdown">
stable <!-- this text may get changed later by javascript -->
<span class="caret"></span>
</button>
<div class="version-switcher__menu dropdown-menu list-group-flush py-0">
<!-- dropdown will be populated by javascript on page load -->
</div>
</div>
</div>
<div class="navbar-end-item">
<ul id="navbar-icon-links" class="navbar-nav" aria-label="Icon Links">
<li class="nav-item">
<a href="https://gitter.im/matplotlib" title="Gitter" class="nav-link" rel="noopener" target="_blank" data-toggle="tooltip"><span><i class="fa-brands fa-gitter"></i></span>
<label class="sr-only">Gitter</label></a>
</li>
<li class="nav-item">
<a href="https://discourse.matplotlib.org" title="Discourse" class="nav-link" rel="noopener" target="_blank" data-toggle="tooltip"><span><i class="fa-brands fa-discourse"></i></span>
<label class="sr-only">Discourse</label></a>
</li>
<li class="nav-item">
<a href="https://github.com/matplotlib/matplotlib" title="GitHub" class="nav-link" rel="noopener" target="_blank" data-toggle="tooltip"><span><i class="fa-brands fa-github"></i></span>
<label class="sr-only">GitHub</label></a>
</li>
<li class="nav-item">
<a href="https://twitter.com/matplotlib/" title="Twitter" class="nav-link" rel="noopener" target="_blank" data-toggle="tooltip"><span><i class="fa-brands fa-twitter"></i></span>
<label class="sr-only">Twitter</label></a>
</li>
</ul>
</div>
</div>
</div>
<div class="navbar-persistent--mobile">
<button class="btn btn-sm navbar-btn search-button search-button__button" title="Search" aria-label="Search" data-toggle="tooltip">
<i class="fa-solid fa-magnifying-glass"></i>
</button>
</div>
<label class="sidebar-toggle secondary-toggle" for="__secondary">
<span class="fa-solid fa-outdent"></span>
</label>
</div>
</nav>
<div class="bd-container">
<div class="bd-container__inner bd-page-width">
<div class="bd-sidebar-primary bd-sidebar">
<div class="sidebar-header-items sidebar-primary__section">
<div class="sidebar-header-items__center">
<div class="navbar-center-item">
<ul id="navbar-main-elements" class="navbar-nav">
<li class="nav-item">
<a class="reference internal nav-link" href="../../plot_types/index.html">Plot types</a>
</li>
<li class="nav-item">
<a class="reference internal nav-link" href="../../gallery/index.html">Examples</a>
</li>
<li class="nav-item">
<a class="reference internal nav-link" href="../../tutorials/index.html">Tutorials</a>
</li>
<li class="nav-item">
<a class="reference internal nav-link" href="../../api/index.html">Reference</a>
</li>
<li class="nav-item">
<a class="reference internal nav-link" href="../../users/index.html">User guide</a>
</li>
<li class="nav-item">
<a class="reference internal nav-link" href="../index.html">Develop</a>
</li>
<li class="nav-item">
<a class="reference internal nav-link" href="../../users/release_notes.html">Releases</a>
</li>
</ul>
</div>
</div>
<div class="sidebar-header-items__end">
<div class="navbar-end-item">
<button class="theme-switch-button btn btn-sm btn-outline-primary navbar-btn rounded-circle" title="light/dark" aria-label="light/dark" data-toggle="tooltip">
<span class="theme-switch" data-mode="light"><i class="fa-solid fa-sun"></i></span>
<span class="theme-switch" data-mode="dark"><i class="fa-solid fa-moon"></i></span>
<span class="theme-switch" data-mode="auto"><i class="fa-solid fa-circle-half-stroke"></i></span>
</button>
</div>
<div class="navbar-end-item">
<div class="version-switcher__container dropdown">
<button type="button" class="version-switcher__button btn btn-sm navbar-btn dropdown-toggle" data-toggle="dropdown">
stable <!-- this text may get changed later by javascript -->
<span class="caret"></span>
</button>
<div class="version-switcher__menu dropdown-menu list-group-flush py-0">
<!-- dropdown will be populated by javascript on page load -->
</div>
</div>
</div>
<div class="navbar-end-item">
<ul id="navbar-icon-links" class="navbar-nav" aria-label="Icon Links">
<li class="nav-item">
<a href="https://gitter.im/matplotlib" title="Gitter" class="nav-link" rel="noopener" target="_blank" data-toggle="tooltip"><span><i class="fa-brands fa-gitter"></i></span>
<label class="sr-only">Gitter</label></a>
</li>
<li class="nav-item">
<a href="https://discourse.matplotlib.org" title="Discourse" class="nav-link" rel="noopener" target="_blank" data-toggle="tooltip"><span><i class="fa-brands fa-discourse"></i></span>
<label class="sr-only">Discourse</label></a>
</li>
<li class="nav-item">
<a href="https://github.com/matplotlib/matplotlib" title="GitHub" class="nav-link" rel="noopener" target="_blank" data-toggle="tooltip"><span><i class="fa-brands fa-github"></i></span>
<label class="sr-only">GitHub</label></a>
</li>
<li class="nav-item">
<a href="https://twitter.com/matplotlib/" title="Twitter" class="nav-link" rel="noopener" target="_blank" data-toggle="tooltip"><span><i class="fa-brands fa-twitter"></i></span>
<label class="sr-only">Twitter</label></a>
</li>
</ul>
</div>
</div>
</div>
<div class="sidebar-start-items sidebar-primary__section">
<div class="sidebar-start-items__item"><nav class="bd-links" id="bd-docs-nav" aria-label="Section navigation">
<p class="bd-links__title" role="heading" aria-level="1">
Section Navigation
</p>
<div class="bd-toc-item navbar-nav">
<ul class="current nav bd-sidenav">
<li class="toctree-l1"><a class="reference internal" href="../contributing.html">Contributing</a></li>
<li class="toctree-l1"><a class="reference internal" href="../triage.html">Bug triaging and issue curation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../development_setup.html">Setting up Matplotlib for development</a></li>
<li class="toctree-l1"><a class="reference internal" href="../development_workflow.html">Development workflow</a></li>
<li class="toctree-l1"><a class="reference internal" href="../testing.html">Testing</a></li>
<li class="toctree-l1"><a class="reference internal" href="../documenting_mpl.html">Writing documentation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../style_guide.html">Documentation style guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="../coding_guide.html">Pull request guidelines</a></li>
<li class="toctree-l1"><a class="reference internal" href="../release_guide.html">Release guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="../dependencies.html">Dependencies</a></li>
<li class="toctree-l1"><a class="reference internal" href="../min_dep_policy.html">Minimum version of dependencies policy</a></li>
<li class="toctree-l1"><a class="reference internal" href="../maintainer_workflow.html">Maintainer workflow</a></li>
<li class="toctree-l1 current active has-children"><a class="reference internal" href="index.html">Matplotlib Enhancement Proposals</a><input checked="" class="toctree-checkbox" id="toctree-checkbox-1" name="toctree-checkbox-1" type="checkbox"/><label class="toctree-toggle" for="toctree-checkbox-1"><i class="fa-solid fa-chevron-down"></i></label><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="template.html">MEP Template</a></li>
<li class="toctree-l2"><a class="reference internal" href="MEP08.html">MEP8: PEP8</a></li>
<li class="toctree-l2"><a class="reference internal" href="MEP09.html">MEP9: Global interaction manager</a></li>
<li class="toctree-l2"><a class="reference internal" href="MEP10.html">MEP10: Docstring consistency</a></li>
<li class="toctree-l2"><a class="reference internal" href="MEP11.html">MEP11: Third-party dependencies</a></li>
<li class="toctree-l2"><a class="reference internal" href="MEP12.html">MEP12: Improve Gallery and Examples</a></li>
<li class="toctree-l2"><a class="reference internal" href="MEP13.html">MEP13: Use properties for Artists</a></li>
<li class="toctree-l2"><a class="reference internal" href="MEP14.html">MEP14: Text handling</a></li>
<li class="toctree-l2"><a class="reference internal" href="MEP15.html">MEP15: Fix axis autoscaling when limits are specified for one axis only</a></li>
<li class="toctree-l2"><a class="reference internal" href="MEP19.html">MEP19: Continuous Integration</a></li>
<li class="toctree-l2"><a class="reference internal" href="MEP21.html">MEP21: color and cm refactor</a></li>
<li class="toctree-l2"><a class="reference internal" href="MEP22.html">MEP22: Toolbar rewrite</a></li>
<li class="toctree-l2"><a class="reference internal" href="MEP23.html">MEP23: Multiple Figures per GUI window</a></li>
<li class="toctree-l2"><a class="reference internal" href="MEP24.html">MEP24: Negative radius in polar plots</a></li>
<li class="toctree-l2"><a class="reference internal" href="MEP25.html">MEP25: Serialization</a></li>
<li class="toctree-l2"><a class="reference internal" href="MEP26.html">MEP26: Artist styling</a></li>
<li class="toctree-l2 current active"><a class="current reference internal" href="#">MEP27: Decouple pyplot from backends</a></li>
<li class="toctree-l2"><a class="reference internal" href="MEP28.html">MEP28: Remove Complexity from Axes.boxplot</a></li>
<li class="toctree-l2"><a class="reference internal" href="MEP29.html">MEP29: Text light markup</a></li>
</ul>
</li>
</ul>
<ul class="nav bd-sidenav">
<li class="toctree-l1"><a class="reference internal" href="../license.html">Licenses</a></li>
<li class="toctree-l1"><a class="reference internal" href="../color_changes.html">Default color changes</a></li>
</ul>
</div>
</nav>
</div>
</div>
<div class="sidebar-end-items sidebar-primary__section">
<div class="sidebar-end-items__item">
</div>
</div>
<div id="rtd-footer-container"></div>
</div>
<main id="main-content" class="bd-main">
<div class="bd-content">
<div class="bd-article-container">
<div class="bd-header-article">
</div>
<article class="bd-article" role="main">
<section id="mep27-decouple-pyplot-from-backends">
<h1>MEP27: Decouple pyplot from backends<a class="headerlink" href="#mep27-decouple-pyplot-from-backends" title="Permalink to this heading">#</a></h1>
<nav class="contents local" id="contents">
<ul class="simple">
<li><p><a class="reference internal" href="#status" id="id1">Status</a></p></li>
<li><p><a class="reference internal" href="#branches-and-pull-requests" id="id2">Branches and Pull requests</a></p></li>
<li><p><a class="reference internal" href="#abstract" id="id3">Abstract</a></p></li>
<li><p><a class="reference internal" href="#detailed-description" id="id4">Detailed description</a></p></li>
<li><p><a class="reference internal" href="#implementation" id="id5">Implementation</a></p></li>
<li><p><a class="reference internal" href="#future-compatibility" id="id6">Future compatibility</a></p></li>
<li><p><a class="reference internal" href="#backward-compatibility" id="id7">Backward compatibility</a></p></li>
<li><p><a class="reference internal" href="#alternatives" id="id8">Alternatives</a></p></li>
<li><p><a class="reference internal" href="#questions" id="id9">Questions</a></p></li>
</ul>
</nav>
<section id="status">
<h2><a class="toc-backref" href="#id1" role="doc-backlink">Status</a><a class="headerlink" href="#status" title="Permalink to this heading">#</a></h2>
<p><strong>Progress</strong></p>
</section>
<section id="branches-and-pull-requests">
<h2><a class="toc-backref" href="#id2" role="doc-backlink">Branches and Pull requests</a><a class="headerlink" href="#branches-and-pull-requests" title="Permalink to this heading">#</a></h2>
<p>Main PR (including GTK3):</p>
<ul class="simple">
<li><p><a class="github reference external" href="https://github.com/matplotlib/matplotlib/pull/4143">matplotlib/matplotlib#4143</a></p></li>
</ul>
<p>Backend specific branch diffs:</p>
<ul class="simple">
<li><p><a class="github reference external" href="https://github.com/OceanWolf/matplotlib/compare/backend-refactor...OceanWolf:backend-refactor-tkagg">OceanWolf/matplotlib</a></p></li>
<li><p><a class="github reference external" href="https://github.com/OceanWolf/matplotlib/compare/backend-refactor...OceanWolf:backend-refactor-qt">OceanWolf/matplotlib</a></p></li>
<li><p><a class="github reference external" href="https://github.com/OceanWolf/matplotlib/compare/backend-refactor...backend-refactor-wx">OceanWolf/matplotlib</a></p></li>
</ul>
</section>
<section id="abstract">
<h2><a class="toc-backref" href="#id3" role="doc-backlink">Abstract</a><a class="headerlink" href="#abstract" title="Permalink to this heading">#</a></h2>
<p>This MEP refactors the backends to give a more structured and
consistent API, removing generic code and consolidate existing code.
To do this we propose splitting:</p>
<ol class="arabic simple">
<li><p><code class="docutils literal notranslate"><span class="pre">FigureManagerBase</span></code> and its derived classes into the core
functionality class <code class="docutils literal notranslate"><span class="pre">FigureManager</span></code> and a backend specific class
<code class="docutils literal notranslate"><span class="pre">WindowBase</span></code> and</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">ShowBase</span></code> and its derived classes into <code class="docutils literal notranslate"><span class="pre">Gcf.show_all</span></code> and <code class="docutils literal notranslate"><span class="pre">MainLoopBase</span></code>.</p></li>
</ol>
</section>
<section id="detailed-description">
<h2><a class="toc-backref" href="#id4" role="doc-backlink">Detailed description</a><a class="headerlink" href="#detailed-description" title="Permalink to this heading">#</a></h2>
<p>This MEP aims to consolidate the backends API into one single uniform
API, removing generic code out of the backend (which includes
<code class="docutils literal notranslate"><span class="pre">_pylab_helpers</span></code> and <code class="docutils literal notranslate"><span class="pre">Gcf</span></code>), and push code to a more appropriate
level in matplotlib. With this we automatically remove
inconsistencies that appear in the backends, such as
<code class="docutils literal notranslate"><span class="pre">FigureManagerBase.resize(w,</span> <span class="pre">h)</span></code> which sometimes sets the canvas,
and other times set the entire window to the dimensions given,
depending on the backend.</p>
<p>Two main places for generic code appear in the classes derived from
<code class="docutils literal notranslate"><span class="pre">FigureManagerBase</span></code> and <code class="docutils literal notranslate"><span class="pre">ShowBase</span></code>.</p>
<ol class="arabic">
<li><p><code class="docutils literal notranslate"><span class="pre">FigureManagerBase</span></code> has <strong>three</strong> jobs at the moment:</p>
<blockquote>
<div><ol class="arabic simple">
<li><p>The documentation describes it as a <em>Helper class for pyplot
mode, wraps everything up into a neat bundle</em></p></li>
<li><p>But it doesn't just wrap the canvas and toolbar, it also does
all of the windowing tasks itself. The conflation of these two
tasks gets seen the best in the following line:
<code class="docutils literal notranslate"><span class="pre">self.set_window_title("Figure</span> <span class="pre">%d"</span> <span class="pre">%</span> <span class="pre">num)</span></code> This combines
backend specific code <code class="docutils literal notranslate"><span class="pre">self.set_window_title(title)</span></code> with
matplotlib generic code <code class="docutils literal notranslate"><span class="pre">title</span> <span class="pre">=</span> <span class="pre">"Figure</span> <span class="pre">%d"</span> <span class="pre">%</span> <span class="pre">num</span></code>.</p></li>
<li><p>Currently the backend specific subclass of <code class="docutils literal notranslate"><span class="pre">FigureManager</span></code>
decides when to end the mainloop. This also seems very wrong
as the figure should have no control over the other figures.</p></li>
</ol>
</div></blockquote>
</li>
<li><p><code class="docutils literal notranslate"><span class="pre">ShowBase</span></code> has two jobs:</p>
<blockquote>
<div><ol class="arabic simple">
<li><p>It has the job of going through all figure managers registered
in <code class="docutils literal notranslate"><span class="pre">_pylab_helpers.Gcf</span></code> and telling them to show themselves.</p></li>
<li><p>And secondly it has the job of performing the backend specific
<code class="docutils literal notranslate"><span class="pre">mainloop</span></code> to block the main programme and thus keep the
figures from dying.</p></li>
</ol>
</div></blockquote>
</li>
</ol>
</section>
<section id="implementation">
<h2><a class="toc-backref" href="#id5" role="doc-backlink">Implementation</a><a class="headerlink" href="#implementation" title="Permalink to this heading">#</a></h2>
<p>The description of this MEP gives us most of the solution:</p>
<ol class="arabic simple">
<li><p>To remove the windowing aspect out of <code class="docutils literal notranslate"><span class="pre">FigureManagerBase</span></code> letting
it simply wrap this new class along with the other backend classes.
Create a new <code class="docutils literal notranslate"><span class="pre">WindowBase</span></code> class that can handle this
functionality, with pass-through methods (:arrow_right:) to
<code class="docutils literal notranslate"><span class="pre">WindowBase</span></code>. Classes that subclass <code class="docutils literal notranslate"><span class="pre">WindowBase</span></code> should also
subclass the GUI specific window class to ensure backward
compatibility (<code class="docutils literal notranslate"><span class="pre">manager.window</span> <span class="pre">==</span> <span class="pre">manager.window</span></code>).</p></li>
<li><p>Refactor the mainloop of <code class="docutils literal notranslate"><span class="pre">ShowBase</span></code> into <code class="docutils literal notranslate"><span class="pre">MainLoopBase</span></code>, which
encapsulates the end of the loop as well. We give an instance of
<code class="docutils literal notranslate"><span class="pre">MainLoop</span></code> to <code class="docutils literal notranslate"><span class="pre">FigureManager</span></code> as a key unlock the exit method
(requiring all keys returned before the loop can die). Note this
opens the possibility for multiple backends to run concurrently.</p></li>
<li><p>Now that <code class="docutils literal notranslate"><span class="pre">FigureManagerBase</span></code> has no backend specifics in it, to
rename it to <code class="docutils literal notranslate"><span class="pre">FigureManager</span></code>, and move to a new file
<code class="docutils literal notranslate"><span class="pre">backend_managers.py</span></code> noting that:</p>
<ol class="arabic simple">
<li><p>This allows us to break up the conversion of backends into
separate PRs as we can keep the existing <code class="docutils literal notranslate"><span class="pre">FigureManagerBase</span></code>
class and its dependencies intact.</p></li>
<li><p>And this also anticipates MEP22 where the new
<code class="docutils literal notranslate"><span class="pre">NavigationBase</span></code> has morphed into a backend independent
<code class="docutils literal notranslate"><span class="pre">ToolManager</span></code>.</p></li>
</ol>
</li>
</ol>
<table class="table">
<thead>
<tr class="row-odd"><th class="head"><p>FigureManagerBase(canvas, num)</p></th>
<th class="head"><p>FigureManager(figure, num)</p></th>
<th class="head"><p><code class="docutils literal notranslate"><span class="pre">WindowBase(title)</span></code></p></th>
<th class="head"><p>Notes</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>show</p></td>
<td></td>
<td><p>show</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>destroy</p></td>
<td><p>calls destroy on all
components</p></td>
<td><p>destroy</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>full_screen_toggle</p></td>
<td><p>handles logic</p></td>
<td><p>set_fullscreen</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>resize</p></td>
<td></td>
<td><p>resize</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>key_press</p></td>
<td><p>key_press</p></td>
<td></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>get_window_title</p></td>
<td></td>
<td><p>get_window_title</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>set_window_title</p></td>
<td></td>
<td><p>set_window_title</p></td>
<td></td>
</tr>
<tr class="row-odd"><td></td>
<td><p>_get_toolbar</p></td>
<td></td>
<td><p>A common method to all
subclasses of FigureManagerBase</p></td>
</tr>
<tr class="row-even"><td></td>
<td></td>
<td><p>set_default_size</p></td>
<td></td>
</tr>
<tr class="row-odd"><td></td>
<td></td>
<td><p>add_element_to_window</p></td>
<td></td>
</tr>
</tbody>
</table>
<table class="table">
<thead>
<tr class="row-odd"><th class="head"><p>ShowBase</p></th>
<th class="head"><p>MainLoopBase</p></th>
<th class="head"><p>Notes</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>mainloop</p></td>
<td><p>begin</p></td>
<td></td>
</tr>
<tr class="row-odd"><td></td>
<td><p>end</p></td>
<td><p>Gets called
automagically
when no more
instances of
the subclass
exist</p></td>
</tr>
<tr class="row-even"><td><p>__call__</p></td>
<td></td>
<td><p>Method moved
to
Gcf.show_all</p></td>
</tr>
</tbody>
</table>
</section>
<section id="future-compatibility">
<h2><a class="toc-backref" href="#id6" role="doc-backlink">Future compatibility</a><a class="headerlink" href="#future-compatibility" title="Permalink to this heading">#</a></h2>
<p>As eluded to above when discussing MEP 22, this refactor makes it easy
to add in new generic features. At the moment, MEP 22 has to make
ugly hacks to each class extending from <code class="docutils literal notranslate"><span class="pre">FigureManagerBase</span></code>. With
this code, this only needs to get made in the single <code class="docutils literal notranslate"><span class="pre">FigureManager</span></code>
class. This also makes the later deprecation of
<code class="docutils literal notranslate"><span class="pre">NavigationToolbar2</span></code> very straightforward, only needing to touch the
single <code class="docutils literal notranslate"><span class="pre">FigureManager</span></code> class</p>
<p>MEP 23 makes for another use case where this refactored code will come
in very handy.</p>
</section>
<section id="backward-compatibility">
<h2><a class="toc-backref" href="#id7" role="doc-backlink">Backward compatibility</a><a class="headerlink" href="#backward-compatibility" title="Permalink to this heading">#</a></h2>
<p>As we leave all backend code intact, only adding missing methods to
existing classes, this should work seamlessly for all use cases. The
only difference will lie for backends that used
<code class="docutils literal notranslate"><span class="pre">FigureManager.resize</span></code> to resize the canvas and not the window, due
to the standardisation of the API.</p>
<p>I would envision that the classes made obsolete by this refactor get
deprecated and removed on the same timetable as
<code class="docutils literal notranslate"><span class="pre">NavigationToolbar2</span></code>, also note that the change in call signature to
the <code class="docutils literal notranslate"><span class="pre">FigureCanvasWx</span></code> constructor, while backward compatible, I think
the old (imho ugly style) signature should get deprecated and removed
in the same manner as everything else.</p>
<table class="table">
<thead>
<tr class="row-odd"><th class="head"><p>backend</p></th>
<th class="head"><p>manager.resize(w,h)</p></th>
<th class="head"><p>Extra</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>gtk3</p></td>
<td><p>window</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>Tk</p></td>
<td><p>canvas</p></td>
<td></td>
</tr>
<tr class="row-even"><td><p>Qt</p></td>
<td><p>window</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>Wx</p></td>
<td><p>canvas</p></td>
<td><p>FigureManagerWx had
<code class="docutils literal notranslate"><span class="pre">frame</span></code> as an alias to
window, so this also
breaks BC.</p></td>
</tr>
</tbody>
</table>
</section>
<section id="alternatives">
<h2><a class="toc-backref" href="#id8" role="doc-backlink">Alternatives</a><a class="headerlink" href="#alternatives" title="Permalink to this heading">#</a></h2>
<p>If there were any alternative solutions to solving the same problem,
they should be discussed here, along with a justification for the
chosen approach.</p>
</section>
<section id="questions">
<h2><a class="toc-backref" href="#id9" role="doc-backlink">Questions</a><a class="headerlink" href="#questions" title="Permalink to this heading">#</a></h2>
<p>Mdehoon: Can you elaborate on how to run multiple backends
concurrently?</p>
<p>OceanWolf: @mdehoon, as I say, not for this MEP, but I see this MEP
opens it up as a future possibility. Basically the <code class="docutils literal notranslate"><span class="pre">MainLoopBase</span></code>
class acts a per backend Gcf, in this MEP it tracks the number of
figures open per backend, and manages the mainloops for those
backends. It closes the backend specific mainloop when it detects
that no figures remain open for that backend. Because of this I
imagine that with only a small amount of tweaking that we can do
full-multi-backend matplotlib. No idea yet why one would want to, but
I leave the possibility there in MainLoopBase. With all the
backend-code specifics refactored out of <code class="docutils literal notranslate"><span class="pre">FigureManager</span></code> also aids
in this, one manager to rule them (the backends) all.</p>
<p>Mdehoon: @OceanWolf, OK, thanks for the explanation. Having a uniform
API for the backends is very important for the maintainability of
matplotlib. I think this MEP is a step in the right direction.</p>
</section>
</section>
</article>
</div>
<div class="bd-sidebar-secondary bd-toc">
<div class="toc-item">
<div class="tocsection onthispage">
<i class="fa-solid fa-list"></i> On this page
</div>
<nav id="bd-toc-nav" class="page-toc">
<ul class="visible nav section-nav flex-column">
<li class="toc-h2 nav-item toc-entry">
<a class="reference internal nav-link" href="#status">
Status
</a>
</li>
<li class="toc-h2 nav-item toc-entry">
<a class="reference internal nav-link" href="#branches-and-pull-requests">
Branches and Pull requests
</a>
</li>
<li class="toc-h2 nav-item toc-entry">
<a class="reference internal nav-link" href="#abstract">
Abstract
</a>
</li>
<li class="toc-h2 nav-item toc-entry">
<a class="reference internal nav-link" href="#detailed-description">
Detailed description
</a>
</li>
<li class="toc-h2 nav-item toc-entry">
<a class="reference internal nav-link" href="#implementation">
Implementation
</a>
</li>
<li class="toc-h2 nav-item toc-entry">
<a class="reference internal nav-link" href="#future-compatibility">
Future compatibility
</a>
</li>
<li class="toc-h2 nav-item toc-entry">
<a class="reference internal nav-link" href="#backward-compatibility">
Backward compatibility
</a>
</li>
<li class="toc-h2 nav-item toc-entry">
<a class="reference internal nav-link" href="#alternatives">
Alternatives
</a>
</li>
<li class="toc-h2 nav-item toc-entry">
<a class="reference internal nav-link" href="#questions">
Questions
</a>
</li>
</ul>
</nav>
</div>
</div>
</div>
<footer class="bd-footer-content">
<div class="bd-footer-content__inner">
</div>
</footer>
</main>
</div>
</div>
<!-- Scripts loaded after <body> so the DOM is not blocked -->
<script src="../../_static/scripts/bootstrap.js?digest=796348d33e8b1d947c94"></script>
<script src="../../_static/scripts/pydata-sphinx-theme.js?digest=796348d33e8b1d947c94"></script>
<footer class="bd-footer"><div class="bd-footer__inner container">
<div class="footer-item">
<p class="copyright">
© Copyright 2002–2012 John Hunter, Darren Dale, Eric Firing, Michael Droettboom and the Matplotlib development team; 2012–2023 The Matplotlib development team.<br>
</p>
</div>
<div class="footer-item">
<p class="sphinx-version">
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 5.3.0.<br>
</p>
</div>
<div class="footer-item">
<p class="sphinx-version">
Built from v3.7.3-2-gba2e4a91dc.
<br/>
</p>
</div>
</div>
</footer>
</body>
</html>