File size: 147,190 Bytes
5123a32 |
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 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 |
# Note: The first part of this file can be modified in place, but the latter
# part is autogenerated by the boilerplate.py script.
"""
`matplotlib.pyplot` is a state-based interface to matplotlib. It provides
an implicit, MATLAB-like, way of plotting. It also opens figures on your
screen, and acts as the figure GUI manager.
pyplot is mainly intended for interactive plots and simple cases of
programmatic plot generation::
import numpy as np
import matplotlib.pyplot as plt
x = np.arange(0, 5, 0.1)
y = np.sin(x)
plt.plot(x, y)
The explicit object-oriented API is recommended for complex plots, though
pyplot is still usually used to create the figure and often the Axes in the
figure. See `.pyplot.figure`, `.pyplot.subplots`, and
`.pyplot.subplot_mosaic` to create figures, and
:doc:`Axes API </api/axes_api>` for the plotting methods on an Axes::
import numpy as np
import matplotlib.pyplot as plt
x = np.arange(0, 5, 0.1)
y = np.sin(x)
fig, ax = plt.subplots()
ax.plot(x, y)
See :ref:`api_interfaces` for an explanation of the tradeoffs between the
implicit and explicit interfaces.
"""
# fmt: off
from __future__ import annotations
from contextlib import AbstractContextManager, ExitStack
from enum import Enum
import functools
import importlib
import inspect
import logging
import sys
import threading
import time
from typing import TYPE_CHECKING, cast, overload
from cycler import cycler # noqa: F401
import matplotlib
import matplotlib.colorbar
import matplotlib.image
from matplotlib import _api
from matplotlib import ( # noqa: F401 Re-exported for typing.
cm as cm, get_backend as get_backend, rcParams as rcParams, style as style)
from matplotlib import _pylab_helpers
from matplotlib import interactive # noqa: F401
from matplotlib import cbook
from matplotlib import _docstring
from matplotlib.backend_bases import (
FigureCanvasBase, FigureManagerBase, MouseButton)
from matplotlib.figure import Figure, FigureBase, figaspect
from matplotlib.gridspec import GridSpec, SubplotSpec
from matplotlib import rcsetup, rcParamsDefault, rcParamsOrig
from matplotlib.artist import Artist
from matplotlib.axes import Axes
from matplotlib.axes import Subplot # noqa: F401
from matplotlib.backends import BackendFilter, backend_registry
from matplotlib.projections import PolarAxes
from matplotlib import mlab # for detrend_none, window_hanning
from matplotlib.scale import get_scale_names # noqa: F401
from matplotlib.cm import _colormaps
from matplotlib.colors import _color_sequences, Colormap
import numpy as np
if TYPE_CHECKING:
from collections.abc import Callable, Hashable, Iterable, Sequence
import datetime
import pathlib
import os
from typing import Any, BinaryIO, Literal, TypeVar
from typing_extensions import ParamSpec
import PIL.Image
from numpy.typing import ArrayLike
import matplotlib.axes
import matplotlib.artist
import matplotlib.backend_bases
from matplotlib.axis import Tick
from matplotlib.axes._base import _AxesBase
from matplotlib.backend_bases import RendererBase, Event
from matplotlib.cm import ScalarMappable
from matplotlib.contour import ContourSet, QuadContourSet
from matplotlib.collections import (
Collection,
LineCollection,
PolyCollection,
PathCollection,
EventCollection,
QuadMesh,
)
from matplotlib.colorbar import Colorbar
from matplotlib.container import (
BarContainer,
ErrorbarContainer,
StemContainer,
)
from matplotlib.figure import SubFigure
from matplotlib.legend import Legend
from matplotlib.mlab import GaussianKDE
from matplotlib.image import AxesImage, FigureImage
from matplotlib.patches import FancyArrow, StepPatch, Wedge
from matplotlib.quiver import Barbs, Quiver, QuiverKey
from matplotlib.scale import ScaleBase
from matplotlib.transforms import Transform, Bbox
from matplotlib.typing import ColorType, LineStyleType, MarkerType, HashableList
from matplotlib.widgets import SubplotTool
_P = ParamSpec('_P')
_R = TypeVar('_R')
_T = TypeVar('_T')
# We may not need the following imports here:
from matplotlib.colors import Normalize
from matplotlib.lines import Line2D, AxLine
from matplotlib.text import Text, Annotation
from matplotlib.patches import Arrow, Circle, Rectangle # noqa: F401
from matplotlib.patches import Polygon
from matplotlib.widgets import Button, Slider, Widget # noqa: F401
from .ticker import ( # noqa: F401
TickHelper, Formatter, FixedFormatter, NullFormatter, FuncFormatter,
FormatStrFormatter, ScalarFormatter, LogFormatter, LogFormatterExponent,
LogFormatterMathtext, Locator, IndexLocator, FixedLocator, NullLocator,
LinearLocator, LogLocator, AutoLocator, MultipleLocator, MaxNLocator)
_log = logging.getLogger(__name__)
# Explicit rename instead of import-as for typing's sake.
colormaps = _colormaps
color_sequences = _color_sequences
@overload
def _copy_docstring_and_deprecators(
method: Any,
func: Literal[None] = None
) -> Callable[[Callable[_P, _R]], Callable[_P, _R]]: ...
@overload
def _copy_docstring_and_deprecators(
method: Any, func: Callable[_P, _R]) -> Callable[_P, _R]: ...
def _copy_docstring_and_deprecators(
method: Any,
func: Callable[_P, _R] | None = None
) -> Callable[[Callable[_P, _R]], Callable[_P, _R]] | Callable[_P, _R]:
if func is None:
return cast('Callable[[Callable[_P, _R]], Callable[_P, _R]]',
functools.partial(_copy_docstring_and_deprecators, method))
decorators: list[Callable[[Callable[_P, _R]], Callable[_P, _R]]] = [
_docstring.copy(method)
]
# Check whether the definition of *method* includes @_api.rename_parameter
# or @_api.make_keyword_only decorators; if so, propagate them to the
# pyplot wrapper as well.
while hasattr(method, "__wrapped__"):
potential_decorator = _api.deprecation.DECORATORS.get(method)
if potential_decorator:
decorators.append(potential_decorator)
method = method.__wrapped__
for decorator in decorators[::-1]:
func = decorator(func)
_add_pyplot_note(func, method)
return func
_NO_PYPLOT_NOTE = [
'FigureBase._gci', # wrapped_func is private
'_AxesBase._sci', # wrapped_func is private
'Artist.findobj', # not a standard pyplot wrapper because it does not operate
# on the current Figure / Axes. Explanation of relation would
# be more complex and is not too important.
]
def _add_pyplot_note(func, wrapped_func):
"""
Add a note to the docstring of *func* that it is a pyplot wrapper.
The note is added to the "Notes" section of the docstring. If that does
not exist, a "Notes" section is created. In numpydoc, the "Notes"
section is the third last possible section, only potentially followed by
"References" and "Examples".
"""
if not func.__doc__:
return # nothing to do
qualname = wrapped_func.__qualname__
if qualname in _NO_PYPLOT_NOTE:
return
wrapped_func_is_method = True
if "." not in qualname:
# method qualnames are prefixed by the class and ".", e.g. "Axes.plot"
wrapped_func_is_method = False
link = f"{wrapped_func.__module__}.{qualname}"
elif qualname.startswith("Axes."): # e.g. "Axes.plot"
link = ".axes." + qualname
elif qualname.startswith("_AxesBase."): # e.g. "_AxesBase.set_xlabel"
link = ".axes.Axes" + qualname[9:]
elif qualname.startswith("Figure."): # e.g. "Figure.figimage"
link = "." + qualname
elif qualname.startswith("FigureBase."): # e.g. "FigureBase.gca"
link = ".Figure" + qualname[10:]
elif qualname.startswith("FigureCanvasBase."): # "FigureBaseCanvas.mpl_connect"
link = "." + qualname
else:
raise RuntimeError(f"Wrapped method from unexpected class: {qualname}")
if wrapped_func_is_method:
message = f"This is the :ref:`pyplot wrapper <pyplot_interface>` for `{link}`."
else:
message = f"This is equivalent to `{link}`."
# Find the correct insert position:
# - either we already have a "Notes" section into which we can insert
# - or we create one before the next present section. Note that in numpydoc, the
# "Notes" section is the third last possible section, only potentially followed
# by "References" and "Examples".
# - or we append a new "Notes" section at the end.
doc = inspect.cleandoc(func.__doc__)
if "\nNotes\n-----" in doc:
before, after = doc.split("\nNotes\n-----", 1)
elif (index := doc.find("\nReferences\n----------")) != -1:
before, after = doc[:index], doc[index:]
elif (index := doc.find("\nExamples\n--------")) != -1:
before, after = doc[:index], doc[index:]
else:
# No "Notes", "References", or "Examples" --> append to the end.
before = doc + "\n"
after = ""
func.__doc__ = f"{before}\nNotes\n-----\n\n.. note::\n\n {message}\n{after}"
## Global ##
# The state controlled by {,un}install_repl_displayhook().
_ReplDisplayHook = Enum("_ReplDisplayHook", ["NONE", "PLAIN", "IPYTHON"])
_REPL_DISPLAYHOOK = _ReplDisplayHook.NONE
def _draw_all_if_interactive() -> None:
if matplotlib.is_interactive():
draw_all()
def install_repl_displayhook() -> None:
"""
Connect to the display hook of the current shell.
The display hook gets called when the read-evaluate-print-loop (REPL) of
the shell has finished the execution of a command. We use this callback
to be able to automatically update a figure in interactive mode.
This works both with IPython and with vanilla python shells.
"""
global _REPL_DISPLAYHOOK
if _REPL_DISPLAYHOOK is _ReplDisplayHook.IPYTHON:
return
# See if we have IPython hooks around, if so use them.
# Use ``sys.modules.get(name)`` rather than ``name in sys.modules`` as
# entries can also have been explicitly set to None.
mod_ipython = sys.modules.get("IPython")
if not mod_ipython:
_REPL_DISPLAYHOOK = _ReplDisplayHook.PLAIN
return
ip = mod_ipython.get_ipython()
if not ip:
_REPL_DISPLAYHOOK = _ReplDisplayHook.PLAIN
return
ip.events.register("post_execute", _draw_all_if_interactive)
_REPL_DISPLAYHOOK = _ReplDisplayHook.IPYTHON
if mod_ipython.version_info[:2] < (8, 24):
# Use of backend2gui is not needed for IPython >= 8.24 as that functionality
# has been moved to Matplotlib.
# This code can be removed when Python 3.12, the latest version supported by
# IPython < 8.24, reaches end-of-life in late 2028.
from IPython.core.pylabtools import backend2gui
ipython_gui_name = backend2gui.get(get_backend())
else:
_, ipython_gui_name = backend_registry.resolve_backend(get_backend())
# trigger IPython's eventloop integration, if available
if ipython_gui_name:
ip.enable_gui(ipython_gui_name)
def uninstall_repl_displayhook() -> None:
"""Disconnect from the display hook of the current shell."""
global _REPL_DISPLAYHOOK
if _REPL_DISPLAYHOOK is _ReplDisplayHook.IPYTHON:
from IPython import get_ipython
ip = get_ipython()
ip.events.unregister("post_execute", _draw_all_if_interactive)
_REPL_DISPLAYHOOK = _ReplDisplayHook.NONE
draw_all = _pylab_helpers.Gcf.draw_all
# Ensure this appears in the pyplot docs.
@_copy_docstring_and_deprecators(matplotlib.set_loglevel)
def set_loglevel(*args, **kwargs) -> None:
return matplotlib.set_loglevel(*args, **kwargs)
@_copy_docstring_and_deprecators(Artist.findobj)
def findobj(
o: Artist | None = None,
match: Callable[[Artist], bool] | type[Artist] | None = None,
include_self: bool = True
) -> list[Artist]:
if o is None:
o = gcf()
return o.findobj(match, include_self=include_self)
_backend_mod: type[matplotlib.backend_bases._Backend] | None = None
def _get_backend_mod() -> type[matplotlib.backend_bases._Backend]:
"""
Ensure that a backend is selected and return it.
This is currently private, but may be made public in the future.
"""
if _backend_mod is None:
# Use rcParams._get("backend") to avoid going through the fallback
# logic (which will (re)import pyplot and then call switch_backend if
# we need to resolve the auto sentinel)
switch_backend(rcParams._get("backend"))
return cast(type[matplotlib.backend_bases._Backend], _backend_mod)
def switch_backend(newbackend: str) -> None:
"""
Set the pyplot backend.
Switching to an interactive backend is possible only if no event loop for
another interactive backend has started. Switching to and from
non-interactive backends is always possible.
If the new backend is different than the current backend then all open
Figures will be closed via ``plt.close('all')``.
Parameters
----------
newbackend : str
The case-insensitive name of the backend to use.
"""
global _backend_mod
# make sure the init is pulled up so we can assign to it later
import matplotlib.backends
if newbackend is rcsetup._auto_backend_sentinel:
current_framework = cbook._get_running_interactive_framework()
if (current_framework and
(backend := backend_registry.backend_for_gui_framework(
current_framework))):
candidates = [backend]
else:
candidates = []
candidates += [
"macosx", "qtagg", "gtk4agg", "gtk3agg", "tkagg", "wxagg"]
# Don't try to fallback on the cairo-based backends as they each have
# an additional dependency (pycairo) over the agg-based backend, and
# are of worse quality.
for candidate in candidates:
try:
switch_backend(candidate)
except ImportError:
continue
else:
rcParamsOrig['backend'] = candidate
return
else:
# Switching to Agg should always succeed; if it doesn't, let the
# exception propagate out.
switch_backend("agg")
rcParamsOrig["backend"] = "agg"
return
# have to escape the switch on access logic
old_backend = dict.__getitem__(rcParams, 'backend')
module = backend_registry.load_backend_module(newbackend)
canvas_class = module.FigureCanvas
required_framework = canvas_class.required_interactive_framework
if required_framework is not None:
current_framework = cbook._get_running_interactive_framework()
if (current_framework and required_framework
and current_framework != required_framework):
raise ImportError(
"Cannot load backend {!r} which requires the {!r} interactive "
"framework, as {!r} is currently running".format(
newbackend, required_framework, current_framework))
# Load the new_figure_manager() and show() functions from the backend.
# Classically, backends can directly export these functions. This should
# keep working for backcompat.
new_figure_manager = getattr(module, "new_figure_manager", None)
show = getattr(module, "show", None)
# In that classical approach, backends are implemented as modules, but
# "inherit" default method implementations from backend_bases._Backend.
# This is achieved by creating a "class" that inherits from
# backend_bases._Backend and whose body is filled with the module globals.
class backend_mod(matplotlib.backend_bases._Backend):
locals().update(vars(module))
# However, the newer approach for defining new_figure_manager and
# show is to derive them from canvas methods. In that case, also
# update backend_mod accordingly; also, per-backend customization of
# draw_if_interactive is disabled.
if new_figure_manager is None:
def new_figure_manager_given_figure(num, figure):
return canvas_class.new_manager(figure, num)
def new_figure_manager(num, *args, FigureClass=Figure, **kwargs):
fig = FigureClass(*args, **kwargs)
return new_figure_manager_given_figure(num, fig)
def draw_if_interactive() -> None:
if matplotlib.is_interactive():
manager = _pylab_helpers.Gcf.get_active()
if manager:
manager.canvas.draw_idle()
backend_mod.new_figure_manager_given_figure = ( # type: ignore[method-assign]
new_figure_manager_given_figure)
backend_mod.new_figure_manager = ( # type: ignore[method-assign]
new_figure_manager)
backend_mod.draw_if_interactive = ( # type: ignore[method-assign]
draw_if_interactive)
# If the manager explicitly overrides pyplot_show, use it even if a global
# show is already present, as the latter may be here for backcompat.
manager_class = getattr(canvas_class, "manager_class", None)
# We can't compare directly manager_class.pyplot_show and FMB.pyplot_show because
# pyplot_show is a classmethod so the above constructs are bound classmethods, and
# thus always different (being bound to different classes). We also have to use
# getattr_static instead of vars as manager_class could have no __dict__.
manager_pyplot_show = inspect.getattr_static(manager_class, "pyplot_show", None)
base_pyplot_show = inspect.getattr_static(FigureManagerBase, "pyplot_show", None)
if (show is None
or (manager_pyplot_show is not None
and manager_pyplot_show != base_pyplot_show)):
if not manager_pyplot_show:
raise ValueError(
f"Backend {newbackend} defines neither FigureCanvas.manager_class nor "
f"a toplevel show function")
_pyplot_show = cast('Any', manager_class).pyplot_show
backend_mod.show = _pyplot_show # type: ignore[method-assign]
_log.debug("Loaded backend %s version %s.",
newbackend, backend_mod.backend_version)
if newbackend in ("ipympl", "widget"):
# ipympl < 0.9.4 expects rcParams["backend"] to be the fully-qualified backend
# name "module://ipympl.backend_nbagg" not short names "ipympl" or "widget".
import importlib.metadata as im
from matplotlib import _parse_to_version_info # type: ignore[attr-defined]
try:
module_version = im.version("ipympl")
if _parse_to_version_info(module_version) < (0, 9, 4):
newbackend = "module://ipympl.backend_nbagg"
except im.PackageNotFoundError:
pass
rcParams['backend'] = rcParamsDefault['backend'] = newbackend
_backend_mod = backend_mod
for func_name in ["new_figure_manager", "draw_if_interactive", "show"]:
globals()[func_name].__signature__ = inspect.signature(
getattr(backend_mod, func_name))
# Need to keep a global reference to the backend for compatibility reasons.
# See https://github.com/matplotlib/matplotlib/issues/6092
matplotlib.backends.backend = newbackend # type: ignore[attr-defined]
if not cbook._str_equal(old_backend, newbackend):
if get_fignums():
_api.warn_deprecated("3.8", message=(
"Auto-close()ing of figures upon backend switching is deprecated since "
"%(since)s and will be removed %(removal)s. To suppress this warning, "
"explicitly call plt.close('all') first."))
close("all")
# Make sure the repl display hook is installed in case we become interactive.
install_repl_displayhook()
def _warn_if_gui_out_of_main_thread() -> None:
warn = False
canvas_class = cast(type[FigureCanvasBase], _get_backend_mod().FigureCanvas)
if canvas_class.required_interactive_framework:
if hasattr(threading, 'get_native_id'):
# This compares native thread ids because even if Python-level
# Thread objects match, the underlying OS thread (which is what
# really matters) may be different on Python implementations with
# green threads.
if threading.get_native_id() != threading.main_thread().native_id:
warn = True
else:
# Fall back to Python-level Thread if native IDs are unavailable,
# mainly for PyPy.
if threading.current_thread() is not threading.main_thread():
warn = True
if warn:
_api.warn_external(
"Starting a Matplotlib GUI outside of the main thread will likely "
"fail.")
# This function's signature is rewritten upon backend-load by switch_backend.
def new_figure_manager(*args, **kwargs):
"""Create a new figure manager instance."""
_warn_if_gui_out_of_main_thread()
return _get_backend_mod().new_figure_manager(*args, **kwargs)
# This function's signature is rewritten upon backend-load by switch_backend.
def draw_if_interactive(*args, **kwargs):
"""
Redraw the current figure if in interactive mode.
.. warning::
End users will typically not have to call this function because the
the interactive mode takes care of this.
"""
return _get_backend_mod().draw_if_interactive(*args, **kwargs)
# This function's signature is rewritten upon backend-load by switch_backend.
def show(*args, **kwargs) -> None:
"""
Display all open figures.
Parameters
----------
block : bool, optional
Whether to wait for all figures to be closed before returning.
If `True` block and run the GUI main loop until all figure windows
are closed.
If `False` ensure that all figure windows are displayed and return
immediately. In this case, you are responsible for ensuring
that the event loop is running to have responsive figures.
Defaults to True in non-interactive mode and to False in interactive
mode (see `.pyplot.isinteractive`).
See Also
--------
ion : Enable interactive mode, which shows / updates the figure after
every plotting command, so that calling ``show()`` is not necessary.
ioff : Disable interactive mode.
savefig : Save the figure to an image file instead of showing it on screen.
Notes
-----
**Saving figures to file and showing a window at the same time**
If you want an image file as well as a user interface window, use
`.pyplot.savefig` before `.pyplot.show`. At the end of (a blocking)
``show()`` the figure is closed and thus unregistered from pyplot. Calling
`.pyplot.savefig` afterwards would save a new and thus empty figure. This
limitation of command order does not apply if the show is non-blocking or
if you keep a reference to the figure and use `.Figure.savefig`.
**Auto-show in jupyter notebooks**
The jupyter backends (activated via ``%matplotlib inline``,
``%matplotlib notebook``, or ``%matplotlib widget``), call ``show()`` at
the end of every cell by default. Thus, you usually don't have to call it
explicitly there.
"""
_warn_if_gui_out_of_main_thread()
return _get_backend_mod().show(*args, **kwargs)
def isinteractive() -> bool:
"""
Return whether plots are updated after every plotting command.
The interactive mode is mainly useful if you build plots from the command
line and want to see the effect of each command while you are building the
figure.
In interactive mode:
- newly created figures will be shown immediately;
- figures will automatically redraw on change;
- `.pyplot.show` will not block by default.
In non-interactive mode:
- newly created figures and changes to figures will not be reflected until
explicitly asked to be;
- `.pyplot.show` will block by default.
See Also
--------
ion : Enable interactive mode.
ioff : Disable interactive mode.
show : Show all figures (and maybe block).
pause : Show all figures, and block for a time.
"""
return matplotlib.is_interactive()
# Note: The return type of ioff being AbstractContextManager
# instead of ExitStack is deliberate.
# See https://github.com/matplotlib/matplotlib/issues/27659
# and https://github.com/matplotlib/matplotlib/pull/27667 for more info.
def ioff() -> AbstractContextManager:
"""
Disable interactive mode.
See `.pyplot.isinteractive` for more details.
See Also
--------
ion : Enable interactive mode.
isinteractive : Whether interactive mode is enabled.
show : Show all figures (and maybe block).
pause : Show all figures, and block for a time.
Notes
-----
For a temporary change, this can be used as a context manager::
# if interactive mode is on
# then figures will be shown on creation
plt.ion()
# This figure will be shown immediately
fig = plt.figure()
with plt.ioff():
# interactive mode will be off
# figures will not automatically be shown
fig2 = plt.figure()
# ...
To enable optional usage as a context manager, this function returns a
context manager object, which is not intended to be stored or
accessed by the user.
"""
stack = ExitStack()
stack.callback(ion if isinteractive() else ioff)
matplotlib.interactive(False)
uninstall_repl_displayhook()
return stack
# Note: The return type of ion being AbstractContextManager
# instead of ExitStack is deliberate.
# See https://github.com/matplotlib/matplotlib/issues/27659
# and https://github.com/matplotlib/matplotlib/pull/27667 for more info.
def ion() -> AbstractContextManager:
"""
Enable interactive mode.
See `.pyplot.isinteractive` for more details.
See Also
--------
ioff : Disable interactive mode.
isinteractive : Whether interactive mode is enabled.
show : Show all figures (and maybe block).
pause : Show all figures, and block for a time.
Notes
-----
For a temporary change, this can be used as a context manager::
# if interactive mode is off
# then figures will not be shown on creation
plt.ioff()
# This figure will not be shown immediately
fig = plt.figure()
with plt.ion():
# interactive mode will be on
# figures will automatically be shown
fig2 = plt.figure()
# ...
To enable optional usage as a context manager, this function returns a
context manager object, which is not intended to be stored or
accessed by the user.
"""
stack = ExitStack()
stack.callback(ion if isinteractive() else ioff)
matplotlib.interactive(True)
install_repl_displayhook()
return stack
def pause(interval: float) -> None:
"""
Run the GUI event loop for *interval* seconds.
If there is an active figure, it will be updated and displayed before the
pause, and the GUI event loop (if any) will run during the pause.
This can be used for crude animation. For more complex animation use
:mod:`matplotlib.animation`.
If there is no active figure, sleep for *interval* seconds instead.
See Also
--------
matplotlib.animation : Proper animations
show : Show all figures and optional block until all figures are closed.
"""
manager = _pylab_helpers.Gcf.get_active()
if manager is not None:
canvas = manager.canvas
if canvas.figure.stale:
canvas.draw_idle()
show(block=False)
canvas.start_event_loop(interval)
else:
time.sleep(interval)
@_copy_docstring_and_deprecators(matplotlib.rc)
def rc(group: str, **kwargs) -> None:
matplotlib.rc(group, **kwargs)
@_copy_docstring_and_deprecators(matplotlib.rc_context)
def rc_context(
rc: dict[str, Any] | None = None,
fname: str | pathlib.Path | os.PathLike | None = None,
) -> AbstractContextManager[None]:
return matplotlib.rc_context(rc, fname)
@_copy_docstring_and_deprecators(matplotlib.rcdefaults)
def rcdefaults() -> None:
matplotlib.rcdefaults()
if matplotlib.is_interactive():
draw_all()
# getp/get/setp are explicitly reexported so that they show up in pyplot docs.
@_copy_docstring_and_deprecators(matplotlib.artist.getp)
def getp(obj, *args, **kwargs):
return matplotlib.artist.getp(obj, *args, **kwargs)
@_copy_docstring_and_deprecators(matplotlib.artist.get)
def get(obj, *args, **kwargs):
return matplotlib.artist.get(obj, *args, **kwargs)
@_copy_docstring_and_deprecators(matplotlib.artist.setp)
def setp(obj, *args, **kwargs):
return matplotlib.artist.setp(obj, *args, **kwargs)
def xkcd(
scale: float = 1, length: float = 100, randomness: float = 2
) -> ExitStack:
"""
Turn on `xkcd <https://xkcd.com/>`_ sketch-style drawing mode.
This will only have an effect on things drawn after this function is called.
For best results, install the `xkcd script <https://github.com/ipython/xkcd-font/>`_
font; xkcd fonts are not packaged with Matplotlib.
Parameters
----------
scale : float, optional
The amplitude of the wiggle perpendicular to the source line.
length : float, optional
The length of the wiggle along the line.
randomness : float, optional
The scale factor by which the length is shrunken or expanded.
Notes
-----
This function works by a number of rcParams, so it will probably
override others you have set before.
If you want the effects of this function to be temporary, it can
be used as a context manager, for example::
with plt.xkcd():
# This figure will be in XKCD-style
fig1 = plt.figure()
# ...
# This figure will be in regular style
fig2 = plt.figure()
"""
# This cannot be implemented in terms of contextmanager() or rc_context()
# because this needs to work as a non-contextmanager too.
if rcParams['text.usetex']:
raise RuntimeError(
"xkcd mode is not compatible with text.usetex = True")
stack = ExitStack()
stack.callback(dict.update, rcParams, rcParams.copy()) # type: ignore[arg-type]
from matplotlib import patheffects
rcParams.update({
'font.family': ['xkcd', 'xkcd Script', 'Comic Neue', 'Comic Sans MS'],
'font.size': 14.0,
'path.sketch': (scale, length, randomness),
'path.effects': [
patheffects.withStroke(linewidth=4, foreground="w")],
'axes.linewidth': 1.5,
'lines.linewidth': 2.0,
'figure.facecolor': 'white',
'grid.linewidth': 0.0,
'axes.grid': False,
'axes.unicode_minus': False,
'axes.edgecolor': 'black',
'xtick.major.size': 8,
'xtick.major.width': 3,
'ytick.major.size': 8,
'ytick.major.width': 3,
})
return stack
## Figures ##
def figure(
# autoincrement if None, else integer from 1-N
num: int | str | Figure | SubFigure | None = None,
# defaults to rc figure.figsize
figsize: tuple[float, float] | None = None,
# defaults to rc figure.dpi
dpi: float | None = None,
*,
# defaults to rc figure.facecolor
facecolor: ColorType | None = None,
# defaults to rc figure.edgecolor
edgecolor: ColorType | None = None,
frameon: bool = True,
FigureClass: type[Figure] = Figure,
clear: bool = False,
**kwargs
) -> Figure:
"""
Create a new figure, or activate an existing figure.
Parameters
----------
num : int or str or `.Figure` or `.SubFigure`, optional
A unique identifier for the figure.
If a figure with that identifier already exists, this figure is made
active and returned. An integer refers to the ``Figure.number``
attribute, a string refers to the figure label.
If there is no figure with the identifier or *num* is not given, a new
figure is created, made active and returned. If *num* is an int, it
will be used for the ``Figure.number`` attribute, otherwise, an
auto-generated integer value is used (starting at 1 and incremented
for each new figure). If *num* is a string, the figure label and the
window title is set to this value. If num is a ``SubFigure``, its
parent ``Figure`` is activated.
figsize : (float, float), default: :rc:`figure.figsize`
Width, height in inches.
dpi : float, default: :rc:`figure.dpi`
The resolution of the figure in dots-per-inch.
facecolor : :mpltype:`color`, default: :rc:`figure.facecolor`
The background color.
edgecolor : :mpltype:`color`, default: :rc:`figure.edgecolor`
The border color.
frameon : bool, default: True
If False, suppress drawing the figure frame.
FigureClass : subclass of `~matplotlib.figure.Figure`
If set, an instance of this subclass will be created, rather than a
plain `.Figure`.
clear : bool, default: False
If True and the figure already exists, then it is cleared.
layout : {'constrained', 'compressed', 'tight', 'none', `.LayoutEngine`, None}, \
default: None
The layout mechanism for positioning of plot elements to avoid
overlapping Axes decorations (labels, ticks, etc). Note that layout
managers can measurably slow down figure display.
- 'constrained': The constrained layout solver adjusts Axes sizes
to avoid overlapping Axes decorations. Can handle complex plot
layouts and colorbars, and is thus recommended.
See :ref:`constrainedlayout_guide`
for examples.
- 'compressed': uses the same algorithm as 'constrained', but
removes extra space between fixed-aspect-ratio Axes. Best for
simple grids of Axes.
- 'tight': Use the tight layout mechanism. This is a relatively
simple algorithm that adjusts the subplot parameters so that
decorations do not overlap. See `.Figure.set_tight_layout` for
further details.
- 'none': Do not use a layout engine.
- A `.LayoutEngine` instance. Builtin layout classes are
`.ConstrainedLayoutEngine` and `.TightLayoutEngine`, more easily
accessible by 'constrained' and 'tight'. Passing an instance
allows third parties to provide their own layout engine.
If not given, fall back to using the parameters *tight_layout* and
*constrained_layout*, including their config defaults
:rc:`figure.autolayout` and :rc:`figure.constrained_layout.use`.
**kwargs
Additional keyword arguments are passed to the `.Figure` constructor.
Returns
-------
`~matplotlib.figure.Figure`
Notes
-----
A newly created figure is passed to the `~.FigureCanvasBase.new_manager`
method or the `new_figure_manager` function provided by the current
backend, which install a canvas and a manager on the figure.
Once this is done, :rc:`figure.hooks` are called, one at a time, on the
figure; these hooks allow arbitrary customization of the figure (e.g.,
attaching callbacks) or of associated elements (e.g., modifying the
toolbar). See :doc:`/gallery/user_interfaces/mplcvd` for an example of
toolbar customization.
If you are creating many figures, make sure you explicitly call
`.pyplot.close` on the figures you are not using, because this will
enable pyplot to properly clean up the memory.
`~matplotlib.rcParams` defines the default values, which can be modified
in the matplotlibrc file.
"""
if isinstance(num, FigureBase):
# type narrowed to `Figure | SubFigure` by combination of input and isinstance
if num.canvas.manager is None:
raise ValueError("The passed figure is not managed by pyplot")
_pylab_helpers.Gcf.set_active(num.canvas.manager)
return num.figure
allnums = get_fignums()
next_num = max(allnums) + 1 if allnums else 1
fig_label = ''
if num is None:
num = next_num
elif isinstance(num, str):
fig_label = num
all_labels = get_figlabels()
if fig_label not in all_labels:
if fig_label == 'all':
_api.warn_external("close('all') closes all existing figures.")
num = next_num
else:
inum = all_labels.index(fig_label)
num = allnums[inum]
else:
num = int(num) # crude validation of num argument
# Type of "num" has narrowed to int, but mypy can't quite see it
manager = _pylab_helpers.Gcf.get_fig_manager(num) # type: ignore[arg-type]
if manager is None:
max_open_warning = rcParams['figure.max_open_warning']
if len(allnums) == max_open_warning >= 1:
_api.warn_external(
f"More than {max_open_warning} figures have been opened. "
f"Figures created through the pyplot interface "
f"(`matplotlib.pyplot.figure`) are retained until explicitly "
f"closed and may consume too much memory. (To control this "
f"warning, see the rcParam `figure.max_open_warning`). "
f"Consider using `matplotlib.pyplot.close()`.",
RuntimeWarning)
manager = new_figure_manager(
num, figsize=figsize, dpi=dpi,
facecolor=facecolor, edgecolor=edgecolor, frameon=frameon,
FigureClass=FigureClass, **kwargs)
fig = manager.canvas.figure
if fig_label:
fig.set_label(fig_label)
for hookspecs in rcParams["figure.hooks"]:
module_name, dotted_name = hookspecs.split(":")
obj: Any = importlib.import_module(module_name)
for part in dotted_name.split("."):
obj = getattr(obj, part)
obj(fig)
_pylab_helpers.Gcf._set_new_active_manager(manager)
# make sure backends (inline) that we don't ship that expect this
# to be called in plotting commands to make the figure call show
# still work. There is probably a better way to do this in the
# FigureManager base class.
draw_if_interactive()
if _REPL_DISPLAYHOOK is _ReplDisplayHook.PLAIN:
fig.stale_callback = _auto_draw_if_interactive
if clear:
manager.canvas.figure.clear()
return manager.canvas.figure
def _auto_draw_if_interactive(fig, val):
"""
An internal helper function for making sure that auto-redrawing
works as intended in the plain python repl.
Parameters
----------
fig : Figure
A figure object which is assumed to be associated with a canvas
"""
if (val and matplotlib.is_interactive()
and not fig.canvas.is_saving()
and not fig.canvas._is_idle_drawing):
# Some artists can mark themselves as stale in the middle of drawing
# (e.g. axes position & tick labels being computed at draw time), but
# this shouldn't trigger a redraw because the current redraw will
# already take them into account.
with fig.canvas._idle_draw_cntx():
fig.canvas.draw_idle()
def gcf() -> Figure:
"""
Get the current figure.
If there is currently no figure on the pyplot figure stack, a new one is
created using `~.pyplot.figure()`. (To test whether there is currently a
figure on the pyplot figure stack, check whether `~.pyplot.get_fignums()`
is empty.)
"""
manager = _pylab_helpers.Gcf.get_active()
if manager is not None:
return manager.canvas.figure
else:
return figure()
def fignum_exists(num: int | str) -> bool:
"""
Return whether the figure with the given id exists.
Parameters
----------
num : int or str
A figure identifier.
Returns
-------
bool
Whether or not a figure with id *num* exists.
"""
return (
_pylab_helpers.Gcf.has_fignum(num)
if isinstance(num, int)
else num in get_figlabels()
)
def get_fignums() -> list[int]:
"""Return a list of existing figure numbers."""
return sorted(_pylab_helpers.Gcf.figs)
def get_figlabels() -> list[Any]:
"""Return a list of existing figure labels."""
managers = _pylab_helpers.Gcf.get_all_fig_managers()
managers.sort(key=lambda m: m.num)
return [m.canvas.figure.get_label() for m in managers]
def get_current_fig_manager() -> FigureManagerBase | None:
"""
Return the figure manager of the current figure.
The figure manager is a container for the actual backend-depended window
that displays the figure on screen.
If no current figure exists, a new one is created, and its figure
manager is returned.
Returns
-------
`.FigureManagerBase` or backend-dependent subclass thereof
"""
return gcf().canvas.manager
@_copy_docstring_and_deprecators(FigureCanvasBase.mpl_connect)
def connect(s: str, func: Callable[[Event], Any]) -> int:
return gcf().canvas.mpl_connect(s, func)
@_copy_docstring_and_deprecators(FigureCanvasBase.mpl_disconnect)
def disconnect(cid: int) -> None:
gcf().canvas.mpl_disconnect(cid)
def close(fig: None | int | str | Figure | Literal["all"] = None) -> None:
"""
Close a figure window.
Parameters
----------
fig : None or int or str or `.Figure`
The figure to close. There are a number of ways to specify this:
- *None*: the current figure
- `.Figure`: the given `.Figure` instance
- ``int``: a figure number
- ``str``: a figure name
- 'all': all figures
"""
if fig is None:
manager = _pylab_helpers.Gcf.get_active()
if manager is None:
return
else:
_pylab_helpers.Gcf.destroy(manager)
elif fig == 'all':
_pylab_helpers.Gcf.destroy_all()
elif isinstance(fig, int):
_pylab_helpers.Gcf.destroy(fig)
elif hasattr(fig, 'int'):
# if we are dealing with a type UUID, we
# can use its integer representation
_pylab_helpers.Gcf.destroy(fig.int)
elif isinstance(fig, str):
all_labels = get_figlabels()
if fig in all_labels:
num = get_fignums()[all_labels.index(fig)]
_pylab_helpers.Gcf.destroy(num)
elif isinstance(fig, Figure):
_pylab_helpers.Gcf.destroy_fig(fig)
else:
raise TypeError("close() argument must be a Figure, an int, a string, "
"or None, not %s" % type(fig))
def clf() -> None:
"""Clear the current figure."""
gcf().clear()
def draw() -> None:
"""
Redraw the current figure.
This is used to update a figure that has been altered, but not
automatically re-drawn. If interactive mode is on (via `.ion()`), this
should be only rarely needed, but there may be ways to modify the state of
a figure without marking it as "stale". Please report these cases as bugs.
This is equivalent to calling ``fig.canvas.draw_idle()``, where ``fig`` is
the current figure.
See Also
--------
.FigureCanvasBase.draw_idle
.FigureCanvasBase.draw
"""
gcf().canvas.draw_idle()
@_copy_docstring_and_deprecators(Figure.savefig)
def savefig(*args, **kwargs) -> None:
fig = gcf()
# savefig default implementation has no return, so mypy is unhappy
# presumably this is here because subclasses can return?
res = fig.savefig(*args, **kwargs) # type: ignore[func-returns-value]
fig.canvas.draw_idle() # Need this if 'transparent=True', to reset colors.
return res
## Putting things in figures ##
def figlegend(*args, **kwargs) -> Legend:
return gcf().legend(*args, **kwargs)
if Figure.legend.__doc__:
figlegend.__doc__ = Figure.legend.__doc__ \
.replace(" legend(", " figlegend(") \
.replace("fig.legend(", "plt.figlegend(") \
.replace("ax.plot(", "plt.plot(")
## Axes ##
@_docstring.dedent_interpd
def axes(
arg: None | tuple[float, float, float, float] = None,
**kwargs
) -> matplotlib.axes.Axes:
"""
Add an Axes to the current figure and make it the current Axes.
Call signatures::
plt.axes()
plt.axes(rect, projection=None, polar=False, **kwargs)
plt.axes(ax)
Parameters
----------
arg : None or 4-tuple
The exact behavior of this function depends on the type:
- *None*: A new full window Axes is added using
``subplot(**kwargs)``.
- 4-tuple of floats *rect* = ``(left, bottom, width, height)``.
A new Axes is added with dimensions *rect* in normalized
(0, 1) units using `~.Figure.add_axes` on the current figure.
projection : {None, 'aitoff', 'hammer', 'lambert', 'mollweide', \
'polar', 'rectilinear', str}, optional
The projection type of the `~.axes.Axes`. *str* is the name of
a custom projection, see `~matplotlib.projections`. The default
None results in a 'rectilinear' projection.
polar : bool, default: False
If True, equivalent to projection='polar'.
sharex, sharey : `~matplotlib.axes.Axes`, optional
Share the x or y `~matplotlib.axis` with sharex and/or sharey.
The axis will have the same limits, ticks, and scale as the axis
of the shared Axes.
label : str
A label for the returned Axes.
Returns
-------
`~.axes.Axes`, or a subclass of `~.axes.Axes`
The returned Axes class depends on the projection used. It is
`~.axes.Axes` if rectilinear projection is used and
`.projections.polar.PolarAxes` if polar projection is used.
Other Parameters
----------------
**kwargs
This method also takes the keyword arguments for
the returned Axes class. The keyword arguments for the
rectilinear Axes class `~.axes.Axes` can be found in
the following table but there might also be other keyword
arguments if another projection is used, see the actual Axes
class.
%(Axes:kwdoc)s
See Also
--------
.Figure.add_axes
.pyplot.subplot
.Figure.add_subplot
.Figure.subplots
.pyplot.subplots
Examples
--------
::
# Creating a new full window Axes
plt.axes()
# Creating a new Axes with specified dimensions and a grey background
plt.axes((left, bottom, width, height), facecolor='grey')
"""
fig = gcf()
pos = kwargs.pop('position', None)
if arg is None:
if pos is None:
return fig.add_subplot(**kwargs)
else:
return fig.add_axes(pos, **kwargs)
else:
return fig.add_axes(arg, **kwargs)
def delaxes(ax: matplotlib.axes.Axes | None = None) -> None:
"""
Remove an `~.axes.Axes` (defaulting to the current Axes) from its figure.
"""
if ax is None:
ax = gca()
ax.remove()
def sca(ax: Axes) -> None:
"""
Set the current Axes to *ax* and the current Figure to the parent of *ax*.
"""
# Mypy sees ax.figure as potentially None,
# but if you are calling this, it won't be None
# Additionally the slight difference between `Figure` and `FigureBase` mypy catches
figure(ax.figure) # type: ignore[arg-type]
ax.figure.sca(ax) # type: ignore[union-attr]
def cla() -> None:
"""Clear the current Axes."""
# Not generated via boilerplate.py to allow a different docstring.
return gca().cla()
## More ways of creating Axes ##
@_docstring.dedent_interpd
def subplot(*args, **kwargs) -> Axes:
"""
Add an Axes to the current figure or retrieve an existing Axes.
This is a wrapper of `.Figure.add_subplot` which provides additional
behavior when working with the implicit API (see the notes section).
Call signatures::
subplot(nrows, ncols, index, **kwargs)
subplot(pos, **kwargs)
subplot(**kwargs)
subplot(ax)
Parameters
----------
*args : int, (int, int, *index*), or `.SubplotSpec`, default: (1, 1, 1)
The position of the subplot described by one of
- Three integers (*nrows*, *ncols*, *index*). The subplot will take the
*index* position on a grid with *nrows* rows and *ncols* columns.
*index* starts at 1 in the upper left corner and increases to the
right. *index* can also be a two-tuple specifying the (*first*,
*last*) indices (1-based, and including *last*) of the subplot, e.g.,
``fig.add_subplot(3, 1, (1, 2))`` makes a subplot that spans the
upper 2/3 of the figure.
- A 3-digit integer. The digits are interpreted as if given separately
as three single-digit integers, i.e. ``fig.add_subplot(235)`` is the
same as ``fig.add_subplot(2, 3, 5)``. Note that this can only be used
if there are no more than 9 subplots.
- A `.SubplotSpec`.
projection : {None, 'aitoff', 'hammer', 'lambert', 'mollweide', \
'polar', 'rectilinear', str}, optional
The projection type of the subplot (`~.axes.Axes`). *str* is the name
of a custom projection, see `~matplotlib.projections`. The default
None results in a 'rectilinear' projection.
polar : bool, default: False
If True, equivalent to projection='polar'.
sharex, sharey : `~matplotlib.axes.Axes`, optional
Share the x or y `~matplotlib.axis` with sharex and/or sharey. The
axis will have the same limits, ticks, and scale as the axis of the
shared Axes.
label : str
A label for the returned Axes.
Returns
-------
`~.axes.Axes`
The Axes of the subplot. The returned Axes can actually be an instance
of a subclass, such as `.projections.polar.PolarAxes` for polar
projections.
Other Parameters
----------------
**kwargs
This method also takes the keyword arguments for the returned Axes
base class; except for the *figure* argument. The keyword arguments
for the rectilinear base class `~.axes.Axes` can be found in
the following table but there might also be other keyword
arguments if another projection is used.
%(Axes:kwdoc)s
Notes
-----
Creating a new Axes will delete any preexisting Axes that
overlaps with it beyond sharing a boundary::
import matplotlib.pyplot as plt
# plot a line, implicitly creating a subplot(111)
plt.plot([1, 2, 3])
# now create a subplot which represents the top plot of a grid
# with 2 rows and 1 column. Since this subplot will overlap the
# first, the plot (and its Axes) previously created, will be removed
plt.subplot(211)
If you do not want this behavior, use the `.Figure.add_subplot` method
or the `.pyplot.axes` function instead.
If no *kwargs* are passed and there exists an Axes in the location
specified by *args* then that Axes will be returned rather than a new
Axes being created.
If *kwargs* are passed and there exists an Axes in the location
specified by *args*, the projection type is the same, and the
*kwargs* match with the existing Axes, then the existing Axes is
returned. Otherwise a new Axes is created with the specified
parameters. We save a reference to the *kwargs* which we use
for this comparison. If any of the values in *kwargs* are
mutable we will not detect the case where they are mutated.
In these cases we suggest using `.Figure.add_subplot` and the
explicit Axes API rather than the implicit pyplot API.
See Also
--------
.Figure.add_subplot
.pyplot.subplots
.pyplot.axes
.Figure.subplots
Examples
--------
::
plt.subplot(221)
# equivalent but more general
ax1 = plt.subplot(2, 2, 1)
# add a subplot with no frame
ax2 = plt.subplot(222, frameon=False)
# add a polar subplot
plt.subplot(223, projection='polar')
# add a red subplot that shares the x-axis with ax1
plt.subplot(224, sharex=ax1, facecolor='red')
# delete ax2 from the figure
plt.delaxes(ax2)
# add ax2 to the figure again
plt.subplot(ax2)
# make the first Axes "current" again
plt.subplot(221)
"""
# Here we will only normalize `polar=True` vs `projection='polar'` and let
# downstream code deal with the rest.
unset = object()
projection = kwargs.get('projection', unset)
polar = kwargs.pop('polar', unset)
if polar is not unset and polar:
# if we got mixed messages from the user, raise
if projection is not unset and projection != 'polar':
raise ValueError(
f"polar={polar}, yet projection={projection!r}. "
"Only one of these arguments should be supplied."
)
kwargs['projection'] = projection = 'polar'
# if subplot called without arguments, create subplot(1, 1, 1)
if len(args) == 0:
args = (1, 1, 1)
# This check was added because it is very easy to type subplot(1, 2, False)
# when subplots(1, 2, False) was intended (sharex=False, that is). In most
# cases, no error will ever occur, but mysterious behavior can result
# because what was intended to be the sharex argument is instead treated as
# a subplot index for subplot()
if len(args) >= 3 and isinstance(args[2], bool):
_api.warn_external("The subplot index argument to subplot() appears "
"to be a boolean. Did you intend to use "
"subplots()?")
# Check for nrows and ncols, which are not valid subplot args:
if 'nrows' in kwargs or 'ncols' in kwargs:
raise TypeError("subplot() got an unexpected keyword argument 'ncols' "
"and/or 'nrows'. Did you intend to call subplots()?")
fig = gcf()
# First, search for an existing subplot with a matching spec.
key = SubplotSpec._from_subplot_args(fig, args)
for ax in fig.axes:
# If we found an Axes at the position, we can reuse it if the user passed no
# kwargs or if the Axes class and kwargs are identical.
if (ax.get_subplotspec() == key
and (kwargs == {}
or (ax._projection_init
== fig._process_projection_requirements(**kwargs)))):
break
else:
# we have exhausted the known Axes and none match, make a new one!
ax = fig.add_subplot(*args, **kwargs)
fig.sca(ax)
return ax
@overload
def subplots(
nrows: Literal[1] = ...,
ncols: Literal[1] = ...,
*,
sharex: bool | Literal["none", "all", "row", "col"] = ...,
sharey: bool | Literal["none", "all", "row", "col"] = ...,
squeeze: Literal[True] = ...,
width_ratios: Sequence[float] | None = ...,
height_ratios: Sequence[float] | None = ...,
subplot_kw: dict[str, Any] | None = ...,
gridspec_kw: dict[str, Any] | None = ...,
**fig_kw
) -> tuple[Figure, Axes]:
...
@overload
def subplots(
nrows: int = ...,
ncols: int = ...,
*,
sharex: bool | Literal["none", "all", "row", "col"] = ...,
sharey: bool | Literal["none", "all", "row", "col"] = ...,
squeeze: Literal[False],
width_ratios: Sequence[float] | None = ...,
height_ratios: Sequence[float] | None = ...,
subplot_kw: dict[str, Any] | None = ...,
gridspec_kw: dict[str, Any] | None = ...,
**fig_kw
) -> tuple[Figure, np.ndarray]: # TODO numpy/numpy#24738
...
@overload
def subplots(
nrows: int = ...,
ncols: int = ...,
*,
sharex: bool | Literal["none", "all", "row", "col"] = ...,
sharey: bool | Literal["none", "all", "row", "col"] = ...,
squeeze: bool = ...,
width_ratios: Sequence[float] | None = ...,
height_ratios: Sequence[float] | None = ...,
subplot_kw: dict[str, Any] | None = ...,
gridspec_kw: dict[str, Any] | None = ...,
**fig_kw
) -> tuple[Figure, Any]:
...
def subplots(
nrows: int = 1, ncols: int = 1, *,
sharex: bool | Literal["none", "all", "row", "col"] = False,
sharey: bool | Literal["none", "all", "row", "col"] = False,
squeeze: bool = True,
width_ratios: Sequence[float] | None = None,
height_ratios: Sequence[float] | None = None,
subplot_kw: dict[str, Any] | None = None,
gridspec_kw: dict[str, Any] | None = None,
**fig_kw
) -> tuple[Figure, Any]:
"""
Create a figure and a set of subplots.
This utility wrapper makes it convenient to create common layouts of
subplots, including the enclosing figure object, in a single call.
Parameters
----------
nrows, ncols : int, default: 1
Number of rows/columns of the subplot grid.
sharex, sharey : bool or {'none', 'all', 'row', 'col'}, default: False
Controls sharing of properties among x (*sharex*) or y (*sharey*)
axes:
- True or 'all': x- or y-axis will be shared among all subplots.
- False or 'none': each subplot x- or y-axis will be independent.
- 'row': each subplot row will share an x- or y-axis.
- 'col': each subplot column will share an x- or y-axis.
When subplots have a shared x-axis along a column, only the x tick
labels of the bottom subplot are created. Similarly, when subplots
have a shared y-axis along a row, only the y tick labels of the first
column subplot are created. To later turn other subplots' ticklabels
on, use `~matplotlib.axes.Axes.tick_params`.
When subplots have a shared axis that has units, calling
`.Axis.set_units` will update each axis with the new units.
Note that it is not possible to unshare axes.
squeeze : bool, default: True
- If True, extra dimensions are squeezed out from the returned
array of `~matplotlib.axes.Axes`:
- if only one subplot is constructed (nrows=ncols=1), the
resulting single Axes object is returned as a scalar.
- for Nx1 or 1xM subplots, the returned object is a 1D numpy
object array of Axes objects.
- for NxM, subplots with N>1 and M>1 are returned as a 2D array.
- If False, no squeezing at all is done: the returned Axes object is
always a 2D array containing Axes instances, even if it ends up
being 1x1.
width_ratios : array-like of length *ncols*, optional
Defines the relative widths of the columns. Each column gets a
relative width of ``width_ratios[i] / sum(width_ratios)``.
If not given, all columns will have the same width. Equivalent
to ``gridspec_kw={'width_ratios': [...]}``.
height_ratios : array-like of length *nrows*, optional
Defines the relative heights of the rows. Each row gets a
relative height of ``height_ratios[i] / sum(height_ratios)``.
If not given, all rows will have the same height. Convenience
for ``gridspec_kw={'height_ratios': [...]}``.
subplot_kw : dict, optional
Dict with keywords passed to the
`~matplotlib.figure.Figure.add_subplot` call used to create each
subplot.
gridspec_kw : dict, optional
Dict with keywords passed to the `~matplotlib.gridspec.GridSpec`
constructor used to create the grid the subplots are placed on.
**fig_kw
All additional keyword arguments are passed to the
`.pyplot.figure` call.
Returns
-------
fig : `.Figure`
ax : `~matplotlib.axes.Axes` or array of Axes
*ax* can be either a single `~.axes.Axes` object, or an array of Axes
objects if more than one subplot was created. The dimensions of the
resulting array can be controlled with the squeeze keyword, see above.
Typical idioms for handling the return value are::
# using the variable ax for single a Axes
fig, ax = plt.subplots()
# using the variable axs for multiple Axes
fig, axs = plt.subplots(2, 2)
# using tuple unpacking for multiple Axes
fig, (ax1, ax2) = plt.subplots(1, 2)
fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2)
The names ``ax`` and pluralized ``axs`` are preferred over ``axes``
because for the latter it's not clear if it refers to a single
`~.axes.Axes` instance or a collection of these.
See Also
--------
.pyplot.figure
.pyplot.subplot
.pyplot.axes
.Figure.subplots
.Figure.add_subplot
Examples
--------
::
# First create some toy data:
x = np.linspace(0, 2*np.pi, 400)
y = np.sin(x**2)
# Create just a figure and only one subplot
fig, ax = plt.subplots()
ax.plot(x, y)
ax.set_title('Simple plot')
# Create two subplots and unpack the output array immediately
f, (ax1, ax2) = plt.subplots(1, 2, sharey=True)
ax1.plot(x, y)
ax1.set_title('Sharing Y axis')
ax2.scatter(x, y)
# Create four polar Axes and access them through the returned array
fig, axs = plt.subplots(2, 2, subplot_kw=dict(projection="polar"))
axs[0, 0].plot(x, y)
axs[1, 1].scatter(x, y)
# Share a X axis with each column of subplots
plt.subplots(2, 2, sharex='col')
# Share a Y axis with each row of subplots
plt.subplots(2, 2, sharey='row')
# Share both X and Y axes with all subplots
plt.subplots(2, 2, sharex='all', sharey='all')
# Note that this is the same as
plt.subplots(2, 2, sharex=True, sharey=True)
# Create figure number 10 with a single subplot
# and clears it if it already exists.
fig, ax = plt.subplots(num=10, clear=True)
"""
fig = figure(**fig_kw)
axs = fig.subplots(nrows=nrows, ncols=ncols, sharex=sharex, sharey=sharey,
squeeze=squeeze, subplot_kw=subplot_kw,
gridspec_kw=gridspec_kw, height_ratios=height_ratios,
width_ratios=width_ratios)
return fig, axs
@overload
def subplot_mosaic(
mosaic: str,
*,
sharex: bool = ...,
sharey: bool = ...,
width_ratios: ArrayLike | None = ...,
height_ratios: ArrayLike | None = ...,
empty_sentinel: str = ...,
subplot_kw: dict[str, Any] | None = ...,
gridspec_kw: dict[str, Any] | None = ...,
per_subplot_kw: dict[str | tuple[str, ...], dict[str, Any]] | None = ...,
**fig_kw: Any
) -> tuple[Figure, dict[str, matplotlib.axes.Axes]]: ...
@overload
def subplot_mosaic(
mosaic: list[HashableList[_T]],
*,
sharex: bool = ...,
sharey: bool = ...,
width_ratios: ArrayLike | None = ...,
height_ratios: ArrayLike | None = ...,
empty_sentinel: _T = ...,
subplot_kw: dict[str, Any] | None = ...,
gridspec_kw: dict[str, Any] | None = ...,
per_subplot_kw: dict[_T | tuple[_T, ...], dict[str, Any]] | None = ...,
**fig_kw: Any
) -> tuple[Figure, dict[_T, matplotlib.axes.Axes]]: ...
@overload
def subplot_mosaic(
mosaic: list[HashableList[Hashable]],
*,
sharex: bool = ...,
sharey: bool = ...,
width_ratios: ArrayLike | None = ...,
height_ratios: ArrayLike | None = ...,
empty_sentinel: Any = ...,
subplot_kw: dict[str, Any] | None = ...,
gridspec_kw: dict[str, Any] | None = ...,
per_subplot_kw: dict[Hashable | tuple[Hashable, ...], dict[str, Any]] | None = ...,
**fig_kw: Any
) -> tuple[Figure, dict[Hashable, matplotlib.axes.Axes]]: ...
def subplot_mosaic(
mosaic: str | list[HashableList[_T]] | list[HashableList[Hashable]],
*,
sharex: bool = False,
sharey: bool = False,
width_ratios: ArrayLike | None = None,
height_ratios: ArrayLike | None = None,
empty_sentinel: Any = '.',
subplot_kw: dict[str, Any] | None = None,
gridspec_kw: dict[str, Any] | None = None,
per_subplot_kw: dict[str | tuple[str, ...], dict[str, Any]] |
dict[_T | tuple[_T, ...], dict[str, Any]] |
dict[Hashable | tuple[Hashable, ...], dict[str, Any]] | None = None,
**fig_kw: Any
) -> tuple[Figure, dict[str, matplotlib.axes.Axes]] | \
tuple[Figure, dict[_T, matplotlib.axes.Axes]] | \
tuple[Figure, dict[Hashable, matplotlib.axes.Axes]]:
"""
Build a layout of Axes based on ASCII art or nested lists.
This is a helper function to build complex GridSpec layouts visually.
See :ref:`mosaic`
for an example and full API documentation
Parameters
----------
mosaic : list of list of {hashable or nested} or str
A visual layout of how you want your Axes to be arranged
labeled as strings. For example ::
x = [['A panel', 'A panel', 'edge'],
['C panel', '.', 'edge']]
produces 4 Axes:
- 'A panel' which is 1 row high and spans the first two columns
- 'edge' which is 2 rows high and is on the right edge
- 'C panel' which in 1 row and 1 column wide in the bottom left
- a blank space 1 row and 1 column wide in the bottom center
Any of the entries in the layout can be a list of lists
of the same form to create nested layouts.
If input is a str, then it must be of the form ::
'''
AAE
C.E
'''
where each character is a column and each line is a row.
This only allows only single character Axes labels and does
not allow nesting but is very terse.
sharex, sharey : bool, default: False
If True, the x-axis (*sharex*) or y-axis (*sharey*) will be shared
among all subplots. In that case, tick label visibility and axis units
behave as for `subplots`. If False, each subplot's x- or y-axis will
be independent.
width_ratios : array-like of length *ncols*, optional
Defines the relative widths of the columns. Each column gets a
relative width of ``width_ratios[i] / sum(width_ratios)``.
If not given, all columns will have the same width. Convenience
for ``gridspec_kw={'width_ratios': [...]}``.
height_ratios : array-like of length *nrows*, optional
Defines the relative heights of the rows. Each row gets a
relative height of ``height_ratios[i] / sum(height_ratios)``.
If not given, all rows will have the same height. Convenience
for ``gridspec_kw={'height_ratios': [...]}``.
empty_sentinel : object, optional
Entry in the layout to mean "leave this space empty". Defaults
to ``'.'``. Note, if *layout* is a string, it is processed via
`inspect.cleandoc` to remove leading white space, which may
interfere with using white-space as the empty sentinel.
subplot_kw : dict, optional
Dictionary with keywords passed to the `.Figure.add_subplot` call
used to create each subplot. These values may be overridden by
values in *per_subplot_kw*.
per_subplot_kw : dict, optional
A dictionary mapping the Axes identifiers or tuples of identifiers
to a dictionary of keyword arguments to be passed to the
`.Figure.add_subplot` call used to create each subplot. The values
in these dictionaries have precedence over the values in
*subplot_kw*.
If *mosaic* is a string, and thus all keys are single characters,
it is possible to use a single string instead of a tuple as keys;
i.e. ``"AB"`` is equivalent to ``("A", "B")``.
.. versionadded:: 3.7
gridspec_kw : dict, optional
Dictionary with keywords passed to the `.GridSpec` constructor used
to create the grid the subplots are placed on.
**fig_kw
All additional keyword arguments are passed to the
`.pyplot.figure` call.
Returns
-------
fig : `.Figure`
The new figure
dict[label, Axes]
A dictionary mapping the labels to the Axes objects. The order of
the Axes is left-to-right and top-to-bottom of their position in the
total layout.
"""
fig = figure(**fig_kw)
ax_dict = fig.subplot_mosaic( # type: ignore[misc]
mosaic, # type: ignore[arg-type]
sharex=sharex, sharey=sharey,
height_ratios=height_ratios, width_ratios=width_ratios,
subplot_kw=subplot_kw, gridspec_kw=gridspec_kw,
empty_sentinel=empty_sentinel,
per_subplot_kw=per_subplot_kw, # type: ignore[arg-type]
)
return fig, ax_dict
def subplot2grid(
shape: tuple[int, int], loc: tuple[int, int],
rowspan: int = 1, colspan: int = 1,
fig: Figure | None = None,
**kwargs
) -> matplotlib.axes.Axes:
"""
Create a subplot at a specific location inside a regular grid.
Parameters
----------
shape : (int, int)
Number of rows and of columns of the grid in which to place axis.
loc : (int, int)
Row number and column number of the axis location within the grid.
rowspan : int, default: 1
Number of rows for the axis to span downwards.
colspan : int, default: 1
Number of columns for the axis to span to the right.
fig : `.Figure`, optional
Figure to place the subplot in. Defaults to the current figure.
**kwargs
Additional keyword arguments are handed to `~.Figure.add_subplot`.
Returns
-------
`~.axes.Axes`
The Axes of the subplot. The returned Axes can actually be an instance
of a subclass, such as `.projections.polar.PolarAxes` for polar
projections.
Notes
-----
The following call ::
ax = subplot2grid((nrows, ncols), (row, col), rowspan, colspan)
is identical to ::
fig = gcf()
gs = fig.add_gridspec(nrows, ncols)
ax = fig.add_subplot(gs[row:row+rowspan, col:col+colspan])
"""
if fig is None:
fig = gcf()
rows, cols = shape
gs = GridSpec._check_gridspec_exists(fig, rows, cols)
subplotspec = gs.new_subplotspec(loc, rowspan=rowspan, colspan=colspan)
return fig.add_subplot(subplotspec, **kwargs)
def twinx(ax: matplotlib.axes.Axes | None = None) -> _AxesBase:
"""
Make and return a second Axes that shares the *x*-axis. The new Axes will
overlay *ax* (or the current Axes if *ax* is *None*), and its ticks will be
on the right.
Examples
--------
:doc:`/gallery/subplots_axes_and_figures/two_scales`
"""
if ax is None:
ax = gca()
ax1 = ax.twinx()
return ax1
def twiny(ax: matplotlib.axes.Axes | None = None) -> _AxesBase:
"""
Make and return a second Axes that shares the *y*-axis. The new Axes will
overlay *ax* (or the current Axes if *ax* is *None*), and its ticks will be
on the top.
Examples
--------
:doc:`/gallery/subplots_axes_and_figures/two_scales`
"""
if ax is None:
ax = gca()
ax1 = ax.twiny()
return ax1
def subplot_tool(targetfig: Figure | None = None) -> SubplotTool | None:
"""
Launch a subplot tool window for a figure.
Returns
-------
`matplotlib.widgets.SubplotTool`
"""
if targetfig is None:
targetfig = gcf()
tb = targetfig.canvas.manager.toolbar # type: ignore[union-attr]
if hasattr(tb, "configure_subplots"): # toolbar2
from matplotlib.backend_bases import NavigationToolbar2
return cast(NavigationToolbar2, tb).configure_subplots()
elif hasattr(tb, "trigger_tool"): # toolmanager
from matplotlib.backend_bases import ToolContainerBase
cast(ToolContainerBase, tb).trigger_tool("subplots")
return None
else:
raise ValueError("subplot_tool can only be launched for figures with "
"an associated toolbar")
def box(on: bool | None = None) -> None:
"""
Turn the Axes box on or off on the current Axes.
Parameters
----------
on : bool or None
The new `~matplotlib.axes.Axes` box state. If ``None``, toggle
the state.
See Also
--------
:meth:`matplotlib.axes.Axes.set_frame_on`
:meth:`matplotlib.axes.Axes.get_frame_on`
"""
ax = gca()
if on is None:
on = not ax.get_frame_on()
ax.set_frame_on(on)
## Axis ##
def xlim(*args, **kwargs) -> tuple[float, float]:
"""
Get or set the x limits of the current Axes.
Call signatures::
left, right = xlim() # return the current xlim
xlim((left, right)) # set the xlim to left, right
xlim(left, right) # set the xlim to left, right
If you do not specify args, you can pass *left* or *right* as kwargs,
i.e.::
xlim(right=3) # adjust the right leaving left unchanged
xlim(left=1) # adjust the left leaving right unchanged
Setting limits turns autoscaling off for the x-axis.
Returns
-------
left, right
A tuple of the new x-axis limits.
Notes
-----
Calling this function with no arguments (e.g. ``xlim()``) is the pyplot
equivalent of calling `~.Axes.get_xlim` on the current Axes.
Calling this function with arguments is the pyplot equivalent of calling
`~.Axes.set_xlim` on the current Axes. All arguments are passed though.
"""
ax = gca()
if not args and not kwargs:
return ax.get_xlim()
ret = ax.set_xlim(*args, **kwargs)
return ret
def ylim(*args, **kwargs) -> tuple[float, float]:
"""
Get or set the y-limits of the current Axes.
Call signatures::
bottom, top = ylim() # return the current ylim
ylim((bottom, top)) # set the ylim to bottom, top
ylim(bottom, top) # set the ylim to bottom, top
If you do not specify args, you can alternatively pass *bottom* or
*top* as kwargs, i.e.::
ylim(top=3) # adjust the top leaving bottom unchanged
ylim(bottom=1) # adjust the bottom leaving top unchanged
Setting limits turns autoscaling off for the y-axis.
Returns
-------
bottom, top
A tuple of the new y-axis limits.
Notes
-----
Calling this function with no arguments (e.g. ``ylim()``) is the pyplot
equivalent of calling `~.Axes.get_ylim` on the current Axes.
Calling this function with arguments is the pyplot equivalent of calling
`~.Axes.set_ylim` on the current Axes. All arguments are passed though.
"""
ax = gca()
if not args and not kwargs:
return ax.get_ylim()
ret = ax.set_ylim(*args, **kwargs)
return ret
def xticks(
ticks: ArrayLike | None = None,
labels: Sequence[str] | None = None,
*,
minor: bool = False,
**kwargs
) -> tuple[list[Tick] | np.ndarray, list[Text]]:
"""
Get or set the current tick locations and labels of the x-axis.
Pass no arguments to return the current values without modifying them.
Parameters
----------
ticks : array-like, optional
The list of xtick locations. Passing an empty list removes all xticks.
labels : array-like, optional
The labels to place at the given *ticks* locations. This argument can
only be passed if *ticks* is passed as well.
minor : bool, default: False
If ``False``, get/set the major ticks/labels; if ``True``, the minor
ticks/labels.
**kwargs
`.Text` properties can be used to control the appearance of the labels.
.. warning::
This only sets the properties of the current ticks, which is
only sufficient if you either pass *ticks*, resulting in a
fixed list of ticks, or if the plot is static.
Ticks are not guaranteed to be persistent. Various operations
can create, delete and modify the Tick instances. There is an
imminent risk that these settings can get lost if you work on
the figure further (including also panning/zooming on a
displayed figure).
Use `~.pyplot.tick_params` instead if possible.
Returns
-------
locs
The list of xtick locations.
labels
The list of xlabel `.Text` objects.
Notes
-----
Calling this function with no arguments (e.g. ``xticks()``) is the pyplot
equivalent of calling `~.Axes.get_xticks` and `~.Axes.get_xticklabels` on
the current Axes.
Calling this function with arguments is the pyplot equivalent of calling
`~.Axes.set_xticks` and `~.Axes.set_xticklabels` on the current Axes.
Examples
--------
>>> locs, labels = xticks() # Get the current locations and labels.
>>> xticks(np.arange(0, 1, step=0.2)) # Set label locations.
>>> xticks(np.arange(3), ['Tom', 'Dick', 'Sue']) # Set text labels.
>>> xticks([0, 1, 2], ['January', 'February', 'March'],
... rotation=20) # Set text labels and properties.
>>> xticks([]) # Disable xticks.
"""
ax = gca()
locs: list[Tick] | np.ndarray
if ticks is None:
locs = ax.get_xticks(minor=minor)
if labels is not None:
raise TypeError("xticks(): Parameter 'labels' can't be set "
"without setting 'ticks'")
else:
locs = ax.set_xticks(ticks, minor=minor)
labels_out: list[Text] = []
if labels is None:
labels_out = ax.get_xticklabels(minor=minor)
for l in labels_out:
l._internal_update(kwargs)
else:
labels_out = ax.set_xticklabels(labels, minor=minor, **kwargs)
return locs, labels_out
def yticks(
ticks: ArrayLike | None = None,
labels: Sequence[str] | None = None,
*,
minor: bool = False,
**kwargs
) -> tuple[list[Tick] | np.ndarray, list[Text]]:
"""
Get or set the current tick locations and labels of the y-axis.
Pass no arguments to return the current values without modifying them.
Parameters
----------
ticks : array-like, optional
The list of ytick locations. Passing an empty list removes all yticks.
labels : array-like, optional
The labels to place at the given *ticks* locations. This argument can
only be passed if *ticks* is passed as well.
minor : bool, default: False
If ``False``, get/set the major ticks/labels; if ``True``, the minor
ticks/labels.
**kwargs
`.Text` properties can be used to control the appearance of the labels.
.. warning::
This only sets the properties of the current ticks, which is
only sufficient if you either pass *ticks*, resulting in a
fixed list of ticks, or if the plot is static.
Ticks are not guaranteed to be persistent. Various operations
can create, delete and modify the Tick instances. There is an
imminent risk that these settings can get lost if you work on
the figure further (including also panning/zooming on a
displayed figure).
Use `~.pyplot.tick_params` instead if possible.
Returns
-------
locs
The list of ytick locations.
labels
The list of ylabel `.Text` objects.
Notes
-----
Calling this function with no arguments (e.g. ``yticks()``) is the pyplot
equivalent of calling `~.Axes.get_yticks` and `~.Axes.get_yticklabels` on
the current Axes.
Calling this function with arguments is the pyplot equivalent of calling
`~.Axes.set_yticks` and `~.Axes.set_yticklabels` on the current Axes.
Examples
--------
>>> locs, labels = yticks() # Get the current locations and labels.
>>> yticks(np.arange(0, 1, step=0.2)) # Set label locations.
>>> yticks(np.arange(3), ['Tom', 'Dick', 'Sue']) # Set text labels.
>>> yticks([0, 1, 2], ['January', 'February', 'March'],
... rotation=45) # Set text labels and properties.
>>> yticks([]) # Disable yticks.
"""
ax = gca()
locs: list[Tick] | np.ndarray
if ticks is None:
locs = ax.get_yticks(minor=minor)
if labels is not None:
raise TypeError("yticks(): Parameter 'labels' can't be set "
"without setting 'ticks'")
else:
locs = ax.set_yticks(ticks, minor=minor)
labels_out: list[Text] = []
if labels is None:
labels_out = ax.get_yticklabels(minor=minor)
for l in labels_out:
l._internal_update(kwargs)
else:
labels_out = ax.set_yticklabels(labels, minor=minor, **kwargs)
return locs, labels_out
def rgrids(
radii: ArrayLike | None = None,
labels: Sequence[str | Text] | None = None,
angle: float | None = None,
fmt: str | None = None,
**kwargs
) -> tuple[list[Line2D], list[Text]]:
"""
Get or set the radial gridlines on the current polar plot.
Call signatures::
lines, labels = rgrids()
lines, labels = rgrids(radii, labels=None, angle=22.5, fmt=None, **kwargs)
When called with no arguments, `.rgrids` simply returns the tuple
(*lines*, *labels*). When called with arguments, the labels will
appear at the specified radial distances and angle.
Parameters
----------
radii : tuple with floats
The radii for the radial gridlines
labels : tuple with strings or None
The labels to use at each radial gridline. The
`matplotlib.ticker.ScalarFormatter` will be used if None.
angle : float
The angular position of the radius labels in degrees.
fmt : str or None
Format string used in `matplotlib.ticker.FormatStrFormatter`.
For example '%f'.
Returns
-------
lines : list of `.lines.Line2D`
The radial gridlines.
labels : list of `.text.Text`
The tick labels.
Other Parameters
----------------
**kwargs
*kwargs* are optional `.Text` properties for the labels.
See Also
--------
.pyplot.thetagrids
.projections.polar.PolarAxes.set_rgrids
.Axis.get_gridlines
.Axis.get_ticklabels
Examples
--------
::
# set the locations of the radial gridlines
lines, labels = rgrids( (0.25, 0.5, 1.0) )
# set the locations and labels of the radial gridlines
lines, labels = rgrids( (0.25, 0.5, 1.0), ('Tom', 'Dick', 'Harry' ))
"""
ax = gca()
if not isinstance(ax, PolarAxes):
raise RuntimeError('rgrids only defined for polar Axes')
if all(p is None for p in [radii, labels, angle, fmt]) and not kwargs:
lines_out: list[Line2D] = ax.yaxis.get_gridlines()
labels_out: list[Text] = ax.yaxis.get_ticklabels()
elif radii is None:
raise TypeError("'radii' cannot be None when other parameters are passed")
else:
lines_out, labels_out = ax.set_rgrids(
radii, labels=labels, angle=angle, fmt=fmt, **kwargs)
return lines_out, labels_out
def thetagrids(
angles: ArrayLike | None = None,
labels: Sequence[str | Text] | None = None,
fmt: str | None = None,
**kwargs
) -> tuple[list[Line2D], list[Text]]:
"""
Get or set the theta gridlines on the current polar plot.
Call signatures::
lines, labels = thetagrids()
lines, labels = thetagrids(angles, labels=None, fmt=None, **kwargs)
When called with no arguments, `.thetagrids` simply returns the tuple
(*lines*, *labels*). When called with arguments, the labels will
appear at the specified angles.
Parameters
----------
angles : tuple with floats, degrees
The angles of the theta gridlines.
labels : tuple with strings or None
The labels to use at each radial gridline. The
`.projections.polar.ThetaFormatter` will be used if None.
fmt : str or None
Format string used in `matplotlib.ticker.FormatStrFormatter`.
For example '%f'. Note that the angle in radians will be used.
Returns
-------
lines : list of `.lines.Line2D`
The theta gridlines.
labels : list of `.text.Text`
The tick labels.
Other Parameters
----------------
**kwargs
*kwargs* are optional `.Text` properties for the labels.
See Also
--------
.pyplot.rgrids
.projections.polar.PolarAxes.set_thetagrids
.Axis.get_gridlines
.Axis.get_ticklabels
Examples
--------
::
# set the locations of the angular gridlines
lines, labels = thetagrids(range(45, 360, 90))
# set the locations and labels of the angular gridlines
lines, labels = thetagrids(range(45, 360, 90), ('NE', 'NW', 'SW', 'SE'))
"""
ax = gca()
if not isinstance(ax, PolarAxes):
raise RuntimeError('thetagrids only defined for polar Axes')
if all(param is None for param in [angles, labels, fmt]) and not kwargs:
lines_out: list[Line2D] = ax.xaxis.get_ticklines()
labels_out: list[Text] = ax.xaxis.get_ticklabels()
elif angles is None:
raise TypeError("'angles' cannot be None when other parameters are passed")
else:
lines_out, labels_out = ax.set_thetagrids(angles,
labels=labels, fmt=fmt,
**kwargs)
return lines_out, labels_out
@_api.deprecated("3.7", pending=True)
def get_plot_commands() -> list[str]:
"""
Get a sorted list of all of the plotting commands.
"""
NON_PLOT_COMMANDS = {
'connect', 'disconnect', 'get_current_fig_manager', 'ginput',
'new_figure_manager', 'waitforbuttonpress'}
return [name for name in _get_pyplot_commands()
if name not in NON_PLOT_COMMANDS]
def _get_pyplot_commands() -> list[str]:
# This works by searching for all functions in this module and removing
# a few hard-coded exclusions, as well as all of the colormap-setting
# functions, and anything marked as private with a preceding underscore.
exclude = {'colormaps', 'colors', 'get_plot_commands', *colormaps}
this_module = inspect.getmodule(get_plot_commands)
return sorted(
name for name, obj in globals().items()
if not name.startswith('_') and name not in exclude
and inspect.isfunction(obj)
and inspect.getmodule(obj) is this_module)
## Plotting part 1: manually generated functions and wrappers ##
@_copy_docstring_and_deprecators(Figure.colorbar)
def colorbar(
mappable: ScalarMappable | None = None,
cax: matplotlib.axes.Axes | None = None,
ax: matplotlib.axes.Axes | Iterable[matplotlib.axes.Axes] | None = None,
**kwargs
) -> Colorbar:
if mappable is None:
mappable = gci()
if mappable is None:
raise RuntimeError('No mappable was found to use for colorbar '
'creation. First define a mappable such as '
'an image (with imshow) or a contour set ('
'with contourf).')
ret = gcf().colorbar(mappable, cax=cax, ax=ax, **kwargs)
return ret
def clim(vmin: float | None = None, vmax: float | None = None) -> None:
"""
Set the color limits of the current image.
If either *vmin* or *vmax* is None, the image min/max respectively
will be used for color scaling.
If you want to set the clim of multiple images, use
`~.ScalarMappable.set_clim` on every image, for example::
for im in gca().get_images():
im.set_clim(0, 0.5)
"""
im = gci()
if im is None:
raise RuntimeError('You must first define an image, e.g., with imshow')
im.set_clim(vmin, vmax)
def get_cmap(name: Colormap | str | None = None, lut: int | None = None) -> Colormap:
"""
Get a colormap instance, defaulting to rc values if *name* is None.
Parameters
----------
name : `~matplotlib.colors.Colormap` or str or None, default: None
If a `.Colormap` instance, it will be returned. Otherwise, the name of
a colormap known to Matplotlib, which will be resampled by *lut*. The
default, None, means :rc:`image.cmap`.
lut : int or None, default: None
If *name* is not already a Colormap instance and *lut* is not None, the
colormap will be resampled to have *lut* entries in the lookup table.
Returns
-------
Colormap
"""
if name is None:
name = rcParams['image.cmap']
if isinstance(name, Colormap):
return name
_api.check_in_list(sorted(_colormaps), name=name)
if lut is None:
return _colormaps[name]
else:
return _colormaps[name].resampled(lut)
def set_cmap(cmap: Colormap | str) -> None:
"""
Set the default colormap, and applies it to the current image if any.
Parameters
----------
cmap : `~matplotlib.colors.Colormap` or str
A colormap instance or the name of a registered colormap.
See Also
--------
colormaps
get_cmap
"""
cmap = get_cmap(cmap)
rc('image', cmap=cmap.name)
im = gci()
if im is not None:
im.set_cmap(cmap)
@_copy_docstring_and_deprecators(matplotlib.image.imread)
def imread(
fname: str | pathlib.Path | BinaryIO, format: str | None = None
) -> np.ndarray:
return matplotlib.image.imread(fname, format)
@_copy_docstring_and_deprecators(matplotlib.image.imsave)
def imsave(
fname: str | os.PathLike | BinaryIO, arr: ArrayLike, **kwargs
) -> None:
matplotlib.image.imsave(fname, arr, **kwargs)
def matshow(A: ArrayLike, fignum: None | int = None, **kwargs) -> AxesImage:
"""
Display a 2D array as a matrix in a new figure window.
The origin is set at the upper left hand corner.
The indexing is ``(row, column)`` so that the first index runs vertically
and the second index runs horizontally in the figure:
.. code-block:: none
A[0, 0] ⋯ A[0, M-1]
⋮ ⋮
A[N-1, 0] ⋯ A[N-1, M-1]
The aspect ratio of the figure window is that of the array,
unless this would make an excessively short or narrow figure.
Tick labels for the xaxis are placed on top.
Parameters
----------
A : 2D array-like
The matrix to be displayed.
fignum : None or int
If *None*, create a new, appropriately sized figure window.
If 0, use the current Axes (creating one if there is none, without ever
adjusting the figure size).
Otherwise, create a new Axes on the figure with the given number
(creating it at the appropriate size if it does not exist, but not
adjusting the figure size otherwise). Note that this will be drawn on
top of any preexisting Axes on the figure.
Returns
-------
`~matplotlib.image.AxesImage`
Other Parameters
----------------
**kwargs : `~matplotlib.axes.Axes.imshow` arguments
"""
A = np.asanyarray(A)
if fignum == 0:
ax = gca()
else:
# Extract actual aspect ratio of array and make appropriately sized
# figure.
fig = figure(fignum, figsize=figaspect(A))
ax = fig.add_axes((0.15, 0.09, 0.775, 0.775))
im = ax.matshow(A, **kwargs)
sci(im)
return im
def polar(*args, **kwargs) -> list[Line2D]:
"""
Make a polar plot.
call signature::
polar(theta, r, **kwargs)
Multiple *theta*, *r* arguments are supported, with format strings, as in
`plot`.
"""
# If an axis already exists, check if it has a polar projection
if gcf().get_axes():
ax = gca()
if not isinstance(ax, PolarAxes):
_api.warn_external('Trying to create polar plot on an Axes '
'that does not have a polar projection.')
else:
ax = axes(projection="polar")
return ax.plot(*args, **kwargs)
# If rcParams['backend_fallback'] is true, and an interactive backend is
# requested, ignore rcParams['backend'] and force selection of a backend that
# is compatible with the current running interactive framework.
if (rcParams["backend_fallback"]
and rcParams._get_backend_or_none() in ( # type: ignore[attr-defined]
set(backend_registry.list_builtin(BackendFilter.INTERACTIVE)) -
{'webagg', 'nbagg'})
and cbook._get_running_interactive_framework()):
rcParams._set("backend", rcsetup._auto_backend_sentinel)
# fmt: on
################# REMAINING CONTENT GENERATED BY boilerplate.py ##############
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Figure.figimage)
def figimage(
X: ArrayLike,
xo: int = 0,
yo: int = 0,
alpha: float | None = None,
norm: str | Normalize | None = None,
cmap: str | Colormap | None = None,
vmin: float | None = None,
vmax: float | None = None,
origin: Literal["upper", "lower"] | None = None,
resize: bool = False,
**kwargs,
) -> FigureImage:
return gcf().figimage(
X,
xo=xo,
yo=yo,
alpha=alpha,
norm=norm,
cmap=cmap,
vmin=vmin,
vmax=vmax,
origin=origin,
resize=resize,
**kwargs,
)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Figure.text)
def figtext(
x: float, y: float, s: str, fontdict: dict[str, Any] | None = None, **kwargs
) -> Text:
return gcf().text(x, y, s, fontdict=fontdict, **kwargs)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Figure.gca)
def gca() -> Axes:
return gcf().gca()
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Figure._gci)
def gci() -> ScalarMappable | None:
return gcf()._gci()
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Figure.ginput)
def ginput(
n: int = 1,
timeout: float = 30,
show_clicks: bool = True,
mouse_add: MouseButton = MouseButton.LEFT,
mouse_pop: MouseButton = MouseButton.RIGHT,
mouse_stop: MouseButton = MouseButton.MIDDLE,
) -> list[tuple[int, int]]:
return gcf().ginput(
n=n,
timeout=timeout,
show_clicks=show_clicks,
mouse_add=mouse_add,
mouse_pop=mouse_pop,
mouse_stop=mouse_stop,
)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Figure.subplots_adjust)
def subplots_adjust(
left: float | None = None,
bottom: float | None = None,
right: float | None = None,
top: float | None = None,
wspace: float | None = None,
hspace: float | None = None,
) -> None:
gcf().subplots_adjust(
left=left, bottom=bottom, right=right, top=top, wspace=wspace, hspace=hspace
)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Figure.suptitle)
def suptitle(t: str, **kwargs) -> Text:
return gcf().suptitle(t, **kwargs)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Figure.tight_layout)
def tight_layout(
*,
pad: float = 1.08,
h_pad: float | None = None,
w_pad: float | None = None,
rect: tuple[float, float, float, float] | None = None,
) -> None:
gcf().tight_layout(pad=pad, h_pad=h_pad, w_pad=w_pad, rect=rect)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Figure.waitforbuttonpress)
def waitforbuttonpress(timeout: float = -1) -> None | bool:
return gcf().waitforbuttonpress(timeout=timeout)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.acorr)
def acorr(
x: ArrayLike, *, data=None, **kwargs
) -> tuple[np.ndarray, np.ndarray, LineCollection | Line2D, Line2D | None]:
return gca().acorr(x, **({"data": data} if data is not None else {}), **kwargs)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.angle_spectrum)
def angle_spectrum(
x: ArrayLike,
Fs: float | None = None,
Fc: int | None = None,
window: Callable[[ArrayLike], ArrayLike] | ArrayLike | None = None,
pad_to: int | None = None,
sides: Literal["default", "onesided", "twosided"] | None = None,
*,
data=None,
**kwargs,
) -> tuple[np.ndarray, np.ndarray, Line2D]:
return gca().angle_spectrum(
x,
Fs=Fs,
Fc=Fc,
window=window,
pad_to=pad_to,
sides=sides,
**({"data": data} if data is not None else {}),
**kwargs,
)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.annotate)
def annotate(
text: str,
xy: tuple[float, float],
xytext: tuple[float, float] | None = None,
xycoords: str
| Artist
| Transform
| Callable[[RendererBase], Bbox | Transform]
| tuple[float, float] = "data",
textcoords: str
| Artist
| Transform
| Callable[[RendererBase], Bbox | Transform]
| tuple[float, float]
| None = None,
arrowprops: dict[str, Any] | None = None,
annotation_clip: bool | None = None,
**kwargs,
) -> Annotation:
return gca().annotate(
text,
xy,
xytext=xytext,
xycoords=xycoords,
textcoords=textcoords,
arrowprops=arrowprops,
annotation_clip=annotation_clip,
**kwargs,
)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.arrow)
def arrow(x: float, y: float, dx: float, dy: float, **kwargs) -> FancyArrow:
return gca().arrow(x, y, dx, dy, **kwargs)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.autoscale)
def autoscale(
enable: bool = True,
axis: Literal["both", "x", "y"] = "both",
tight: bool | None = None,
) -> None:
gca().autoscale(enable=enable, axis=axis, tight=tight)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.axhline)
def axhline(y: float = 0, xmin: float = 0, xmax: float = 1, **kwargs) -> Line2D:
return gca().axhline(y=y, xmin=xmin, xmax=xmax, **kwargs)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.axhspan)
def axhspan(
ymin: float, ymax: float, xmin: float = 0, xmax: float = 1, **kwargs
) -> Rectangle:
return gca().axhspan(ymin, ymax, xmin=xmin, xmax=xmax, **kwargs)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.axis)
def axis(
arg: tuple[float, float, float, float] | bool | str | None = None,
/,
*,
emit: bool = True,
**kwargs,
) -> tuple[float, float, float, float]:
return gca().axis(arg, emit=emit, **kwargs)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.axline)
def axline(
xy1: tuple[float, float],
xy2: tuple[float, float] | None = None,
*,
slope: float | None = None,
**kwargs,
) -> AxLine:
return gca().axline(xy1, xy2=xy2, slope=slope, **kwargs)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.axvline)
def axvline(x: float = 0, ymin: float = 0, ymax: float = 1, **kwargs) -> Line2D:
return gca().axvline(x=x, ymin=ymin, ymax=ymax, **kwargs)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.axvspan)
def axvspan(
xmin: float, xmax: float, ymin: float = 0, ymax: float = 1, **kwargs
) -> Rectangle:
return gca().axvspan(xmin, xmax, ymin=ymin, ymax=ymax, **kwargs)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.bar)
def bar(
x: float | ArrayLike,
height: float | ArrayLike,
width: float | ArrayLike = 0.8,
bottom: float | ArrayLike | None = None,
*,
align: Literal["center", "edge"] = "center",
data=None,
**kwargs,
) -> BarContainer:
return gca().bar(
x,
height,
width=width,
bottom=bottom,
align=align,
**({"data": data} if data is not None else {}),
**kwargs,
)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.barbs)
def barbs(*args, data=None, **kwargs) -> Barbs:
return gca().barbs(*args, **({"data": data} if data is not None else {}), **kwargs)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.barh)
def barh(
y: float | ArrayLike,
width: float | ArrayLike,
height: float | ArrayLike = 0.8,
left: float | ArrayLike | None = None,
*,
align: Literal["center", "edge"] = "center",
data=None,
**kwargs,
) -> BarContainer:
return gca().barh(
y,
width,
height=height,
left=left,
align=align,
**({"data": data} if data is not None else {}),
**kwargs,
)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.bar_label)
def bar_label(
container: BarContainer,
labels: ArrayLike | None = None,
*,
fmt: str | Callable[[float], str] = "%g",
label_type: Literal["center", "edge"] = "edge",
padding: float = 0,
**kwargs,
) -> list[Annotation]:
return gca().bar_label(
container,
labels=labels,
fmt=fmt,
label_type=label_type,
padding=padding,
**kwargs,
)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.boxplot)
def boxplot(
x: ArrayLike | Sequence[ArrayLike],
notch: bool | None = None,
sym: str | None = None,
vert: bool | None = None,
whis: float | tuple[float, float] | None = None,
positions: ArrayLike | None = None,
widths: float | ArrayLike | None = None,
patch_artist: bool | None = None,
bootstrap: int | None = None,
usermedians: ArrayLike | None = None,
conf_intervals: ArrayLike | None = None,
meanline: bool | None = None,
showmeans: bool | None = None,
showcaps: bool | None = None,
showbox: bool | None = None,
showfliers: bool | None = None,
boxprops: dict[str, Any] | None = None,
tick_labels: Sequence[str] | None = None,
flierprops: dict[str, Any] | None = None,
medianprops: dict[str, Any] | None = None,
meanprops: dict[str, Any] | None = None,
capprops: dict[str, Any] | None = None,
whiskerprops: dict[str, Any] | None = None,
manage_ticks: bool = True,
autorange: bool = False,
zorder: float | None = None,
capwidths: float | ArrayLike | None = None,
label: Sequence[str] | None = None,
*,
data=None,
) -> dict[str, Any]:
return gca().boxplot(
x,
notch=notch,
sym=sym,
vert=vert,
whis=whis,
positions=positions,
widths=widths,
patch_artist=patch_artist,
bootstrap=bootstrap,
usermedians=usermedians,
conf_intervals=conf_intervals,
meanline=meanline,
showmeans=showmeans,
showcaps=showcaps,
showbox=showbox,
showfliers=showfliers,
boxprops=boxprops,
tick_labels=tick_labels,
flierprops=flierprops,
medianprops=medianprops,
meanprops=meanprops,
capprops=capprops,
whiskerprops=whiskerprops,
manage_ticks=manage_ticks,
autorange=autorange,
zorder=zorder,
capwidths=capwidths,
label=label,
**({"data": data} if data is not None else {}),
)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.broken_barh)
def broken_barh(
xranges: Sequence[tuple[float, float]],
yrange: tuple[float, float],
*,
data=None,
**kwargs,
) -> PolyCollection:
return gca().broken_barh(
xranges, yrange, **({"data": data} if data is not None else {}), **kwargs
)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.clabel)
def clabel(CS: ContourSet, levels: ArrayLike | None = None, **kwargs) -> list[Text]:
return gca().clabel(CS, levels=levels, **kwargs)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.cohere)
def cohere(
x: ArrayLike,
y: ArrayLike,
NFFT: int = 256,
Fs: float = 2,
Fc: int = 0,
detrend: Literal["none", "mean", "linear"]
| Callable[[ArrayLike], ArrayLike] = mlab.detrend_none,
window: Callable[[ArrayLike], ArrayLike] | ArrayLike = mlab.window_hanning,
noverlap: int = 0,
pad_to: int | None = None,
sides: Literal["default", "onesided", "twosided"] = "default",
scale_by_freq: bool | None = None,
*,
data=None,
**kwargs,
) -> tuple[np.ndarray, np.ndarray]:
return gca().cohere(
x,
y,
NFFT=NFFT,
Fs=Fs,
Fc=Fc,
detrend=detrend,
window=window,
noverlap=noverlap,
pad_to=pad_to,
sides=sides,
scale_by_freq=scale_by_freq,
**({"data": data} if data is not None else {}),
**kwargs,
)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.contour)
def contour(*args, data=None, **kwargs) -> QuadContourSet:
__ret = gca().contour(
*args, **({"data": data} if data is not None else {}), **kwargs
)
if __ret._A is not None: # type: ignore[attr-defined]
sci(__ret)
return __ret
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.contourf)
def contourf(*args, data=None, **kwargs) -> QuadContourSet:
__ret = gca().contourf(
*args, **({"data": data} if data is not None else {}), **kwargs
)
if __ret._A is not None: # type: ignore[attr-defined]
sci(__ret)
return __ret
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.csd)
def csd(
x: ArrayLike,
y: ArrayLike,
NFFT: int | None = None,
Fs: float | None = None,
Fc: int | None = None,
detrend: Literal["none", "mean", "linear"]
| Callable[[ArrayLike], ArrayLike]
| None = None,
window: Callable[[ArrayLike], ArrayLike] | ArrayLike | None = None,
noverlap: int | None = None,
pad_to: int | None = None,
sides: Literal["default", "onesided", "twosided"] | None = None,
scale_by_freq: bool | None = None,
return_line: bool | None = None,
*,
data=None,
**kwargs,
) -> tuple[np.ndarray, np.ndarray] | tuple[np.ndarray, np.ndarray, Line2D]:
return gca().csd(
x,
y,
NFFT=NFFT,
Fs=Fs,
Fc=Fc,
detrend=detrend,
window=window,
noverlap=noverlap,
pad_to=pad_to,
sides=sides,
scale_by_freq=scale_by_freq,
return_line=return_line,
**({"data": data} if data is not None else {}),
**kwargs,
)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.ecdf)
def ecdf(
x: ArrayLike,
weights: ArrayLike | None = None,
*,
complementary: bool = False,
orientation: Literal["vertical", "horizonatal"] = "vertical",
compress: bool = False,
data=None,
**kwargs,
) -> Line2D:
return gca().ecdf(
x,
weights=weights,
complementary=complementary,
orientation=orientation,
compress=compress,
**({"data": data} if data is not None else {}),
**kwargs,
)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.errorbar)
def errorbar(
x: float | ArrayLike,
y: float | ArrayLike,
yerr: float | ArrayLike | None = None,
xerr: float | ArrayLike | None = None,
fmt: str = "",
ecolor: ColorType | None = None,
elinewidth: float | None = None,
capsize: float | None = None,
barsabove: bool = False,
lolims: bool | ArrayLike = False,
uplims: bool | ArrayLike = False,
xlolims: bool | ArrayLike = False,
xuplims: bool | ArrayLike = False,
errorevery: int | tuple[int, int] = 1,
capthick: float | None = None,
*,
data=None,
**kwargs,
) -> ErrorbarContainer:
return gca().errorbar(
x,
y,
yerr=yerr,
xerr=xerr,
fmt=fmt,
ecolor=ecolor,
elinewidth=elinewidth,
capsize=capsize,
barsabove=barsabove,
lolims=lolims,
uplims=uplims,
xlolims=xlolims,
xuplims=xuplims,
errorevery=errorevery,
capthick=capthick,
**({"data": data} if data is not None else {}),
**kwargs,
)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.eventplot)
def eventplot(
positions: ArrayLike | Sequence[ArrayLike],
orientation: Literal["horizontal", "vertical"] = "horizontal",
lineoffsets: float | Sequence[float] = 1,
linelengths: float | Sequence[float] = 1,
linewidths: float | Sequence[float] | None = None,
colors: ColorType | Sequence[ColorType] | None = None,
alpha: float | Sequence[float] | None = None,
linestyles: LineStyleType | Sequence[LineStyleType] = "solid",
*,
data=None,
**kwargs,
) -> EventCollection:
return gca().eventplot(
positions,
orientation=orientation,
lineoffsets=lineoffsets,
linelengths=linelengths,
linewidths=linewidths,
colors=colors,
alpha=alpha,
linestyles=linestyles,
**({"data": data} if data is not None else {}),
**kwargs,
)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.fill)
def fill(*args, data=None, **kwargs) -> list[Polygon]:
return gca().fill(*args, **({"data": data} if data is not None else {}), **kwargs)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.fill_between)
def fill_between(
x: ArrayLike,
y1: ArrayLike | float,
y2: ArrayLike | float = 0,
where: Sequence[bool] | None = None,
interpolate: bool = False,
step: Literal["pre", "post", "mid"] | None = None,
*,
data=None,
**kwargs,
) -> PolyCollection:
return gca().fill_between(
x,
y1,
y2=y2,
where=where,
interpolate=interpolate,
step=step,
**({"data": data} if data is not None else {}),
**kwargs,
)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.fill_betweenx)
def fill_betweenx(
y: ArrayLike,
x1: ArrayLike | float,
x2: ArrayLike | float = 0,
where: Sequence[bool] | None = None,
step: Literal["pre", "post", "mid"] | None = None,
interpolate: bool = False,
*,
data=None,
**kwargs,
) -> PolyCollection:
return gca().fill_betweenx(
y,
x1,
x2=x2,
where=where,
step=step,
interpolate=interpolate,
**({"data": data} if data is not None else {}),
**kwargs,
)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.grid)
def grid(
visible: bool | None = None,
which: Literal["major", "minor", "both"] = "major",
axis: Literal["both", "x", "y"] = "both",
**kwargs,
) -> None:
gca().grid(visible=visible, which=which, axis=axis, **kwargs)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.hexbin)
def hexbin(
x: ArrayLike,
y: ArrayLike,
C: ArrayLike | None = None,
gridsize: int | tuple[int, int] = 100,
bins: Literal["log"] | int | Sequence[float] | None = None,
xscale: Literal["linear", "log"] = "linear",
yscale: Literal["linear", "log"] = "linear",
extent: tuple[float, float, float, float] | None = None,
cmap: str | Colormap | None = None,
norm: str | Normalize | None = None,
vmin: float | None = None,
vmax: float | None = None,
alpha: float | None = None,
linewidths: float | None = None,
edgecolors: Literal["face", "none"] | ColorType = "face",
reduce_C_function: Callable[[np.ndarray | list[float]], float] = np.mean,
mincnt: int | None = None,
marginals: bool = False,
*,
data=None,
**kwargs,
) -> PolyCollection:
__ret = gca().hexbin(
x,
y,
C=C,
gridsize=gridsize,
bins=bins,
xscale=xscale,
yscale=yscale,
extent=extent,
cmap=cmap,
norm=norm,
vmin=vmin,
vmax=vmax,
alpha=alpha,
linewidths=linewidths,
edgecolors=edgecolors,
reduce_C_function=reduce_C_function,
mincnt=mincnt,
marginals=marginals,
**({"data": data} if data is not None else {}),
**kwargs,
)
sci(__ret)
return __ret
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.hist)
def hist(
x: ArrayLike | Sequence[ArrayLike],
bins: int | Sequence[float] | str | None = None,
range: tuple[float, float] | None = None,
density: bool = False,
weights: ArrayLike | None = None,
cumulative: bool | float = False,
bottom: ArrayLike | float | None = None,
histtype: Literal["bar", "barstacked", "step", "stepfilled"] = "bar",
align: Literal["left", "mid", "right"] = "mid",
orientation: Literal["vertical", "horizontal"] = "vertical",
rwidth: float | None = None,
log: bool = False,
color: ColorType | Sequence[ColorType] | None = None,
label: str | Sequence[str] | None = None,
stacked: bool = False,
*,
data=None,
**kwargs,
) -> tuple[
np.ndarray | list[np.ndarray],
np.ndarray,
BarContainer | Polygon | list[BarContainer | Polygon],
]:
return gca().hist(
x,
bins=bins,
range=range,
density=density,
weights=weights,
cumulative=cumulative,
bottom=bottom,
histtype=histtype,
align=align,
orientation=orientation,
rwidth=rwidth,
log=log,
color=color,
label=label,
stacked=stacked,
**({"data": data} if data is not None else {}),
**kwargs,
)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.stairs)
def stairs(
values: ArrayLike,
edges: ArrayLike | None = None,
*,
orientation: Literal["vertical", "horizontal"] = "vertical",
baseline: float | ArrayLike | None = 0,
fill: bool = False,
data=None,
**kwargs,
) -> StepPatch:
return gca().stairs(
values,
edges=edges,
orientation=orientation,
baseline=baseline,
fill=fill,
**({"data": data} if data is not None else {}),
**kwargs,
)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.hist2d)
def hist2d(
x: ArrayLike,
y: ArrayLike,
bins: None | int | tuple[int, int] | ArrayLike | tuple[ArrayLike, ArrayLike] = 10,
range: ArrayLike | None = None,
density: bool = False,
weights: ArrayLike | None = None,
cmin: float | None = None,
cmax: float | None = None,
*,
data=None,
**kwargs,
) -> tuple[np.ndarray, np.ndarray, np.ndarray, QuadMesh]:
__ret = gca().hist2d(
x,
y,
bins=bins,
range=range,
density=density,
weights=weights,
cmin=cmin,
cmax=cmax,
**({"data": data} if data is not None else {}),
**kwargs,
)
sci(__ret[-1])
return __ret
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.hlines)
def hlines(
y: float | ArrayLike,
xmin: float | ArrayLike,
xmax: float | ArrayLike,
colors: ColorType | Sequence[ColorType] | None = None,
linestyles: LineStyleType = "solid",
label: str = "",
*,
data=None,
**kwargs,
) -> LineCollection:
return gca().hlines(
y,
xmin,
xmax,
colors=colors,
linestyles=linestyles,
label=label,
**({"data": data} if data is not None else {}),
**kwargs,
)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.imshow)
def imshow(
X: ArrayLike | PIL.Image.Image,
cmap: str | Colormap | None = None,
norm: str | Normalize | None = None,
*,
aspect: Literal["equal", "auto"] | float | None = None,
interpolation: str | None = None,
alpha: float | ArrayLike | None = None,
vmin: float | None = None,
vmax: float | None = None,
origin: Literal["upper", "lower"] | None = None,
extent: tuple[float, float, float, float] | None = None,
interpolation_stage: Literal["data", "rgba"] | None = None,
filternorm: bool = True,
filterrad: float = 4.0,
resample: bool | None = None,
url: str | None = None,
data=None,
**kwargs,
) -> AxesImage:
__ret = gca().imshow(
X,
cmap=cmap,
norm=norm,
aspect=aspect,
interpolation=interpolation,
alpha=alpha,
vmin=vmin,
vmax=vmax,
origin=origin,
extent=extent,
interpolation_stage=interpolation_stage,
filternorm=filternorm,
filterrad=filterrad,
resample=resample,
url=url,
**({"data": data} if data is not None else {}),
**kwargs,
)
sci(__ret)
return __ret
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.legend)
def legend(*args, **kwargs) -> Legend:
return gca().legend(*args, **kwargs)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.locator_params)
def locator_params(
axis: Literal["both", "x", "y"] = "both", tight: bool | None = None, **kwargs
) -> None:
gca().locator_params(axis=axis, tight=tight, **kwargs)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.loglog)
def loglog(*args, **kwargs) -> list[Line2D]:
return gca().loglog(*args, **kwargs)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.magnitude_spectrum)
def magnitude_spectrum(
x: ArrayLike,
Fs: float | None = None,
Fc: int | None = None,
window: Callable[[ArrayLike], ArrayLike] | ArrayLike | None = None,
pad_to: int | None = None,
sides: Literal["default", "onesided", "twosided"] | None = None,
scale: Literal["default", "linear", "dB"] | None = None,
*,
data=None,
**kwargs,
) -> tuple[np.ndarray, np.ndarray, Line2D]:
return gca().magnitude_spectrum(
x,
Fs=Fs,
Fc=Fc,
window=window,
pad_to=pad_to,
sides=sides,
scale=scale,
**({"data": data} if data is not None else {}),
**kwargs,
)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.margins)
def margins(
*margins: float,
x: float | None = None,
y: float | None = None,
tight: bool | None = True,
) -> tuple[float, float] | None:
return gca().margins(*margins, x=x, y=y, tight=tight)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.minorticks_off)
def minorticks_off() -> None:
gca().minorticks_off()
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.minorticks_on)
def minorticks_on() -> None:
gca().minorticks_on()
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.pcolor)
def pcolor(
*args: ArrayLike,
shading: Literal["flat", "nearest", "auto"] | None = None,
alpha: float | None = None,
norm: str | Normalize | None = None,
cmap: str | Colormap | None = None,
vmin: float | None = None,
vmax: float | None = None,
data=None,
**kwargs,
) -> Collection:
__ret = gca().pcolor(
*args,
shading=shading,
alpha=alpha,
norm=norm,
cmap=cmap,
vmin=vmin,
vmax=vmax,
**({"data": data} if data is not None else {}),
**kwargs,
)
sci(__ret)
return __ret
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.pcolormesh)
def pcolormesh(
*args: ArrayLike,
alpha: float | None = None,
norm: str | Normalize | None = None,
cmap: str | Colormap | None = None,
vmin: float | None = None,
vmax: float | None = None,
shading: Literal["flat", "nearest", "gouraud", "auto"] | None = None,
antialiased: bool = False,
data=None,
**kwargs,
) -> QuadMesh:
__ret = gca().pcolormesh(
*args,
alpha=alpha,
norm=norm,
cmap=cmap,
vmin=vmin,
vmax=vmax,
shading=shading,
antialiased=antialiased,
**({"data": data} if data is not None else {}),
**kwargs,
)
sci(__ret)
return __ret
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.phase_spectrum)
def phase_spectrum(
x: ArrayLike,
Fs: float | None = None,
Fc: int | None = None,
window: Callable[[ArrayLike], ArrayLike] | ArrayLike | None = None,
pad_to: int | None = None,
sides: Literal["default", "onesided", "twosided"] | None = None,
*,
data=None,
**kwargs,
) -> tuple[np.ndarray, np.ndarray, Line2D]:
return gca().phase_spectrum(
x,
Fs=Fs,
Fc=Fc,
window=window,
pad_to=pad_to,
sides=sides,
**({"data": data} if data is not None else {}),
**kwargs,
)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.pie)
def pie(
x: ArrayLike,
explode: ArrayLike | None = None,
labels: Sequence[str] | None = None,
colors: ColorType | Sequence[ColorType] | None = None,
autopct: str | Callable[[float], str] | None = None,
pctdistance: float = 0.6,
shadow: bool = False,
labeldistance: float | None = 1.1,
startangle: float = 0,
radius: float = 1,
counterclock: bool = True,
wedgeprops: dict[str, Any] | None = None,
textprops: dict[str, Any] | None = None,
center: tuple[float, float] = (0, 0),
frame: bool = False,
rotatelabels: bool = False,
*,
normalize: bool = True,
hatch: str | Sequence[str] | None = None,
data=None,
) -> tuple[list[Wedge], list[Text]] | tuple[list[Wedge], list[Text], list[Text]]:
return gca().pie(
x,
explode=explode,
labels=labels,
colors=colors,
autopct=autopct,
pctdistance=pctdistance,
shadow=shadow,
labeldistance=labeldistance,
startangle=startangle,
radius=radius,
counterclock=counterclock,
wedgeprops=wedgeprops,
textprops=textprops,
center=center,
frame=frame,
rotatelabels=rotatelabels,
normalize=normalize,
hatch=hatch,
**({"data": data} if data is not None else {}),
)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.plot)
def plot(
*args: float | ArrayLike | str,
scalex: bool = True,
scaley: bool = True,
data=None,
**kwargs,
) -> list[Line2D]:
return gca().plot(
*args,
scalex=scalex,
scaley=scaley,
**({"data": data} if data is not None else {}),
**kwargs,
)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.plot_date)
def plot_date(
x: ArrayLike,
y: ArrayLike,
fmt: str = "o",
tz: str | datetime.tzinfo | None = None,
xdate: bool = True,
ydate: bool = False,
*,
data=None,
**kwargs,
) -> list[Line2D]:
return gca().plot_date(
x,
y,
fmt=fmt,
tz=tz,
xdate=xdate,
ydate=ydate,
**({"data": data} if data is not None else {}),
**kwargs,
)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.psd)
def psd(
x: ArrayLike,
NFFT: int | None = None,
Fs: float | None = None,
Fc: int | None = None,
detrend: Literal["none", "mean", "linear"]
| Callable[[ArrayLike], ArrayLike]
| None = None,
window: Callable[[ArrayLike], ArrayLike] | ArrayLike | None = None,
noverlap: int | None = None,
pad_to: int | None = None,
sides: Literal["default", "onesided", "twosided"] | None = None,
scale_by_freq: bool | None = None,
return_line: bool | None = None,
*,
data=None,
**kwargs,
) -> tuple[np.ndarray, np.ndarray] | tuple[np.ndarray, np.ndarray, Line2D]:
return gca().psd(
x,
NFFT=NFFT,
Fs=Fs,
Fc=Fc,
detrend=detrend,
window=window,
noverlap=noverlap,
pad_to=pad_to,
sides=sides,
scale_by_freq=scale_by_freq,
return_line=return_line,
**({"data": data} if data is not None else {}),
**kwargs,
)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.quiver)
def quiver(*args, data=None, **kwargs) -> Quiver:
__ret = gca().quiver(
*args, **({"data": data} if data is not None else {}), **kwargs
)
sci(__ret)
return __ret
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.quiverkey)
def quiverkey(
Q: Quiver, X: float, Y: float, U: float, label: str, **kwargs
) -> QuiverKey:
return gca().quiverkey(Q, X, Y, U, label, **kwargs)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.scatter)
def scatter(
x: float | ArrayLike,
y: float | ArrayLike,
s: float | ArrayLike | None = None,
c: ArrayLike | Sequence[ColorType] | ColorType | None = None,
marker: MarkerType | None = None,
cmap: str | Colormap | None = None,
norm: str | Normalize | None = None,
vmin: float | None = None,
vmax: float | None = None,
alpha: float | None = None,
linewidths: float | Sequence[float] | None = None,
*,
edgecolors: Literal["face", "none"] | ColorType | Sequence[ColorType] | None = None,
plotnonfinite: bool = False,
data=None,
**kwargs,
) -> PathCollection:
__ret = gca().scatter(
x,
y,
s=s,
c=c,
marker=marker,
cmap=cmap,
norm=norm,
vmin=vmin,
vmax=vmax,
alpha=alpha,
linewidths=linewidths,
edgecolors=edgecolors,
plotnonfinite=plotnonfinite,
**({"data": data} if data is not None else {}),
**kwargs,
)
sci(__ret)
return __ret
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.semilogx)
def semilogx(*args, **kwargs) -> list[Line2D]:
return gca().semilogx(*args, **kwargs)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.semilogy)
def semilogy(*args, **kwargs) -> list[Line2D]:
return gca().semilogy(*args, **kwargs)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.specgram)
def specgram(
x: ArrayLike,
NFFT: int | None = None,
Fs: float | None = None,
Fc: int | None = None,
detrend: Literal["none", "mean", "linear"]
| Callable[[ArrayLike], ArrayLike]
| None = None,
window: Callable[[ArrayLike], ArrayLike] | ArrayLike | None = None,
noverlap: int | None = None,
cmap: str | Colormap | None = None,
xextent: tuple[float, float] | None = None,
pad_to: int | None = None,
sides: Literal["default", "onesided", "twosided"] | None = None,
scale_by_freq: bool | None = None,
mode: Literal["default", "psd", "magnitude", "angle", "phase"] | None = None,
scale: Literal["default", "linear", "dB"] | None = None,
vmin: float | None = None,
vmax: float | None = None,
*,
data=None,
**kwargs,
) -> tuple[np.ndarray, np.ndarray, np.ndarray, AxesImage]:
__ret = gca().specgram(
x,
NFFT=NFFT,
Fs=Fs,
Fc=Fc,
detrend=detrend,
window=window,
noverlap=noverlap,
cmap=cmap,
xextent=xextent,
pad_to=pad_to,
sides=sides,
scale_by_freq=scale_by_freq,
mode=mode,
scale=scale,
vmin=vmin,
vmax=vmax,
**({"data": data} if data is not None else {}),
**kwargs,
)
sci(__ret[-1])
return __ret
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.spy)
def spy(
Z: ArrayLike,
precision: float | Literal["present"] = 0,
marker: str | None = None,
markersize: float | None = None,
aspect: Literal["equal", "auto"] | float | None = "equal",
origin: Literal["upper", "lower"] = "upper",
**kwargs,
) -> AxesImage:
__ret = gca().spy(
Z,
precision=precision,
marker=marker,
markersize=markersize,
aspect=aspect,
origin=origin,
**kwargs,
)
if isinstance(__ret, cm.ScalarMappable):
sci(__ret) # noqa
return __ret
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.stackplot)
def stackplot(
x, *args, labels=(), colors=None, hatch=None, baseline="zero", data=None, **kwargs
):
return gca().stackplot(
x,
*args,
labels=labels,
colors=colors,
hatch=hatch,
baseline=baseline,
**({"data": data} if data is not None else {}),
**kwargs,
)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.stem)
def stem(
*args: ArrayLike | str,
linefmt: str | None = None,
markerfmt: str | None = None,
basefmt: str | None = None,
bottom: float = 0,
label: str | None = None,
orientation: Literal["vertical", "horizontal"] = "vertical",
data=None,
) -> StemContainer:
return gca().stem(
*args,
linefmt=linefmt,
markerfmt=markerfmt,
basefmt=basefmt,
bottom=bottom,
label=label,
orientation=orientation,
**({"data": data} if data is not None else {}),
)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.step)
def step(
x: ArrayLike,
y: ArrayLike,
*args,
where: Literal["pre", "post", "mid"] = "pre",
data=None,
**kwargs,
) -> list[Line2D]:
return gca().step(
x,
y,
*args,
where=where,
**({"data": data} if data is not None else {}),
**kwargs,
)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.streamplot)
def streamplot(
x,
y,
u,
v,
density=1,
linewidth=None,
color=None,
cmap=None,
norm=None,
arrowsize=1,
arrowstyle="-|>",
minlength=0.1,
transform=None,
zorder=None,
start_points=None,
maxlength=4.0,
integration_direction="both",
broken_streamlines=True,
*,
data=None,
):
__ret = gca().streamplot(
x,
y,
u,
v,
density=density,
linewidth=linewidth,
color=color,
cmap=cmap,
norm=norm,
arrowsize=arrowsize,
arrowstyle=arrowstyle,
minlength=minlength,
transform=transform,
zorder=zorder,
start_points=start_points,
maxlength=maxlength,
integration_direction=integration_direction,
broken_streamlines=broken_streamlines,
**({"data": data} if data is not None else {}),
)
sci(__ret.lines)
return __ret
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.table)
def table(
cellText=None,
cellColours=None,
cellLoc="right",
colWidths=None,
rowLabels=None,
rowColours=None,
rowLoc="left",
colLabels=None,
colColours=None,
colLoc="center",
loc="bottom",
bbox=None,
edges="closed",
**kwargs,
):
return gca().table(
cellText=cellText,
cellColours=cellColours,
cellLoc=cellLoc,
colWidths=colWidths,
rowLabels=rowLabels,
rowColours=rowColours,
rowLoc=rowLoc,
colLabels=colLabels,
colColours=colColours,
colLoc=colLoc,
loc=loc,
bbox=bbox,
edges=edges,
**kwargs,
)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.text)
def text(
x: float, y: float, s: str, fontdict: dict[str, Any] | None = None, **kwargs
) -> Text:
return gca().text(x, y, s, fontdict=fontdict, **kwargs)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.tick_params)
def tick_params(axis: Literal["both", "x", "y"] = "both", **kwargs) -> None:
gca().tick_params(axis=axis, **kwargs)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.ticklabel_format)
def ticklabel_format(
*,
axis: Literal["both", "x", "y"] = "both",
style: Literal["", "sci", "scientific", "plain"] | None = None,
scilimits: tuple[int, int] | None = None,
useOffset: bool | float | None = None,
useLocale: bool | None = None,
useMathText: bool | None = None,
) -> None:
gca().ticklabel_format(
axis=axis,
style=style,
scilimits=scilimits,
useOffset=useOffset,
useLocale=useLocale,
useMathText=useMathText,
)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.tricontour)
def tricontour(*args, **kwargs):
__ret = gca().tricontour(*args, **kwargs)
if __ret._A is not None: # type: ignore[attr-defined]
sci(__ret)
return __ret
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.tricontourf)
def tricontourf(*args, **kwargs):
__ret = gca().tricontourf(*args, **kwargs)
if __ret._A is not None: # type: ignore[attr-defined]
sci(__ret)
return __ret
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.tripcolor)
def tripcolor(
*args,
alpha=1.0,
norm=None,
cmap=None,
vmin=None,
vmax=None,
shading="flat",
facecolors=None,
**kwargs,
):
__ret = gca().tripcolor(
*args,
alpha=alpha,
norm=norm,
cmap=cmap,
vmin=vmin,
vmax=vmax,
shading=shading,
facecolors=facecolors,
**kwargs,
)
sci(__ret)
return __ret
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.triplot)
def triplot(*args, **kwargs):
return gca().triplot(*args, **kwargs)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.violinplot)
def violinplot(
dataset: ArrayLike | Sequence[ArrayLike],
positions: ArrayLike | None = None,
vert: bool = True,
widths: float | ArrayLike = 0.5,
showmeans: bool = False,
showextrema: bool = True,
showmedians: bool = False,
quantiles: Sequence[float | Sequence[float]] | None = None,
points: int = 100,
bw_method: Literal["scott", "silverman"]
| float
| Callable[[GaussianKDE], float]
| None = None,
side: Literal["both", "low", "high"] = "both",
*,
data=None,
) -> dict[str, Collection]:
return gca().violinplot(
dataset,
positions=positions,
vert=vert,
widths=widths,
showmeans=showmeans,
showextrema=showextrema,
showmedians=showmedians,
quantiles=quantiles,
points=points,
bw_method=bw_method,
side=side,
**({"data": data} if data is not None else {}),
)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.vlines)
def vlines(
x: float | ArrayLike,
ymin: float | ArrayLike,
ymax: float | ArrayLike,
colors: ColorType | Sequence[ColorType] | None = None,
linestyles: LineStyleType = "solid",
label: str = "",
*,
data=None,
**kwargs,
) -> LineCollection:
return gca().vlines(
x,
ymin,
ymax,
colors=colors,
linestyles=linestyles,
label=label,
**({"data": data} if data is not None else {}),
**kwargs,
)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.xcorr)
def xcorr(
x: ArrayLike,
y: ArrayLike,
normed: bool = True,
detrend: Callable[[ArrayLike], ArrayLike] = mlab.detrend_none,
usevlines: bool = True,
maxlags: int = 10,
*,
data=None,
**kwargs,
) -> tuple[np.ndarray, np.ndarray, LineCollection | Line2D, Line2D | None]:
return gca().xcorr(
x,
y,
normed=normed,
detrend=detrend,
usevlines=usevlines,
maxlags=maxlags,
**({"data": data} if data is not None else {}),
**kwargs,
)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes._sci)
def sci(im: ScalarMappable) -> None:
gca()._sci(im)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.set_title)
def title(
label: str,
fontdict: dict[str, Any] | None = None,
loc: Literal["left", "center", "right"] | None = None,
pad: float | None = None,
*,
y: float | None = None,
**kwargs,
) -> Text:
return gca().set_title(label, fontdict=fontdict, loc=loc, pad=pad, y=y, **kwargs)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.set_xlabel)
def xlabel(
xlabel: str,
fontdict: dict[str, Any] | None = None,
labelpad: float | None = None,
*,
loc: Literal["left", "center", "right"] | None = None,
**kwargs,
) -> Text:
return gca().set_xlabel(
xlabel, fontdict=fontdict, labelpad=labelpad, loc=loc, **kwargs
)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.set_ylabel)
def ylabel(
ylabel: str,
fontdict: dict[str, Any] | None = None,
labelpad: float | None = None,
*,
loc: Literal["bottom", "center", "top"] | None = None,
**kwargs,
) -> Text:
return gca().set_ylabel(
ylabel, fontdict=fontdict, labelpad=labelpad, loc=loc, **kwargs
)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.set_xscale)
def xscale(value: str | ScaleBase, **kwargs) -> None:
gca().set_xscale(value, **kwargs)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
@_copy_docstring_and_deprecators(Axes.set_yscale)
def yscale(value: str | ScaleBase, **kwargs) -> None:
gca().set_yscale(value, **kwargs)
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
def autumn() -> None:
"""
Set the colormap to 'autumn'.
This changes the default colormap as well as the colormap of the current
image if there is one. See ``help(colormaps)`` for more information.
"""
set_cmap("autumn")
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
def bone() -> None:
"""
Set the colormap to 'bone'.
This changes the default colormap as well as the colormap of the current
image if there is one. See ``help(colormaps)`` for more information.
"""
set_cmap("bone")
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
def cool() -> None:
"""
Set the colormap to 'cool'.
This changes the default colormap as well as the colormap of the current
image if there is one. See ``help(colormaps)`` for more information.
"""
set_cmap("cool")
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
def copper() -> None:
"""
Set the colormap to 'copper'.
This changes the default colormap as well as the colormap of the current
image if there is one. See ``help(colormaps)`` for more information.
"""
set_cmap("copper")
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
def flag() -> None:
"""
Set the colormap to 'flag'.
This changes the default colormap as well as the colormap of the current
image if there is one. See ``help(colormaps)`` for more information.
"""
set_cmap("flag")
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
def gray() -> None:
"""
Set the colormap to 'gray'.
This changes the default colormap as well as the colormap of the current
image if there is one. See ``help(colormaps)`` for more information.
"""
set_cmap("gray")
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
def hot() -> None:
"""
Set the colormap to 'hot'.
This changes the default colormap as well as the colormap of the current
image if there is one. See ``help(colormaps)`` for more information.
"""
set_cmap("hot")
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
def hsv() -> None:
"""
Set the colormap to 'hsv'.
This changes the default colormap as well as the colormap of the current
image if there is one. See ``help(colormaps)`` for more information.
"""
set_cmap("hsv")
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
def jet() -> None:
"""
Set the colormap to 'jet'.
This changes the default colormap as well as the colormap of the current
image if there is one. See ``help(colormaps)`` for more information.
"""
set_cmap("jet")
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
def pink() -> None:
"""
Set the colormap to 'pink'.
This changes the default colormap as well as the colormap of the current
image if there is one. See ``help(colormaps)`` for more information.
"""
set_cmap("pink")
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
def prism() -> None:
"""
Set the colormap to 'prism'.
This changes the default colormap as well as the colormap of the current
image if there is one. See ``help(colormaps)`` for more information.
"""
set_cmap("prism")
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
def spring() -> None:
"""
Set the colormap to 'spring'.
This changes the default colormap as well as the colormap of the current
image if there is one. See ``help(colormaps)`` for more information.
"""
set_cmap("spring")
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
def summer() -> None:
"""
Set the colormap to 'summer'.
This changes the default colormap as well as the colormap of the current
image if there is one. See ``help(colormaps)`` for more information.
"""
set_cmap("summer")
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
def winter() -> None:
"""
Set the colormap to 'winter'.
This changes the default colormap as well as the colormap of the current
image if there is one. See ``help(colormaps)`` for more information.
"""
set_cmap("winter")
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
def magma() -> None:
"""
Set the colormap to 'magma'.
This changes the default colormap as well as the colormap of the current
image if there is one. See ``help(colormaps)`` for more information.
"""
set_cmap("magma")
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
def inferno() -> None:
"""
Set the colormap to 'inferno'.
This changes the default colormap as well as the colormap of the current
image if there is one. See ``help(colormaps)`` for more information.
"""
set_cmap("inferno")
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
def plasma() -> None:
"""
Set the colormap to 'plasma'.
This changes the default colormap as well as the colormap of the current
image if there is one. See ``help(colormaps)`` for more information.
"""
set_cmap("plasma")
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
def viridis() -> None:
"""
Set the colormap to 'viridis'.
This changes the default colormap as well as the colormap of the current
image if there is one. See ``help(colormaps)`` for more information.
"""
set_cmap("viridis")
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
def nipy_spectral() -> None:
"""
Set the colormap to 'nipy_spectral'.
This changes the default colormap as well as the colormap of the current
image if there is one. See ``help(colormaps)`` for more information.
"""
set_cmap("nipy_spectral")
|