I have written the following code:
import matplotlib.pyplot as plt
X1 = [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, 399, 400, 401, 402, 403, 404, 405, 406, 407, 414, 415, 417, 420, 422, 424, 425, 426, 427, 428, 430, 431, 432, 433, 438, 440, 442, 443, 444, 446, 448, 452, 456, 458, 463, 464, 469, 472, 474, 479, 486]
Y1 = [906, 2917, 4432, 5846, 6954, 8893, 10860, 11668, 14235, 15658, 17435, 19122, 20165, 21858, 23802, 24376, 25822, 26569, 27482, 28213, 28874, 28932, 29496, 29155, 28914, 28611, 28830, 28379, 27907, 28279, 27529, 27697, 26917, 26433, 26768, 26350, 25381, 24484, 23784, 23300, 22537, 21868, 21401, 20509, 19808, 19377, 18769, 17672, 16923, 16129, 15727, 15312, 14566, 14013, 13636, 13198, 12624, 12190, 11805, 11569, 10966, 10652, 10188, 9736, 9488, 9331, 8929, 8697, 8593, 7981, 7760, 7322, 7102, 6857, 6611, 6539, 6365, 5875, 5828, 5455, 5415, 5276, 5120, 5046, 4707, 4609, 4485, 4307, 4384, 4234, 4125, 3821, 3741, 3555, 3628, 3577, 3367, 3194, 3081, 3087, 3070, 2901, 2750, 2776, 2648, 2629, 2406, 2564, 2384, 2298, 2131, 2171, 2076, 2003, 2005, 1922, 1881, 1776, 1701, 1731, 1647, 1520, 1559, 1477, 1385, 1358, 1297, 1346, 1243, 1264, 1264, 1124, 1182, 1159, 998, 980, 1003, 1025, 971, 908, 893, 895, 812, 842, 787, 726, 705, 767, 698, 753, 737, 641, 659, 602, 623, 611, 598, 567, 557, 522, 492, 488, 485, 499, 488, 463, 423, 477, 433, 393, 419, 380, 421, 364, 353, 377, 330, 356, 339, 332, 362, 298, 301, 313, 292, 316, 233, 249, 239, 246, 215, 215, 222, 245, 198, 202, 222, 197, 196, 191, 222, 201, 167, 143, 150, 189, 167, 182, 157, 171, 146, 145, 152, 171, 128, 151, 122, 156, 118, 136, 115, 114, 111, 105, 110, 114, 90, 110, 108, 88, 74, 89, 79, 74, 77, 91, 87, 62, 67, 75, 86, 77, 61, 65, 81, 71, 72, 71, 48, 51, 58, 67, 60, 57, 62, 61, 49, 44, 52, 57, 38, 49, 35, 45, 34, 34, 31, 42, 51, 42, 43, 28, 40, 22, 16, 30, 28, 22, 32, 35, 34, 32, 36, 29, 28, 25, 25, 28, 25, 14, 30, 22, 18, 18, 20, 12, 16, 18, 15, 20, 17, 17, 14, 9, 12, 23, 8, 10, 17, 9, 15, 12, 11, 6, 7, 5, 9, 6, 11, 8, 6, 15, 12, 12, 14, 12, 9, 14, 10, 16, 6, 13, 7, 3, 5, 5, 4, 8, 8, 3, 12, 9, 11, 4, 5, 8, 3, 5, 5, 6, 9, 5, 5, 4, 4, 10, 10, 7, 8, 6, 8, 8, 2, 3, 9, 6, 11, 5, 4, 7, 4, 11, 4, 4, 7, 3, 4, 2, 3, 2, 4, 1, 4, 3, 4, 3, 1, 1, 2, 2, 1, 2, 3, 1, 3, 1, 6, 1, 1, 2, 1, 1, 1, 3, 3, 1, 1, 1, 1, 2, 3, 1, 1, 1, 1, 3, 1, 2, 1, 1, 1, 1, 1, 1]
X2 = [55, 198, 770, 341, 913, 484, 627, 56, 771, 342, 199, 914, 485, 628, 772, 343, 57, 200, 915, 486, 629, 773, 344, 58, 201, 916, 487, 630, 774, 345, 202, 59, 917, 488, 631, 775, 346, 203, 60, 918, 489, 632, 776, 347, 204, 61, 919, 490, 633, 777, 348, 205, 62, 920, 491, 634, 778, 349, 206, 63, 921, 492, 635, 779, 350, 207, 64, 922, 493, 636, 780, 351, 208, 65, 923, 494, 637, 781, 352, 209, 66, 924, 495, 638, 782, 353, 210, 67, 925, 496, 783, 639, 354, 211, 68, 926, 497, 784, 640, 355, 212, 69, 927, 498, 785, 641, 356, 213, 70, 928, 499, 786, 642, 357, 214, 71, 929, 500, 787, 358, 643, 215, 72, 930, 501, 788, 359, 216, 644, 73, 931, 502, 789, 360, 217, 645, 74, 932, 503, 790, 361, 218, 646, 75, 933, 791, 504, 362, 219, 647, 76, 934, 792, 505, 363, 220, 648, 77, 935, 793, 506, 364, 221, 649, 78, 936, 794, 507, 365, 222, 650, 79, 937, 795, 508, 366, 223, 651, 80, 938, 796, 509, 367, 224, 81, 652, 797, 939, 510, 368, 225, 798, 82, 653, 940, 511, 369, 226, 799, 83, 941, 654, 512, 370, 227, 800, 84, 942, 655, 371, 513, 228, 801, 85, 943, 656, 372, 229, 514, 802, 86, 944, 657, 373, 230, 515, 803, 945, 87, 658, 374, 231, 516, 804, 946, 88, 375, 232, 659, 517, 805, 947, 89, 376, 233, 660, 518, 806, 948, 90, 377, 234, 661, 519, 807, 949, 91, 378, 235, 662, 520, 808, 950, 92, 379, 236, 521, 663, 809, 951, 380, 237, 93, 522, 664, 810, 952, 238, 381, 94, 523, 665, 811, 953, 239, 382, 95, 524, 812, 666, 954, 240, 383, 96, 813, 525, 667, 955, 241, 384, 97, 814, 526, 668, 956, 242, 385, 98, 815, 527, 669, 957, 243, 386, 816, 99, 528, 670, 244, 958, 387, 817, 100, 529, 671, 245, 388, 959, 818, 101, 530, 672, 246, 389, 960, 819, 102, 531, 673, 247, 390, 961, 820, 103, 532, 674, 248, 391, 962, 821, 104, 533, 249, 675, 392, 963, 822, 105, 534, 250, 393, 676, 964, 823, 535, 106, 251, 394, 677, 965, 824, 536, 107, 252, 395, 678, 825, 966, 537, 108, 253, 396, 679, 826, 967, 538, 109, 254, 397, 827, 680, 968, 539, 110, 255, 398, 828, 969, 681, 540, 256, 111, 399, 829, 970, 682, 541, 257, 400, 112, 830, 971, 683, 542, 258, 401, 113, 831, 972, 684, 543, 259, 402, 832, 114, 973, 685, 260, 544, 403, 833, 115, 974, 686, 261, 545, 404, 834, 116, 975, 687, 262, 405, 835, 546, 117, 976, 688, 263, 406, 836, 547, 118, 977, 689, 264, 407, 837, 548, 119, 978, 690, 265, 408, 838, 549, 120, 979, 691, 266, 409, 839, 550, 121, 980, 692, 267, 840, 410, 551, 122, 981, 268, 693, 841, 411, 552, 123, 982, 269, 694, 842, 412, 553, 983, 124, 270, 695, 843, 413, 554, 984, 125, 271, 844, 696, 414, 555, 985, 126, 272, 845, 415, 697, 556, 986, 127, 273, 846, 416, 698, 557, 987, 128, 274, 847, 417, 699, 558, 988, 275, 129, 848, 418, 700, 559, 989, 276, 130, 849, 419, 701, 560, 990, 277, 131, 850, 420, 702, 561, 991, 278, 851, 132, 421, 703, 562, 992, 279, 852, 133, 422, 704, 563, 280, 993, 853, 134, 423, 705, 564, 281, 994, 854, 424, 135, 706, 565, 282, 855, 995, 425, 136, 707, 566, 283, 856, 996, 426, 137, 708, 567, 284, 857, 997, 427, 138, 709, 568, 285, 858, 998, 428, 139, 710, 569, 286, 859, 999, 429, 140, 711, 287, 860, 570, 1000, 430, 141, 288, 712, 861, 571, 431, 1001, 142, 289, 862, 713, 572, 432, 1002, 143, 290, 863, 714, 573, 433, 1003, 144, 291, 864, 715, 574, 434, 1004, 145, 292, 865, 716, 575, 435, 1005, 146, 293, 866, 576, 717, 436, 1006, 147, 294, 867, 577, 437, 718, 1007, 148, 295, 868, 438, 578, 719, 1008, 149, 296, 869, 439, 579, 720, 1009, 150, 297, 870, 440, 580, 151, 721, 1010, 298, 871, 441, 581, 152, 722, 1011, 299, 872, 442, 153, 582, 723, 1012, 300, 873, 443, 154, 583, 724, 1013, 301, 874, 444, 155, 584, 1014, 725, 302, 875, 445, 156, 585, 303, 1015, 726, 876, 446, 157, 586, 304, 1016, 727, 877, 447, 158, 305, 587, 1017, 728, 878, 448, 159, 306, 588, 1018, 879, 729, 449, 160, 307, 589, 1019, 880, 730, 450, 161, 308, 590, 881, 1020, 731, 451, 162, 309, 591, 882, 1021, 732, 452, 163, 310, 592, 883, 1022, 733, 453, 311, 164, 884, 593, 1023, 734, 454, 312, 165, 885, 594, 1024, 735, 313, 455, 166, 886, 595, 1025, 736, 314, 456, 167, 887, 596, 1026, 737, 315, 457, 168, 888, 597, 1027, 738, 316, 458, 169, 889, 598, 1028, 317, 739, 459, 170, 890, 599, 1029, 318, 740, 171, 460, 891, 600, 1030, 319, 741, 172, 461, 892, 601, 320, 1031, 742, 173, 462, 893, 321, 602, 1032, 174, 463, 743, 894, 322, 603, 1033, 175, 464, 744, 895, 323, 604, 176, 1034, 465, 745, 896, 324, 177, 605, 1035, 466, 746, 897, 325, 178, 606, 1036, 467, 747, 898, 326, 179, 607, 1037, 468, 748, 899, 327, 180, 608, 469, 1038, 749, 900, 328, 181, 470, 1039, 609, 750, 901, 329, 182, 471, 1040, 610, 902, 751, 330, 183, 472, 1041, 611, 903, 752, 331, 184, 473, 1042, 612, 904, 753, 332, 185, 474, 1043, 905, 613, 754, 333, 186, 475, 906, 1044, 614, 755, 334, 187, 476, 907, 756, 1045, 335, 615, 188, 477, 908, 757, 336, 1046, 616, 189, 478, 758, 909, 337, 1047, 617, 190, 479, 759, 910, 338, 1048, 618, 191, 480, 760, 911, 339, 1049, 619, 192, 481, 761, 340, 912, 1050, 620, 193, 762, 482, 197, 626, 1051, 194, 621, 763, 483, 769, 625, 1052, 195, 622, 764, 767, 768, 1055, 196, 1053, 623, 765, 624, 1054, 766]
Y2 = [5158, 1800, 0, 409, 0, 356, 108, 5345, 0, 406, 1756, 0, 356, 106, 0, 409, 5540, 1726, 0, 355, 104, 0, 407, 5752, 1698, 0, 354, 103, 0, 408, 1645, 5962, 0, 353, 103, 0, 409, 1629, 6159, 0, 353, 101, 0, 408, 1612, 6338, 0, 353, 101, 0, 411, 1586, 6582, 0, 351, 97, 0, 409, 1539, 6757, 0, 349, 98, 0, 410, 1525, 6972, 0, 350, 95, 0, 411, 1502, 7166, 0, 347, 93, 0, 411, 1473, 7388, 0, 349, 92, 0, 412, 1448, 7591, 0, 346, 0, 90, 412, 1444, 7822, 0, 341, 0, 88, 412, 1388, 8034, 0, 343, 0, 88, 414, 1377, 8260, 0, 340, 0, 85, 415, 1351, 8458, 0, 338, 0, 415, 85, 1323, 8686, 0, 335, 0, 416, 1295, 80, 8908, 0, 336, 0, 417, 1280, 80, 9117, 0, 334, 0, 415, 1242, 78, 9316, 0, 0, 331, 417, 1234, 77, 9521, 0, 0, 332, 417, 1176, 75, 9801, 0, 0, 328, 415, 1188, 73, 9981, 0, 0, 327, 420, 1156, 73, 10184, 0, 0, 326, 417, 1162, 71, 10389, 0, 0, 324, 421, 1131, 10622, 69, 0, 0, 319, 422, 1120, 0, 10806, 68, 0, 317, 422, 1098, 0, 10985, 0, 69, 314, 419, 1098, 0, 11166, 0, 68, 420, 312, 1065, 0, 11368, 0, 68, 418, 1054, 310, 0, 11509, 0, 68, 419, 1036, 309, 0, 0, 11664, 67, 417, 1021, 305, 0, 0, 11788, 419, 1013, 66, 307, 0, 0, 11929, 419, 997, 65, 305, 0, 0, 12044, 418, 966, 66, 297, 0, 0, 12164, 419, 959, 65, 296, 0, 0, 12301, 421, 936, 292, 64, 0, 0, 420, 923, 12372, 289, 63, 0, 0, 913, 419, 12492, 287, 61, 0, 0, 896, 418, 12638, 284, 0, 61, 0, 891, 416, 12673, 0, 282, 61, 0, 883, 414, 12745, 0, 281, 61, 0, 847, 416, 12754, 0, 273, 58, 0, 852, 413, 0, 12836, 268, 57, 823, 0, 413, 0, 12828, 268, 56, 814, 412, 0, 0, 12790, 265, 55, 803, 413, 0, 0, 12692, 264, 54, 786, 410, 0, 0, 12688, 259, 49, 787, 410, 0, 0, 12615, 259, 783, 47, 408, 0, 0, 12583, 254, 781, 404, 43, 0, 0, 254, 12464, 766, 405, 44, 0, 0, 251, 12401, 751, 402, 38, 0, 0, 254, 12284, 738, 400, 37, 0, 0, 254, 12186, 723, 400, 0, 34, 0, 253, 12051, 721, 397, 0, 0, 30, 247, 712, 11910, 398, 0, 0, 28, 249, 703, 397, 11703, 0, 0, 26, 244, 691, 395, 11618, 0, 0, 26, 241, 693, 396, 0, 11430, 0, 22, 674, 242, 397, 0, 11270, 0, 25, 680, 241, 396, 0, 11131, 0, 21, 661, 397, 0, 240, 10890, 0, 22, 654, 391, 0, 236, 10727, 0, 22, 645, 391, 0, 232, 10503, 0, 21, 635, 389, 0, 231, 10339, 0, 20, 613, 391, 0, 231, 10156, 0, 19, 607, 0, 389, 229, 9928, 0, 596, 20, 0, 390, 229, 9765, 0, 583, 20, 0, 387, 229, 0, 9534, 575, 19, 0, 389, 228, 0, 9364, 569, 0, 20, 387, 224, 0, 9208, 564, 0, 386, 18, 222, 0, 8980, 554, 0, 385, 21, 222, 0, 8793, 551, 0, 384, 20, 216, 0, 535, 8611, 0, 383, 21, 217, 0, 542, 8436, 0, 383, 21, 215, 0, 534, 8261, 0, 379, 21, 211, 0, 527, 0, 8072, 380, 18, 213, 0, 528, 0, 7887, 381, 18, 212, 523, 0, 0, 7676, 382, 18, 212, 520, 0, 0, 380, 7499, 17, 208, 520, 0, 0, 381, 7270, 17, 207, 519, 0, 0, 383, 7142, 17, 207, 510, 0, 0, 383, 6965, 16, 205, 503, 0, 0, 383, 6801, 16, 202, 494, 0, 0, 382, 6632, 15, 489, 0, 205, 0, 381, 6535, 486, 15, 0, 201, 379, 0, 6312, 484, 0, 14, 203, 379, 0, 6147, 476, 0, 14, 201, 380, 0, 6009, 469, 0, 14, 199, 380, 0, 5900, 469, 0, 14, 197, 381, 0, 5740, 467, 0, 194, 14, 380, 0, 5614, 460, 0, 192, 380, 14, 0, 5450, 455, 0, 378, 193, 14, 0, 5316, 454, 0, 381, 194, 14, 0, 5148, 460, 0, 379, 190, 5059, 14, 0, 455, 0, 381, 187, 4899, 13, 0, 457, 0, 381, 4802, 185, 13, 0, 451, 0, 381, 4691, 182, 12, 0, 459, 0, 380, 4605, 182, 0, 12, 448, 0, 381, 4469, 179, 454, 0, 12, 0, 380, 4383, 176, 448, 0, 12, 0, 382, 4279, 446, 175, 0, 11, 0, 379, 4174, 448, 172, 0, 0, 12, 381, 4068, 447, 170, 0, 0, 12, 380, 3971, 444, 170, 0, 0, 10, 381, 3906, 438, 169, 0, 0, 10, 379, 3807, 431, 166, 0, 0, 8, 378, 430, 3763, 0, 166, 0, 7, 375, 429, 3668, 0, 166, 0, 7, 428, 377, 3574, 0, 166, 0, 6, 425, 376, 3510, 0, 163, 0, 6, 427, 375, 3437, 0, 161, 0, 7, 425, 376, 3375, 0, 160, 0, 424, 6, 374, 3336, 0, 159, 0, 423, 6, 3264, 372, 0, 159, 0, 423, 6, 3156, 373, 0, 156, 421, 0, 5, 3108, 373, 0, 421, 156, 0, 3030, 371, 5, 0, 419, 155, 0, 2936, 368, 5, 0, 421, 152, 2852, 0, 367, 4, 0, 420, 2795, 155, 0, 367, 3, 0, 419, 2733, 153, 0, 366, 3, 0, 416, 2652, 152, 0, 366, 2, 0, 415, 2615, 151, 364, 0, 2, 0, 416, 2537, 364, 0, 149, 2, 0, 413, 2469, 364, 0, 148, 0, 2, 410, 2444, 363, 0, 146, 0, 1, 414, 2388, 366, 0, 140, 0, 1, 412, 2333, 364, 0, 0, 141, 1, 415, 2290, 364, 0, 0, 138, 0, 413, 2250, 359, 0, 0, 0, 414, 138, 2196, 361, 0, 0, 413, 0, 136, 2162, 358, 0, 0, 415, 0, 135, 2126, 358, 0, 0, 412, 0, 132, 2058, 358, 0, 0, 414, 0, 126, 2038, 359, 0, 408, 0, 0, 122, 1989, 0, 357, 1845, 109, 0, 1961, 119, 0, 358, 0, 112, 0, 1914, 116, 0, 0, 0, 0, 1870, 0, 117, 0, 114, 0, 0]
# fig,ax = plt.subplots()
fig = plt.figure()
ax1 = fig.add_subplot(111)
ax2 = ax1.twinx()
ax1.scatter(X1, Y1, s=10, c='b', marker="s", label='first')
ax2.scatter(X2, Y2, s=10, c='r', marker="o", label='second')
plt.legend(loc='upper right');
plt.show()
It gave me the figure as shown below: Figure 1:
But I want to achieve the following figure:
Figure 2:
I want the Red curve reversed but with the axis of the Blue curve. I mean the high of Red and blue should be at the same position and the red one is reversed.
Please suggest me what I can do to achieve what I want.
CodePudding user response: