Matplotlib and cartopy contours coming out completely wrong - python

I'm trying to plot latency maps of the world (for the moment, from London).
I have a database with a series of latencies between GPS points. I'd like to plot these on a map of the world with contour lines at various levels of latency, eg 50ms, 100ms, 200ms+ etc.
Right now I'm working with some sample code from the cartopy project for drawing labelled contours.
#!/usr/bin/env python3
from collections import defaultdict
import cartopy.crs as ccrs
import matplotlib.pyplot as plt
import numpy as np
from cartopy.examples.waves import sample_data
def main():
# lat, long and then latency from london
zs = [
(55.30927, 25.07725, 123.822),
(19.81889, 41.3275, 61.154),
(-58.37723, -34.61315, 250.024),
(16.37208, 48.20849, 26.987),
(15.45, 47.06667, 49.47),
(115.8614, -31.95224, 273.459),
(138.59863, -34.92866, 257.056),
(151.20732, -33.86785, 258.382),
(144.96332, -37.814, 259.542),
(149.12807, -35.28346, 291.766),
(153.02809, -27.46794, 283.675),
(49.89201, 40.37767, 89.569),
(90.40744, 23.7104, 232.381),
(5.56749, 50.63373, 11.093),
(4.34878, 50.85045, 9.644),
(3.22424, 51.20892, 10.713),
(4.40026, 51.22047, 10.905),
(27.91667, 43.21667, 47.367),
(23.32415, 42.69751, 52.414),
(-34.86306, -7.115, 208.491),
(-46.63611, -23.5475, 180.227),
(-47.92972, -15.77972, 227.893),
(-113.46871, 53.55014, 138.725),
(-73.58781, 45.50884, 84.456),
(-75.69812, 45.41117, 83.592),
(-106.66892, 52.13238, 108.197),
(-79.4163, 43.70011, 90.885),
(-123.11934, 49.24966, 130.308),
(-97.14704, 49.8844, 159.187),
(-63.57291, 44.6464, 74.226),
(-71.21454, 46.81228, 85.994),
(8.55, 47.36667, 22.503),
(8.96004, 46.01008, 33.557),
(6.63282, 46.516, 27.375),
(7.44744, 46.94809, 18.838),
(7.57327, 47.55839, 27.376),
(-70.64827, -33.45694, 195.647),
(114.0683, 22.54554, 233.257),
(121.45806, 31.22222, 191.371),
(120.16142, 30.29365, 237.881),
(114.87944, 40.81, 206.936),
(-75.56359, 6.25184, 150.812),
(-74.08175, 4.60971, 153.555),
(-84.11651, 10.00236, 140.832),
(33.03794, 34.68406, 64.037),
(14.42076, 50.08804, 27.247),
(16.60796, 49.19522, 29.384),
(11.07752, 49.45421, 17.739),
(11.57549, 48.13743, 20.171),
(9.99302, 53.55073, 43.907),
(8.68417, 50.11552, 13.733),
(6.77616, 51.22172, 12.371),
(12.10466, 47.7044, 19.85),
(12.56553, 55.67594, 16.867),
(3.08746, 36.73225, 40.629),
(-78.52495, -0.22985, 161.671),
(24.75353, 59.43696, 34.33),
(31.24967, 30.06263, 63.373),
(-0.37739, 39.46975, 32.652),
(-3.70256, 40.4165, 23.838),
(2.15899, 41.38879, 29.685),
(24.93545, 60.16952, 33.84),
(7.74553, 48.58392, 13.785),
(3.17456, 50.69421, 4.4),
(2.3488, 48.85341, 8.154),
(4.84671, 45.74846, 21.794),
(-1.61396, 54.97328, 5.601),
(-2.23743, 53.48095, 7.15),
(0.51667, 51.26667, 1.404),
(-1.12902, 50.79509, 3.552),
(-3.19648, 55.95206, 10.398),
(-1.51217, 52.40656, 6.462),
(-2.07972, 51.90006, 4.167),
(-3.18, 51.48, 6.116),
(-2.59665, 51.45523, 4.497),
(-5.92541, 54.59682, 10.33),
(44.83368, 41.69411, 88.784),
(-0.1969, 5.55602, 97.088),
(23.72784, 37.98376, 56.074),
(22.93086, 40.64361, 61.766),
(-90.51327, 14.64072, 342.363),
(114.17469, 22.27832, 219.061),
(15.97798, 45.81444, 31.988),
(19.04045, 47.49835, 28.312),
(106.84513, -6.21462, 191.802),
(-6.24889, 53.33306, 11.926),
(-6.92611, 52.84083, 12.585),
(35.21633, 31.76904, 63.795),
(34.78057, 32.08088, 111.049),
(-4.48333, 54.15, 14.732),
(78.15538, 11.65376, 70.362),
(73.85535, 18.51957, 274.087),
(77.22445, 28.63576, 150.969),
(80.27847, 13.08784, 144.037),
(75.8333, 22.71792, 137.159),
(78.45636, 17.38405, 187.213),
(72.88261, 19.07283, 187.64),
(77.59369, 12.97194, 131.413),
(-21.89541, 64.13548, 38.428),
(13.33561, 38.13205, 52.313),
(12.33265, 45.43713, 38.471),
(12.51133, 41.89193, 31.075),
(9.18951, 45.46427, 30.8),
(13.34109, 41.63976, 41.74),
(11.88068, 43.46276, 34.63),
(139.69171, 35.6895, 215.214),
(135.50218, 34.69374, 233.671),
(141.35, 43.06667, 242.554),
(36.81667, -1.28333, 174.557),
(104.91601, 11.56245, 208.175),
(126.9784, 37.566, 266.233),
(73.10211, 49.80187, 123.06),
(35.50157, 33.89332, 64.207),
(25.2798, 54.68916, 38.825),
(23.31667, 55.93333, 42.406),
(6.13, 49.61167, 15.731),
(24.10589, 56.946, 38.292),
(-5.00028, 34.03313, 77.605),
(28.8575, 47.00556, 51.354),
(14.5148, 35.89968, 48.426),
(-103.39182, 20.66682, 132.319),
(3.39467, 6.45407, 96.877),
(4.29861, 52.07667, 8.78),
(4.47917, 51.9225, 6.952),
(6.56667, 53.21917, 8.917),
(5.47778, 51.44083, 8.77),
(5.71806, 52.525, 7.052),
(4.88969, 52.37403, 6.88),
(4.66111, 51.86583, 9.274),
(10.74609, 59.91273, 28.073),
(5.32415, 60.39299, 28.998),
(174.77557, -41.28664, 282.141),
(172.63333, -43.53333, 273.846),
(174.76349, -36.84853, 279.023),
(-79.51973, 8.9936, 150.216),
(-77.02824, -12.04318, 163.241),
(120.9822, 14.6042, 220.693),
(120.33325, 16.04313, 245.787),
(74.35071, 31.558, 150.221),
(21.01178, 52.22977, 31.504),
(18.64912, 54.35227, 38.029),
(-66.10572, 18.46633, 106.983),
(-9.13333, 38.71667, 50.867),
(26.10626, 44.43225, 47.648),
(21.90333, 43.32472, 48.541),
(20.46513, 44.80401, 38.377),
(30.31413, 59.93863, 36.871),
(37.61556, 55.75222, 49.041),
(49.12214, 55.78874, 58.591),
(82.9346, 55.0415, 127.4),
(131.87353, 43.10562, 147.576),
(46.72185, 24.68773, 88.155),
(18.06871, 59.32938, 26.838),
(11.96679, 57.70716, 56.335),
(103.85007, 1.28967, 251.641),
(14.50513, 46.05108, 36.656),
(17.10674, 48.14816, 27.031),
(-55.16682, 5.86638, 166.626),
(100.50144, 13.75398, 265.619),
(10.16579, 36.81897, 52.035),
(27.13838, 38.41273, 67.678),
(32.85427, 39.91987, 60.337),
(28.94966, 41.01384, 51.519),
(29.06013, 40.19559, 72.622),
(121.53185, 25.04776, 261.82),
(39.26951, -6.82349, 150.264),
(30.5238, 50.45466, 41.29),
(36.25272, 49.98081, 58.363),
(32.58219, 0.31628, 159.655),
(-77.03637, 38.89511, 78.045),
(-81.65565, 30.33218, 94.374),
(-80.19366, 25.77427, 99.16),
(-81.37924, 28.53834, 97.119),
(-82.45843, 27.94752, 101.628),
(-84.38798, 33.749, 87.471),
(-81.09983, 32.08354, 119.433),
(-86.15804, 39.76838, 91.394),
(-90.07507, 29.95465, 116.938),
(-76.61219, 39.29038, 77.512),
(-94.57857, 39.09973, 98.802),
(-90.19789, 38.62727, 90.391),
(-90.18481, 32.29876, 105.299),
(-82.55402, 35.60095, 87.855),
(-80.84313, 35.22709, 92.297),
(-78.63861, 35.7721, 83.355),
(-84.51439, 39.12711, 96.657),
(-82.99879, 39.96118, 85.065),
(-97.51643, 35.46756, 108.011),
(-75.16379, 39.95233, 70.659),
(-83.92074, 35.96064, 111.042),
(-90.04898, 35.14953, 106.578),
(-97.74306, 30.26715, 117.634),
(-96.80667, 32.78306, 113.133),
(-95.36327, 29.76328, 105.161),
(-98.49363, 29.42412, 117.229),
(-93.60911, 41.60054, 101.56),
(-87.65005, 41.85003, 89.144),
(-88.30535, 41.88753, 26.006),
(-86.25001, 41.68338, 89.071),
(-71.05977, 42.35843, 75.733),
(-83.04575, 42.33143, 92.257),
(-84.55553, 42.73253, 97.811),
(-93.26384, 44.97997, 97.597),
(-96.66696, 40.8, 97.95),
(-74.39904, 40.49927, 69.437),
(-74.05653, 40.78955, 71.265),
(-73.75623, 42.65258, 74.285),
(-78.87837, 42.88645, 79.13),
(-73.96625, 40.78343, 68.356),
(-74.00597, 40.71427, 71.41),
(-76.14742, 43.04812, 76.038),
(-81.8418, 41.23811, 83.061),
(-81.69541, 41.4995, 93.716),
(-83.55521, 41.66394, 97.349),
(-79.99589, 40.44062, 87.723),
(-75.6649, 41.40916, 73.833),
(-88.01983, 44.51916, 102.133),
(-112.07404, 33.44838, 130.966),
(-121.98857, 37.54827, 134.523),
(-118.24368, 34.05223, 136.396),
(-121.4944, 38.58157, 136.928),
(-117.16472, 32.71571, 146.006),
(-122.41942, 37.77493, 141.373),
(-121.89496, 37.33939, 133.461),
(-104.82136, 38.83388, 108.739),
(-104.9847, 39.73915, 121.039),
(-106.65114, 35.08449, 164.648),
(-115.13722, 36.17497, 146.236),
(-122.39168, 40.58654, 156.6),
(-122.67621, 45.52345, 130.65),
(-123.34174, 43.2165, 147.008),
(-111.89105, 40.76078, 151.18),
(-122.33207, 47.60621, 129.576),
(-157.85833, 21.30694, 186.991),
(-56.18816, -34.90328, 228.291),
(-66.87919, 10.48801, 148.292),
(106.62965, 10.82302, 305.353),
(105.84117, 21.0245, 240.46),
(21.16688, 42.67272, 48.995),
(28.04363, -26.20227, 165.392),
(18.42322, -33.92584, 143.62),
]
z = np.array(zs, dtype="float")
breakpoint()
fig = plt.figure()
# Setup a global EckertIII map with faint coastlines.
ax = fig.add_subplot(1, 1, 1, projection=ccrs.EckertIII())
ax.set_global()
ax.coastlines("110m", alpha=0.1)
# Add colourful filled contours.
filled_c = ax.contourf(z, transform=ccrs.PlateCarree())
# And black line contours.
line_c = ax.contour(
z, levels=filled_c.levels, colors=["black"], transform=ccrs.PlateCarree()
)
# Uncomment to make the line contours invisible.
# plt.setp(line_c.collections, visible=False)
# Add a colorbar for the filled contour.
fig.colorbar(filled_c, orientation="horizontal")
# Use the line contours to place contour labels.
ax.clabel(
line_c, # Typically best results when labelling line contours.
colors=["black"],
manual=False, # Automatic placement vs manual placement.
inline=True, # Cut the line where the label will be placed.
fmt=" {:.0f} ".format, # Labes as integers, with some extra space.
)
plt.show()
if __name__ == "__main__":
main()
Instead of getting nice contours, I get this image:
What's my problem?
Am I passing the wrong args to the matplotlib functions?
Is numpy somehow interpreting my floats wrong?

You need to separate data into lat, long, and height. Then use tricontour type functions to generate the plot. Here is the relevant part of the modified code that handles the data and generate the plot.
# more code before this (see the question)
zs = np.array(zs)
# get `lat`, `long`, and `height` separately
lats, lons, zzz = zs[:,0], zs[:,1], zs[:,2]
fig = plt.figure()
# Setup a global EckertIII map with faint coastlines.
ax = fig.add_subplot(1, 1, 1, projection=ccrs.EckertIII())
ax.set_global()
ax.coastlines("110m", alpha=0.1)
# Add colourful filled contours.
filled_c = ax.tricontourf(lats, lons, zzz, transform=ccrs.PlateCarree())
# And black line contours.
line_c = ax.tricontour(
lats, lons, zzz, levels=filled_c.levels, colors=["black"], transform=ccrs.PlateCarree()
)
# Uncomment to make the line contours invisible.
# plt.setp(line_c.collections, visible=False)
# Add a colorbar for the filled contour.
fig.colorbar(filled_c, orientation="horizontal")
# Use the line contours to place contour labels.
ax.clabel(
line_c, # Typically best results when labelling line contours.
colors=["black"],
manual=False, # Automatic placement vs manual placement.
inline=True, # Cut the line where the label will be placed.
fmt=" {:.0f} ".format, # Labes as integers, with some extra space.
)
plt.show()

Related

Dynamic plotting of multiple circles in python (to see the evolution of a certain trajectory)

I am new to python and was wondering how to dynamically plot multiple circles (one by one) to see the evolution of a certain trajectory for example. All I have as information given to me are the coordinates of each circle (it's center) and the radius of the circles (always 110 mm).
I wrote a very simple code to show you what I would like the final product to look like and the Matrix I use for the coordinates of the center of each circles. I don't know how to animate it though. I looked at matplotlib.animation, but can't seem to find a way to print on the same graph multiple circles one by one and follow that evolution.
Thanks to anyone who can help me :)
Here is the simple code I wrote: (you can copy/paste to see output)
import matplotlib.pyplot as plt
M=[[-353.367, 1033.919], [-332.2289, 1022.62], [-308.9693, 1012.15], [-275.6987, 1009.794], [-255.759, 1012.831], [-227.1466, 1022.136], [-205.0762, 1040.001], [-186.8659, 1063.798], [-169.1376, 1095.61], [-164.1178, 1115.52], [-164.6858, 1145.322], [-172.5163, 1173.053], [-190.4497, 1203.225], [-217.9684, 1218.559], [-243.6059, 1226.065], [-268.9684, 1229.198], [-284.552, 1236.618], [-313.0649, 1245.422], [-341.8054, 1240.937], [-373.7917, 1232.477], [-390.5454, 1213.948], [-414.7616, 1177.002], [-431.7343, 1131.7], [-430.5874, 1111.886], [-422.6885, 1080.612], [-406.6531, 1057.562], [-386.0578, 1045.479], [-363.1557, 1032.198], [-334.0824, 1029.815], [-306.1595, 1034.832], [-275.797, 1050.248], [-251.0765, 1063.588], [-234.0385, 1088.162], [-218.9364, 1116.517], [-215.2409, 1142.459], [-216.5757, 1162.321], [-224.0054, 1193.865], [-239.5592, 1210.065], [-256.5946, 1226.277], [-269.817, 1233.805], [-282.3394, 1244.219], [-310.8614, 1250.199], [-325.9461, 1258.774], [-352.6251, 1273.536], [-378.2938, 1278.17], [-392.2101, 1273.354], [-419.7631, 1259.556], [-443.834, 1239.024], [-462.2394, 1213.344], [-473.6183, 1184.354], [-476.9157, 1148.379], [-471.1018, 1132.955], [-464.7671, 1108.116], [-447.4711, 1086.088], [-424.2345, 1070.545], [-394.7679, 1063.421], [-365.0302, 1062.413], [-337.4447, 1070.366], [-313.6294, 1079.923], [-294.4435, 1100.018], [-273.5304, 1131.008], [-262.598, 1146.377], [-259.7155, 1184.271], [-263.7368, 1213.217], [-275.8035, 1238.906], [-294.8008, 1253.269], [-310.6419, 1267.708], [-337.7829, 1278.309], [-363.7509, 1287.402], [-381.0431, 1308.681], [-401.0663, 1319.924], [-422.0269, 1317.162], [-448.6474, 1304.716], [-473.7899, 1285.203], [-496.8754, 1260.192], [-508.5398, 1227.624], [-512.2774, 1187.758], [-507.8042, 1168.757], [-495.4691, 1143.232], [-476.2492, 1122.938], [-447.8833, 1111.69], [-432.8667, 1105.275], [-403.2355, 1104.286], [-383.3333, 1108.894], [-353.2146, 1119.441], [-328.9186, 1138.472], [-314.5862, 1163.125], [-302.3018, 1181.773], [-296.0374, 1201.452], [-295.3168, 1231.432], [-302.4509, 1259.988], [-313.687, 1280.337], [-329.2202, 1301.075], [-357.1423, 1315.207], [-381.2958, 1324.296], [-407.1058, 1341.854], [-419.993, 1363.024], [-430.4856, 1369.453], [-446.1629, 1365.734], [-475.8101, 1352.226], [-498.8694, 1339.29], [-517.2361, 1311.655], [-530.3865, 1294.905], [-533.8939, 1267.289], [-535.2554, 1237.41], [-528.8127, 1214.766], [-516.8326, 1189.832], [-496.7888, 1170.367], [-465.8856, 1158.17], [-438.7599, 1153.918], [-414.804, 1158.549], [-380.3575, 1171.258], [-352.4823, 1191.146], [-332.798, 1216.418], [-321.6086, 1249.139], [-318.3846, 1279.136], [-323.3752, 1307.856], [-338.4404, 1337.587], [-354.3026, 1350.77], [-380.7487, 1364.942], [-406.5152, 1379.089], [-426.5342, 1393.325], [-434.4213, 1411.274], [-440.8358, 1423.097], [-457.6952, 1421.923], [-477.868, 1411.24], [-506.8693, 1392.765], [-528.1245, 1364.994], [-539.1038, 1336.496], [-546.2713, 1316.544], [-545.8773, 1290.688], [-535.0356, 1262.777], [-518.2655, 1229.677], [-486.7253, 1212.485], [-454.5135, 1207.969], [-418.6611, 1212.69], [-390.2291, 1225.6], [-358.2794, 1253.604], [-341.0657, 1280.357], [-329.5321, 1319.843], [-331.4965, 1358.81], [-347.1193, 1387.638], [-374.7163, 1415.354], [-413.9228, 1428.634], [-434.3252, 1449.438], [-436.9276, 1468.692], [-439.6375, 1479.155], [-455.6206, 1474.209], [-489.7198, 1453.96], [-521.986, 1422.663], [-539.7686, 1384.55], [-543.0701, 1354.541], [-537.5444, 1325.794], [-520.8219, 1296.02], [-499.6737, 1277.328], [-471.653, 1263.555], [-428.4604, 1263.644], [-399.12, 1271.29], [-367.6371, 1293.805], [-341.3217, 1326.764], [-327.3464, 1365.63], [-327.6788, 1410.848], [-342.2673, 1444.753], [-364.3698, 1464.017], [-395.0403, 1480.398], [-421.46, 1499.156], [-426.0284, 1523.588], [-415.4504, 1532.763], [-397.0308, 1529.162], [-373.9081, 1516.305], [-341.4985, 1495.441], [-325.3263, 1468.436], [-312.1562, 1423.641], [-311.4977, 1393.881], [-317.5511, 1362.964], [-339.4044, 1336.628], [-371.6758, 1317.971], [-416.1536, 1315.724], [-455.3117, 1327.009], [-483.2677, 1351.7], [-508.9474, 1376.833], [-523.6409, 1411.456], [-526.3406, 1441.475], [-519.9404, 1482.489], [-493.0933, 1511.768], [-469.0362, 1526.164], [-432.756, 1543.481], [-403.2769, 1563.808], [-391.6133, 1579.361], [-366.1702, 1574.822], [-342.1183, 1555.277], [-310.115, 1533.289], [-288.2865, 1496.987], [-280.5991, 1467.129], [-282.1186, 1428.055], [-299.5267, 1394.554], [-319.8267, 1375.856], [-350.9147, 1362.371], [-400.0623, 1364.378], [-430.872, 1380.399], [-465.416, 1413.822], [-491.4677, 1451.262], [-496.9905, 1481.268], [-492.8149, 1514.172], [-471.2688, 1547.293], [-450.6965, 1568.428], [-424.2299, 1581.129], [-384.9122, 1598.29], [-356.1093, 1614.251], [-338.9459, 1617.087], [-314.669, 1606.542], [-284.1367, 1579.615], [-254.9558, 1554.324], [-243.4746, 1525.626], [-240.235, 1485.667], [-250.3822, 1448.694], [-273.6103, 1419.559], [-297.7935, 1405.516], [-329.8026, 1400.002], [-388.7009, 1413.653], [-414.6778, 1432.243], [-436.7974, 1456.532], [-453.1871, 1494.635], [-456.7498, 1538.398], [-445.8698, 1574.179], [-419.0897, 1601.206], [-388.5554, 1615.067], [-354.7166, 1632.194], [-314.4724, 1643.525], [-280.2189, 1641.387], [-251.6241, 1629.778], [-230.1354, 1603.68], [-208.1479, 1577.854], [-193.7817, 1538.851], [-193.3607, 1508.953], [-201.3903, 1477.549], [-223.9322, 1444.292], [-256.7153, 1430.09], [-295.3913, 1426.766], [-334.7743, 1436.521], [-366.4014, 1460.237], [-389.7171, 1484.86], [-406.069, 1523.158], [-408.3097, 1562.998], [-400.4853, 1590.734], [-382.6054, 1620.927], [-351.6727, 1638.374], [-314.2585, 1647.47], [-280.8991, 1656.951], [-235.3465, 1655.062], [-197.5304, 1637.869], [-173.212, 1616.99], [-154.4203, 1587.273], [-139.5245, 1547.907], [-142.0162, 1495.963], [-158.593, 1473.332], [-186.9524, 1450.806], [-217.6703, 1440.713], [-257.2566, 1443.088], [-295.5097, 1459.153], [-327.2386, 1487.681], [-344.2355, 1514.735], [-355.4432, 1554.364], [-354.3744, 1583.898], [-340.4795, 1610.833], [-321.8054, 1639.23], [-288.5625, 1652.806], [-259.8545, 1659.756], [-213.7623, 1660.159], [-173.7876, 1654.228], [-136.6984, 1635.506], [-106.9547, 1605.329], [-90.45823, 1567.705], [-84.31964, 1531.705], [-89.45423, 1502.995], [-102.8442, 1467.743], [-142.8958, 1444.217], [-181.0074, 1440.788], [-218.7369, 1447.717], [-254.862, 1468.821], [-281.443, 1492.04], [-294.3479, 1527.382], [-300.8553, 1549.361], [-298.0456, 1584.913], [-289.9435, 1611.776], [-267.7791, 1633.974], [-242.0123, 1650.594], [-217.7545, 1658.31], [-184.2669, 1654.097], [-144.8474, 1644.531], [-109.7208, 1637.203], [-82.43204, 1621.707], [-59.36412, 1591.363], [-38.09873, 1563.542], [-30.89796, 1533.667], [-33.99216, 1485.436], [-53.55411, 1456.685], [-79.92442, 1435.82], [-107.0308, 1428.931], [-144.5399, 1428.12], [-175.7949, 1438.916], [-202.2502, 1456.225], [-223.8597, 1479.606], [-242.5855, 1517.033], [-247.6185, 1553.075], [-241.5967, 1576.318], [-227.9895, 1610.275], [-204.6221, 1634.386], [-163.3819, 1644.437], [-130.5885, 1633.278], [-98.96542, 1621.423], [-72.5339, 1615.433], [-43.11806, 1597.279], [-5.99537, 1570.966], [10.92261, 1534.209], [18.19289, 1494.239], [10.92241, 1449.578], [-8.584769, 1432.486], [-31.02674, 1410.048], [-69.68215, 1401.698], [-113.4156, 1404.994], [-143.2605, 1419.77], [-162.732, 1440.016], [-185.1952, 1478.715], [-198.0868, 1518.472], [-194.5775, 1547.854], [-180.9837, 1589.557], [-153.4026, 1607.14], [-123.1798, 1617.854], [-87.55124, 1607.125], [-66.58879, 1591.694], [-47.51177, 1581.649], [-15.81822, 1567.318], [21.46709, 1544.121], [46.09593, 1509.497], [57.37705, 1480.045], [57.36242, 1440.343], [44.0697, 1404.997], [18.25326, 1381.899], [-7.351728, 1370.322], [-32.2257, 1364.652], [-66.11478, 1368.577], [-100.2056, 1380.902], [-124.5261, 1403.595], [-145.2667, 1438.634], [-157.1636, 1474.231], [-157.4587, 1513.443], [-145.1665, 1539.583], [-119.9591, 1566.394], [-89.40922, 1580.139], [-53.67052, 1570.516], [-32.64999, 1548.108], [-16.66615, 1536.516], [6.490777, 1529.025], [31.97713, 1514.448], [60.08655, 1484.993], [81.14851, 1453.727], [88.46942, 1423.841], [81.74537, 1375.701], [67.44641, 1351.281], [46.61972, 1332.588], [15.0952, 1320.228], [-12.26343, 1318.346], [-42.129, 1324.324], [-75.54681, 1338.252], [-101.5572, 1367.278], [-118.0977, 1394.486], [-128.0707, 1438.201], [-123.8414, 1472.884], [-108.7894, 1501.175], [-78.72721, 1525.078], [-46.19279, 1533.898], [-23.59591, 1521.328], [-7.722545, 1495.371], [2.110508, 1483.757], [27.42411, 1475.468], [61.11173, 1453.39], [88.5411, 1429.751], [100.7274, 1398.062], [106.1155, 1368.119], [103.9678, 1333.036], [86.48449, 1299.491], [58.09462, 1276.048], [31.18663, 1267.566], [-4.258423, 1266.381], [-33.82413, 1275.022], [-69.1487, 1297.679], [-89.99754, 1330.714], [-107.3487, 1359.621], [-111.1309, 1389.672], [-103.752, 1441.02], [-68.02649, 1469.898], [-34.99534, 1481.813], [-8.461586, 1473.875], [-0.1402668, 1452.983], [2.639243, 1434.012], [9.501756, 1428.734], [35.01265, 1418.973], [60.25186, 1402.637], [82.93935, 1380.076], [103.5159, 1343.29], [110.4929, 1299.416], [104.37, 1265.672], [88.31962, 1249.234], [71.85352, 1226.983], [44.76006, 1218.187], [25.78514, 1211.846], [-4.032246, 1212.962], [-35.28857, 1220.177], [-60.11924, 1236.0], [-78.1687, 1258.27], [-99.41018, 1281.373], [-100.1344, 1281.373], [-102.1007, 1324.693], [-106.4406, 1367.235], [-86.26932, 1399.474], [-60.85463, 1410.725], [-44.8115, 1425.372], [-15.77799, 1422.786], [-3.165829, 1402.704], [-4.200755, 1382.766], [-14.88467, 1374.684], [-37.12067, 1369.416], [-55.75563, 1356.069], [-83.39506, 1335.855], [-102.8612, 1310.411], [-113.7677, 1277.62], [-116.6935, 1247.634], [-111.4152, 1226.374], [-102.5447, 1205.037], [-89.81829, 1182.588], [-62.18055, 1164.957], [-34.44635, 1157.941], [-4.697551, 1158.479], [24.80031, 1166.713], [55.11592, 1189.81], [82.74968, 1214.07], [95.09119, 1242.216], [100.8731, 1278.122], [97.81202, 1307.189], [86.77965, 1333.134], [68.61958, 1354.043], [48.2424, 1369.461], [19.12447, 1372.624], [-0.8152943, 1361.971], [-17.21025, 1340.192], [-32.79333, 1326.46], [-52.63164, 1321.488], [-71.75038, 1307.899], [-102.1292, 1288.402], [-120.6276, 1267.054], [-131.8435, 1248.589], [-137.8415, 1219.025], [-138.2087, 1197.053], [-135.7063, 1170.291], [-122.9438, 1144.966], [-103.781, 1124.957], [-79.13057, 1112.104], [-44.85416, 1107.323], [-20.89322, 1110.864], [11.95125, 1117.725], [32.82501, 1131.874], [47.87254, 1146.108], [64.46723, 1171.654], [76.13985, 1210.502], [76.94341, 1244.263], [69.95406, 1271.886], [53.59194, 1295.287], [28.41202, 1312.713], [5.259316, 1322.112], [-23.90935, 1314.675], [-49.2878, 1295.755], [-65.5571, 1284.006], [-77.68121, 1280.748], [-98.63795, 1271.883], [-128.6358, 1251.447], [-148.9674, 1236.27], [-165.4682, 1209.712], [-172.2538, 1186.354], [-173.92, 1150.461], [-169.078, 1131.317], [-156.4, 1105.401], [-138.3503, 1088.234], [-120.7542, 1072.757], [-87.36267, 1065.241], [-63.5072, 1064.928], [-39.72315, 1073.128], [-3.400684, 1088.865], [16.01539, 1107.792], [30.89093, 1128.555], [40.31864, 1153.436], [43.63892, 1183.407], [38.95707, 1212.601], [27.39531, 1233.896], [15.34975, 1256.269], [-7.563136, 1272.373], [-38.67617, 1279.378], [-66.80437, 1268.137], [-93.26956, 1258.181], [-111.3685, 1247.295], [-145.3048, 1237.571], [-168.5001, 1226.962], [-189.6831, 1208.908], [-198.3916, 1197.501], [-210.5756, 1160.37], [-217.9469, 1130.447], [-214.9319, 1095.652], [-204.0248, 1078.16], [-190.0907, 1059.948], [-170.6554, 1042.757], [-143.9037, 1033.326], [-114.5352, 1031.72], [-84.7283, 1039.733], [-53.30964, 1055.187], [-30.04264, 1077.168], [-12.66869, 1103.878], [-1.486558, 1137.312], [-1.064299, 1157.3], [-5.341586, 1185.994], [-18.21387, 1215.658], [-40.97787, 1228.778], [-54.11655, 1236.161], [-76.08755, 1246.099], [-105.6179, 1244.681], [-135.4744, 1236.043], [-174.7149, 1232.536], [-184.5176, 1225.9], [-220.0076, 1220.869], [-249.2242, 1210.986], [-276.3006, 1191.326], [-301.6652, 1173.228], [-316.6139, 1150.25], [-323.868, 1117.092], [-326.3884, 1097.087], [-322.1166, 1059.155], [-304.9708, 1034.98], [-285.515, 1018.597], [-263.4151, 1006.624], [-234.8072, 1002.626], [-200.9287, 1007.067], [-170.5251, 1019.518], [-150.2951, 1036.233], [-124.2688, 1064.341], [-113.8737, 1093.0], [-109.5216, 1132.898], [-115.8234, 1161.196], [-129.8293, 1185.697], [-153.6055, 1207.544], [-179.8143, 1217.768], [-214.8842, 1221.203], [-244.943, 1224.325], [-269.0096, 1226.253], [-304.297, 1221.33], [-317.3503, 1210.094], [-345.5856, 1190.689], [-362.5714, 1165.841], [-378.0464, 1137.345], [-381.3854, 1113.39], [-379.4114, 1083.903], [-366.9059, 1048.939], [-341.1812, 1028.518], [-317.4363, 1013.372], [-290.7552, 1009.945], [-262.8416, 1011.018], [-239.3678, 1021.605], [-207.5487, 1032.593], [-190.1064, 1054.388], [-173.9324, 1086.723], [-165.1843, 1106.384], [-164.0149, 1146.167], [-172.0801, 1177.211], [-199.4012, 1203.769], [-216.9979, 1220.357], [-260.0022, 1228.974], [-277.6455, 1236.919], [-311.9639, 1245.999], [-346.5475, 1241.313], [-374.5607, 1227.686], [-398.7542, 1207.302], [-417.3307, 1181.762], [-429.835, 1154.858], [-432.4515, 1136.847], [-431.9319, 1112.987], [-423.1529, 1088.577], [-413.3953, 1064.005], [-388.5888, 1045.024], [-362.3439, 1032.438], [-333.2143, 1029.841], [-309.2604, 1033.416], [-284.1591, 1040.317], [-261.3084, 1053.24], [-243.3964, 1075.171], [-225.6251, 1107.614], [-216.5621, 1131.302], [-216.7274, 1167.062], [-225.1822, 1194.614], [-241.3986, 1213.666], [-257.2806, 1232.254], [-283.1432, 1243.899], [-313.6137, 1251.092], [-339.1638, 1264.362], [-357.9759, 1276.749], [-389.4101, 1274.932], [-415.205, 1267.437], [-432.2913, 1245.894], [-457.3329, 1212.539], [-476.3467, 1179.487], [-476.8618, 1149.49], [-470.8127, 1115.837], [-458.1615, 1099.495], [-441.1498, 1079.599], [-409.1117, 1066.836], [-382.1244, 1062.366], [-368.1576, 1063.508], [-329.0669, 1072.368], [-306.1739, 1086.485], [-284.2929, 1108.712], [-271.2411, 1135.612]]
fig, ax = plt.subplots()
for [x,y] in M:
circle = plt.Circle((-x,y), 110, color='r',alpha=0.015)
ax.add_patch(circle)
plt.tight_layout()
plt.grid()
plt.axis([-300, 800, 800, 1800])
plt.show()

Plot wont display in python

I'm using the following bit of code to plot two arrays of the same length -
import matplotlib.pyplot as plt
from scipy import stats
from scipy.stats import linregress
G_mag_values = [11.436, 11.341, 11.822, 11.646, 11.924, 12.057, 11.884, 11.805, 12.347, 12.662, 12.362, 12.555, 12.794, 12.819, 12.945, 12.733, 12.789, 12.878, 12.963, 13.094, 13.031, 12.962, 13.018, 12.906, 13.016, 13.088, 13.04, 13.035, 13.094, 13.032, 13.216, 13.062, 13.083, 13.126, 13.101, 13.089, 13.073, 13.182, 13.116, 13.145, 13.235, 13.161, 13.154, 13.383, 13.315, 13.429, 13.461, 13.287, 13.494, 13.459, 13.478, 13.534, 13.536, 13.536, 13.483, 13.544, 13.564, 13.544, 13.608, 13.655, 13.665, 13.668, 13.697, 13.649, 13.742, 13.756, 13.671, 13.701, 13.788, 13.723, 13.697, 13.713, 13.708, 13.765, 13.847, 13.992, 13.706, 13.79, 13.783, 13.844, 13.945, 13.928, 13.936, 13.956, 13.898, 14.059, 13.945, 14.039, 13.999, 14.087, 14.05, 14.083, 14.136, 14.124, 14.189, 14.149, 14.182, 14.281, 14.177, 14.297, 14.268, 14.454, 14.295]
G_cal_values = [-8.553610547563503, -8.085853602272588, -7.98491731861732, -7.852060056526794, -7.550944423333883, -7.569289687795749, -7.547088847268468, -7.544445036682168, -7.480698829329534, -7.184407435874912, -7.382606680295108, -7.2231275160942054, -7.093385973539046, -7.0473097125206685, -6.775012624594927, -6.814667514017907, -6.719898703328146, -6.741699011193633, -6.483121454948265, -6.320533066162438, -6.216044707275117, -6.037365656714626, -6.058593802250578, -6.0203190345840865, -6.036176430437363, -5.817887798572345, -5.838439347527171, -5.864922270102037, -5.755152671040021, -5.7709095683554725, -5.729226240967218, -5.606533007538604, -5.5817719334376905, -5.578993138005095, -5.62616747769538, -5.648413591916503, -5.611676700504294, -5.557722166623976, -5.5584623064502825, -5.425878164810264, -5.582204334985258, -5.529395790688368, -5.560750195967957, -5.433224654816512, -5.4751198268734385, -5.4592032005417215, -5.514591770369543, -5.580278698184566, -5.520695348050357, -5.501615700174841, -5.578645415877418, -5.692203332547151, -5.569497861450115, -5.335209902666812, -5.470963349023013, -5.44265375533589, -5.538541653702721, -5.355732832969871, -5.318164588926453, -5.376154615199398, -5.372133774215322, -5.361689907587619, -5.37608154921679, -5.412657572197508, -5.454613589602333, -5.339384591430104, -5.367511403407703, -5.258069473329993, -5.347580031901464, -4.9905279263992, -5.445096880253789, -5.192885553786512, -5.2983352094538505, -5.3930571447307365, -5.057910469318639, -5.32585105504838, -5.238649399637653, -5.122431894813153, -5.084559296025157, -5.139042420486851, -4.9919273140342915, -5.103619454431522, -5.017946144298159, -4.98136832081144, -5.084355565584671, -5.048634391386494, -4.887073481359435, -5.074683293771264, -5.050703776716202, -5.104772289705188, -4.9597601680524415, -4.971489935988787, -4.895283369236485, -4.9859511256778974, -4.840717539517584, -4.815665714699117, -4.937635861879118, -4.887219819695687, -4.813729758415283, -4.82667464608015, -4.865176481168528, -4.885105289124561, -4.887072278243732]
fig, ax = plt.subplots()
plt.scatter(G_mag_values,G_cal_values)
ax.minorticks_on()
ax.grid(which='major', linestyle='-', linewidth='0.5')
ax.grid(which='minor', linestyle='-', linewidth='0.5')
fig.set_size_inches(10,7)
best_fit_Y_G = []
slope_G, intercept_G, r_value_G, p_value_G, std_err_G = stats.linregress(G_mag_values,G_cal_values)
for value_G in G_mag_values:
best_fit_Y_G.append(intercept_G + slope_G*value_G)
plt.plot(G_mag_values, best_fit_Y_G, 'r', label = 'Best fit')
plt.title('M67 Calibration graph for G filter')
plt.xlabel('Real magnitude')
plt.ylabel('Measured magnitude')
plt.show()
curve_G = np.polyfit(G_mag_values,G_cal_values,1)
print('G filter polyfit line: slope {}; intercept = {}'.format(curve_G[0],curve_G[1]))
print('G filter linregress: slope {}; intercept = {}'.format(slope_G,intercept_G))
When I run this, it prints the values for slope and intercept from the best_fit_Y_G and curve_G, but it doesnt display the plot at all. Where am I going wrong?
I copy/pasted and run your code.
curve_G = np.polyfit(G_mag_values,G_cal_values,1)
That line gives me error. Then I imported numpy as np and problem solved.
output figure

plt.tricontourf(x,y,z) creating color values outside of data bounds

I am attempting to make compressor and turbine maps colored by efficiency. I have achieved this, but the tricontourf I am attempting leads to level colors outside of where my data even exists. I need to make sure the contour ends at the bounds of my data. Is there a way to achieve this?
My code:
import numpy as np
import matplotlib.pyplot as plt
alphaMap = np.array([0.000, 90.000])
NcMap = np.array([0.300, 0.400, 0.500, 0.600, 0.700, 0.750, 0.800, 0.850, 0.900, 0.950, 1.000, 1.050, 1.100, 1.150])
RlineMap = np.array([1.000, 1.200, 1.400, 1.600, 1.800, 2.000, 2.200, 2.400, 2.600, 2.800, 3.000])
WCmap = np.array([[[17.907, 19.339, 20.749, 22.136, 23.498, 24.833, 26.141, 27.420, 28.669, 29.887, 31.011],
[24.951, 26.742, 28.485, 30.177, 31.815, 33.397, 34.921, 36.385, 37.788, 39.128, 40.405],
[32.682, 34.715, 36.662, 38.520, 40.286, 41.958, 43.533, 45.011, 46.390, 47.669, 48.848],
[40.927, 43.115, 45.168, 47.083, 48.858, 50.492, 51.983, 53.331, 54.539, 55.607, 56.537],
[49.850, 52.122, 54.195, 56.068, 57.741, 59.215, 60.494, 61.580, 62.479, 63.197, 63.739],
[54.798, 57.066, 59.099, 60.897, 62.463, 63.800, 64.913, 65.810, 66.497, 66.983, 67.278],
[60.051, 62.252, 64.185, 65.851, 67.255, 68.405, 69.307, 69.973, 70.413, 70.638, 70.675],
[65.313, 67.427, 69.262, 70.824, 72.118, 73.153, 73.938, 74.484, 74.803, 74.907, 74.907],
[70.995, 72.902, 74.542, 75.920, 77.043, 77.920, 78.560, 78.974, 79.174, 79.198, 79.198],
[77.441, 78.904, 80.155, 81.199, 82.042, 82.690, 83.151, 83.434, 83.545, 83.548, 83.548],
[84.344, 85.211, 85.952, 86.572, 87.074, 87.460, 87.735, 87.903, 87.967, 87.968, 87.968],
[89.305, 89.687, 90.025, 90.320, 90.572, 90.783, 90.953, 91.083, 91.174, 91.227, 91.243],
[93.626, 93.712, 93.793, 93.868, 93.939, 94.004, 94.064, 94.120, 94.170, 94.216, 94.257],
[95.978, 95.989, 96.000, 96.012, 96.022, 96.033, 96.044, 96.054, 96.064, 96.074, 96.084]],
[[17.907, 19.339, 20.749, 22.136, 23.498, 24.833, 26.141, 27.420, 28.669, 29.887, 31.011],
[24.951, 26.742, 28.485, 30.177, 31.815, 33.397, 34.921, 36.385, 37.788, 39.128, 40.405],
[32.682, 34.715, 36.662, 38.520, 40.286, 41.958, 43.533, 45.011, 46.390, 47.669, 48.848],
[40.927, 43.115, 45.168, 47.083, 48.858, 50.492, 51.983, 53.331, 54.539, 55.607, 56.537],
[49.850, 52.122, 54.195, 56.068, 57.741, 59.215, 60.494, 61.580, 62.479, 63.197, 63.739],
[54.798, 57.066, 59.099, 60.897, 62.463, 63.800, 64.913, 65.810, 66.497, 66.983, 67.278],
[60.051, 62.252, 64.185, 65.851, 67.255, 68.405, 69.307, 69.973, 70.413, 70.638, 70.675],
[65.313, 67.427, 69.262, 70.824, 72.118, 73.153, 73.938, 74.484, 74.803, 74.907, 74.907],
[70.995, 72.902, 74.542, 75.920, 77.043, 77.920, 78.560, 78.974, 79.174, 79.198, 79.198],
[77.441, 78.904, 80.155, 81.199, 82.042, 82.690, 83.151, 83.434, 83.545, 83.548, 83.548],
[84.344, 85.211, 85.952, 86.572, 87.074, 87.460, 87.735, 87.903, 87.967, 87.968, 87.968],
[89.305, 89.687, 90.025, 90.320, 90.572, 90.783, 90.953, 91.083, 91.174, 91.227, 91.243],
[93.626, 93.712, 93.793, 93.868, 93.939, 94.004, 94.064, 94.120, 94.170, 94.216, 94.257],
[96.084, 96.074, 96.064, 96.054, 96.044, 96.033, 96.022, 96.012, 96.000, 95.989, 95.978]]])
effMap = np.array([[[.8070, .8291, .8461, .8566, .8586, .8497, .8170, .7410, .6022, .3674, .0000],
[.8230, .8454, .8628, .8741, .8775, .8708, .8419, .7732, .6477, .4372, .0916],
[.8411, .8631, .8805, .8921, .8966, .8918, .8671, .8065, .6959, .5124, .2168],
[.8565, .8783, .8957, .9077, .9131, .9099, .8883, .8338, .7340, .5696, .3083],
[.8662, .8879, .9055, .9179, .9239, .9219, .9024, .8520, .7600, .6096, .3739],
[.8699, .8917, .9093, .9218, .9281, .9265, .9080, .8598, .7721, .6297, .4089],
[.8743, .8957, .9130, .9253, .9316, .9304, .9131, .8678, .7858, .6538, .4519],
[.8836, .9026, .9179, .9287, .9342, .9331, .9183, .8804, .8128, .7065, .5485],
[.8943, .9103, .9230, .9319, .9362, .9351, .9231, .8930, .8406, .7602, .6442],
[.9060, .9169, .9253, .9310, .9334, .9321, .9236, .9036, .8703, .8211, .7529],
[.9170, .9224, .9264, .9288, .9293, .9280, .9231, .9127, .8962, .8730, .8423],
[.9159, .9171, .9176, .9177, .9171, .9159, .9136, .9097, .9042, .8968, .8876],
[.9061, .9059, .9055, .9052, .9047, .9042, .9036, .9028, .9018, .9007, .8994],
[.8962, .8964, .8965, .8966, .8967, .8968, .8969, .8970, .8971, .8972, .8973]],
[[.8070, .8291, .8461, .8566, .8586, .8497, .8170, .7410, .6022, .3674, .0714],
[.8230, .8454, .8628, .8741, .8775, .8708, .8419, .7732, .6477, .4372, .0916],
[.8411, .8631, .8805, .8921, .8966, .8918, .8671, .8065, .6959, .5124, .2168],
[.8565, .8783, .8957, .9077, .9131, .9099, .8883, .8338, .7340, .5696, .3083],
[.8662, .8879, .9055, .9179, .9239, .9219, .9024, .8520, .7600, .6096, .3739],
[.8699, .8917, .9093, .9218, .9281, .9265, .9080, .8598, .7721, .6297, .4089],
[.8743, .8957, .9130, .9253, .9316, .9304, .9131, .8678, .7858, .6538, .4519],
[.8836, .9026, .9179, .9287, .9342, .9331, .9183, .8804, .8128, .7065, .5485],
[.8943, .9103, .9230, .9319, .9362, .9351, .9231, .8930, .8406, .7602, .6442],
[.9060, .9169, .9253, .9310, .9334, .9321, .9236, .9036, .8703, .8211, .7529],
[.9170, .9224, .9264, .9288, .9293, .9280, .9231, .9127, .8962, .8730, .8423],
[.9159, .9171, .9176, .9177, .9171, .9159, .9136, .9097, .9042, .8968, .8876],
[.9061, .9059, .9055, .9052, .9047, .9042, .9036, .9028, .9018, .9007, .8994],
[.8962, .8964, .8965, .8966, .8967, .8968, .8969, .8970, .8971, .8972, .8973]]])
PRmap = np.array([[[1.0678, 1.0649, 1.0613, 1.0571, 1.0522, 1.0468, 1.0402, 1.0322, 1.0227, 1.0117, 1.0000],
[1.1239, 1.1186, 1.1122, 1.1047, 1.0962, 1.0865, 1.0751, 1.0611, 1.0445, 1.0257, 1.0045],
[1.1994, 1.1910, 1.1809, 1.1691, 1.1558, 1.1409, 1.1233, 1.1020, 1.0771, 1.0488, 1.0173],
[1.2981, 1.2855, 1.2706, 1.2533, 1.2339, 1.2122, 1.1869, 1.1563, 1.1210, 1.0811, 1.0370],
[1.4289, 1.4111, 1.3899, 1.3655, 1.3380, 1.3076, 1.2720, 1.2295, 1.1804, 1.1254, 1.0654],
[1.5118, 1.4909, 1.4661, 1.4375, 1.4052, 1.3695, 1.3278, 1.2779, 1.2205, 1.1565, 1.0868],
[1.6070, 1.5827, 1.5538, 1.5205, 1.4831, 1.4417, 1.3934, 1.3358, 1.2697, 1.1962, 1.1165],
[1.7160, 1.6881, 1.6555, 1.6183, 1.5767, 1.5312, 1.4785, 1.4160, 1.3448, 1.2660, 1.1808],
[1.8402, 1.8086, 1.7724, 1.7318, 1.6869, 1.6381, 1.5824, 1.5170, 1.4430, 1.3615, 1.2736],
[1.9930, 1.9587, 1.9206, 1.8788, 1.8336, 1.7852, 1.7309, 1.6685, 1.5988, 1.5225, 1.4405],
[2.1593, 2.1257, 2.0899, 2.0518, 2.0117, 1.9695, 1.9235, 1.8724, 1.8163, 1.7557, 1.6909],
[2.2764, 2.2510, 2.2248, 2.1978, 2.1701, 2.1416, 2.1118, 2.0801, 2.0464, 2.0108, 1.9735],
[2.3771, 2.3664, 2.3557, 2.3448, 2.3339, 2.3229, 2.3118, 2.3004, 2.2887, 2.2768, 2.2646],
[2.4559, 2.4538, 2.4516, 2.4495, 2.4473, 2.4452, 2.443, 2.4409, 2.4387, 2.4365, 2.4343]],
[[1.0678, 1.0649, 1.0613, 1.0571, 1.0522, 1.0468, 1.0402, 1.0322, 1.0227, 1.0117, 1.0000],
[1.1239, 1.1186, 1.1122, 1.1047, 1.0962, 1.0865, 1.0751, 1.0611, 1.0445, 1.0257, 1.0045],
[1.1994, 1.1910, 1.1809, 1.1691, 1.1558, 1.1409, 1.1233, 1.1020, 1.0771, 1.0488, 1.0173],
[1.2981, 1.2855, 1.2706, 1.2533, 1.2339, 1.2122, 1.1869, 1.1563, 1.1210, 1.0811, 1.0370],
[1.4289, 1.4111, 1.3899, 1.3655, 1.3380, 1.3076, 1.2720, 1.2295, 1.1804, 1.1254, 1.0654],
[1.5118, 1.4909, 1.4661, 1.4375, 1.4052, 1.3695, 1.3278, 1.2779, 1.2205, 1.1565, 1.0868],
[1.6070, 1.5827, 1.5538, 1.5205, 1.4831, 1.4417, 1.3934, 1.3358, 1.2697, 1.1962, 1.1165],
[1.7160, 1.6881, 1.6555, 1.6183, 1.5767, 1.5312, 1.4785, 1.4160, 1.3448, 1.2660, 1.1808],
[1.8402, 1.8086, 1.7724, 1.7318, 1.6869, 1.6381, 1.5824, 1.5170, 1.4430, 1.3615, 1.2736],
[1.9930, 1.9587, 1.9206, 1.8788, 1.8336, 1.7852, 1.7309, 1.6685, 1.5988, 1.5225, 1.4405],
[2.1593, 2.1257, 2.0899, 2.0518, 2.0117, 1.9695, 1.9235, 1.8724, 1.8163, 1.7557, 1.6909],
[2.2764, 2.2510, 2.2248, 2.1978, 2.1701, 2.1416, 2.1118, 2.0801, 2.0464, 2.0108, 1.9735],
[2.3771, 2.3664, 2.3557, 2.3448, 2.3339, 2.3229, 2.3118, 2.3004, 2.2887, 2.2768, 2.2646],
[2.4343, 2.4365, 2.4387, 2.4409, 2.4430, 2.4452, 2.4473, 2.4495, 2.4516, 2.4538, 2.4559]]])
label = []
for x in NcMap:
label.append(x*100)
for i in range(0,14):
plt.annotate('{0}%'.format(round(label[i],2)),xy = ((flowmax[i],PRmax[i])), textcoords='offset points', xytext=(0,6), ha = 'center', color = 'b')
plt.xlim(0,1)
plt.ylim(1,8)
plt.ylabel(r'$PR_{off}$', fontsize=16)
plt.xlabel(r'$\.m_{c,off} [kg/s]$', fontsize=16)
x = WCmap[0,:14,:]
x = x.flatten().tolist()
y = PRmap[0,:14,:]
y = y.flatten().tolist()
z = effMap[0,:14,:]
z = z.flatten().tolist()
plt.tricontourf(x,y,z, cmap = 'jet')
cbar = plt.colorbar()
cbar.set_label(r'$\eta_{off}$', fontsize=16)
plt.show()
Compressor Map Plot

Cartopy incorrectly filling outside of Shapely polygon

The Shapely polygon listed below as "mywkt" plots incorrectly in Cartopy; it fills the outside rather than the inside, despite being a valid polygon. In GIS software it plots correctly. The issue is occurring in many projections tested, including the one below. How can I correct it to fill the inside, as would be expected?
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
from cartopy.feature import ShapelyFeature
import shapely
import shapely.wkt as wkt
# Main plot setup, issue occurs regardless of projection used.
fig = plt.figure(figsize=[5, 5])
crs = ccrs.NearsidePerspective(central_longitude=-100, central_latitude=65, satellite_height=6200000)
ax = fig.add_subplot(1, 1, 1, projection=crs)
# Build and plot the polygon, valid
mywkt = "POLYGON ((-66.64127406774401 63.2679483443407, -66.48652697503979 63.1988718046901, -66.4817891045834 63.1004449790526, -66.379143168922 63.0115892305586, -66.1973803825985 62.9848443902565, -66.0559008189676 62.9537393506905, -65.97118398525259 62.9850694644843, -65.850509788396 62.9360773051236, -65.69642646101229 62.9192773820456, -65.6182098640938 62.8587266887857, -65.473922680887 62.8270608886491, -65.3890303678572 62.8197557451316, -65.31233201541011 62.7191354685271, -65.25006848777041 62.6268846390149, -65.12107061571631 62.5688402034127, -64.96662902810711 62.6103134144326, -64.52292746513029 60.3009837190234, -64.678588195289 60.3290634023542, -64.7726142595404 60.3596734442741, -64.8751520004644 60.2840499669325, -64.9515074450125 60.2243558221635, -65.0198404413832 60.1228099129471, -65.095375384966 60.0444670754952, -65.1483835964257 59.944148956709, -65.2920146315699 59.8405379513654, -65.453168021487 59.7919610620534, -65.47048148623151 59.6270483926692, -65.4267596751189 59.4696754279787, -65.49367684990671 59.3679086749455, -65.6342827626394 59.2531493848363, -65.6786190418353 59.1322782877129, -65.7005535515051 59.0241583127559, -65.8285595801605 58.9623716488326, -65.9420170341587 58.8275171137239, -66.0506960726655 58.7706855047323, -66.149750409254 58.7371845390353, -66.256134042452 58.7978006318937, -66.3347385322574 58.8311493351738, -66.45372349384409 58.800538690708, -66.49451082791229 58.7198367831411, -66.5676193169778 58.6466901412371, -66.6218795870732 58.5770604645689, -66.7814218532359 58.4949434629705, -66.88831340553919 58.4688908893032, -67.0380290656889 58.4144607966286, -67.1342663928796 58.3776258669403, -67.2353212911446 58.3398129542046, -67.33057432114791 58.3205410987927, -67.47232732814371 58.2854808444655, -67.5925217519772 58.1990972702229, -67.6903910465095 58.2706693512096, -67.7234163041191 58.3415155704872, -67.81171229568589 58.4379109661182, -67.9250695391279 58.4466397966894, -68.0271575596735 58.5408090366078, -68.1713938511453 58.5239214763951, -68.3308705567307 58.6276111553306, -68.37026229227089 58.7457949055105, -68.4149256971631 58.8196035851374, -68.5609516754794 58.8743733607421, -68.67261845427809 58.9022758569453, -68.8273157758023 58.9054559910013, -68.9202407883817 58.878506525256, -69.07570399414401 58.9052582049023, -69.2647591176391 58.8920751275651, -69.3652429760824 58.869404278185, -69.4899762315179 58.7899739103677, -69.6132537210823 58.7566270839728, -69.72686138794261 58.6796452157541, -69.842988449757 58.6732594077955, -69.8395047468465 58.8392757000136, -69.6917509226669 58.8574368306453, -69.5327113793267 58.8471842391614, -69.46260960175159 58.9405896192156, -69.4404513848235 59.0222669548561, -69.3474281644782 59.1017357623955, -69.3028958231836 59.2196576443848, -69.4281941172646 59.3568617410766, -69.5182813676909 59.3316304588787, -69.6520868841024 59.4400386197865, -69.65458094065789 59.5726276160716, -69.5578593654174 59.6813767639266, -69.5928206493534 59.798270974426, -69.70748724543991 59.9355825212164, -69.737201347664 60.0551376260007, -69.616491617694 60.15187842425, -69.6398101732009 60.2406957887797, -69.7022901640597 60.3436465118771, -69.7505086681404 60.4372696447783, -69.7298120033212 60.5385315013278, -69.6576941750461 60.635072446836, -69.58624424267749 60.736179235983, -69.5121017580896 60.7615279039897, -69.4052339964517 60.8147459704502, -69.4564300739886 60.9777373363091, -69.5537354306456 61.0800360797014, -69.67305901935821 60.9755718380699, -69.74723982315921 60.8975333096147, -69.84465196801381 60.847667578496, -69.99184594083739 60.836894867704, -70.1006539538168 60.9605688827478, -70.1916436091651 61.0764643475517, -70.3686452388866 61.0577015965515, -70.5324451896937 61.0420612242462, -70.66397847542621 61.043868155591, -70.8089575088819 61.0657154903776, -70.9218584021435 61.0859015570113, -71.1063331804318 61.1279448078067, -71.2168983247977 61.13527297217, -71.39589387470249 61.1518817695281, -71.5711726138249 61.2143165838433, -71.67622634576909 61.2783583103878, -71.7435230974129 61.4217185605632, -71.7156399546202 61.5457269912077, -71.745408594431 61.6792414618241, -71.84647644023541 61.7009009129468, -72.0093717180302 61.7027090727656, -72.1138114630285 61.768727955231, -72.22976980123519 61.8808668843993, -72.3646309526563 61.8955630162203, -72.4438507145388 61.911258570027, -72.5975236614877 62.0116845813784, -72.65332864939759 62.1237777818192, -72.751459880469 62.1445197697716, -72.903374167184 62.1482523240856, -73.0173601185745 62.183594747, -73.0963776310228 62.2126581636434, -73.1944329188441 62.2876760141368, -73.28965616150251 62.3318380343978, -73.42240349692371 62.3685538308947, -73.56754929616309 62.4005830290836, -73.73324404207889 62.4774707715589, -73.8655810825009 62.4501908903973, -73.9502095218519 62.3978956398719, -74.1022008669764 62.3374917528422, -74.2265877898945 62.3260057582592, -74.29980367420011 62.2777694125284, -74.42241445316439 62.2427918022999, -74.511257930409 62.2428908122612, -74.62888748866651 62.2598035705784, -74.7267889348615 62.2046664902664, -74.8163182386957 62.2027195416736, -74.9442040738588 62.2578310929307, -75.03847038480041 62.2674159350974, -75.1831341600134 62.2847549100112, -75.3442277576048 62.3174456539938, -75.5153162981086 62.2713303206378, -75.6416712506276 62.2500114445726, -75.8110834269585 62.3090148398631, -75.93677284069391 62.3500193062461, -76.10534289276021 62.3775115497183, -76.2125175210667 62.3952569876199, -76.3685719204577 62.4278825055732, -76.48766814167131 62.4468325304969, -76.6064638391348 62.4572315361066, -76.7061760154107 62.4969147689015, -76.8642309126265 62.5259033871317, -76.9682144998992 62.5369445167761, -77.0828220366076 62.5335578426204, -77.25888406544721 62.5470384120931, -77.3441128508273 62.5540247837169, -77.47945886273619 62.5781576537528, -77.5586235987 62.541063735503, -77.6682454270847 62.5150911061697, -77.81984122339369 62.4436013059556, -77.9415896901121 62.405578487857, -78.0408993361354 62.3642756102313, -78.1703715205291 62.2442638953625, -78.1610545162529 62.1223761632295, -78.14890860634701 62.0181106241061, -78.07967792379711 61.8977229845282, -78.05323718115091 61.8092322177927, -77.99494302809821 61.7128768347981, -77.9110333772885 61.6805678431315, -77.7752377331347 61.6529479256063, -77.68604436295691 61.5902604530575, -77.7464299002197 61.4447707602625, -77.7713878361796 61.2809443639912, -81.1208442837367 61.6343186366958, -85.9087502533215 61.4403863269675, -87.7835499471722 60.796390048462, -88.8519416879585 60.1195386784673, -89.8256929935368 59.1331428536598, -90.28917688060849 58.6636404579409, -90.67532027770859 57.2245717427917, -90.79091050271749 57.2407170808287, -90.9217394124439 57.2601567677207, -91.01806055105349 57.2568265287214, -91.1159991221617 57.249242901139, -91.2779177991671 57.2192479316468, -91.4525318115937 57.1780529852571, -91.5799427372674 57.1525440913368, -91.7268544003103 57.1197453081995, -91.8391362308523 57.0876751359988, -91.9249059071818 57.0659466097483, -92.0507985856861 57.049360294542, -92.13512631242941 57.04835702076, -92.25875306989821 57.0716991447998, -92.3518469706611 57.0584964685373, -92.4861090971571 57.0399379517752, -92.4857200468426 57.1999797751466, -92.4425224316648 57.3074512552713, -92.4497627547472 57.3881817001254, -92.5112404799642 57.5276470395793, -92.59639221412939 57.6298542247927, -92.65817509550421 57.7008037788714, -92.7342173331634 57.8130054717252, -92.77113601131779 57.8940105722302, -92.8201015390547 58.0647373586422, -92.874468654005 58.1538677627871, -92.97732059736759 58.2803554957096, -93.0559415825379 58.4189625249007, -93.1315794841059 58.5865955877163, -93.1591292778938 58.7012920988514, -93.2823669526727 58.7624760209517, -93.3608810776995 58.7592754812785, -93.4738800798018 58.7538242685752, -93.62835249617071 58.7846698986969, -93.71609056722581 58.7966098944312, -93.89549583566421 58.7730426754791, -94.0091280782981 58.7725887156967, -94.14890625412031 58.7425517739453, -94.24527317181941 58.7465228653381, -94.4130130857852 58.709989490023, -94.496623682337 58.803209247309, -94.605174776095 58.8845767350284, -94.668979477321 58.9607562380101, -94.7854498526285 59.019945075305, -94.8760642082965 59.0353373705233, -95.0288505271301 59.0589655922883, -94.9498328680923 59.0871371413661, -94.78415853948491 59.1531909238221, -94.75664135421501 59.3040141602254, -94.7311897255254 59.4165820732042, -94.8055229949902 59.5517024667955, -94.8188439536855 59.6357478828585, -94.7946054061145 59.7556094972806, -94.82640478525261 59.8905277160813, -94.7793129086637 60.072941390333, -94.73645838124919 60.2213475638391, -94.6762507910411 60.3269215005269, -94.6734126925416 60.423391387003, -94.6149944348452 60.513830240873, -94.5353359405012 60.6169071910141, -94.4341091386257 60.7222386291095, -94.37695735929471 60.8089810418417, -94.2591747562099 60.8856145118004, -94.2088665424568 60.964075215299, -94.117840250527 61.0820447451689, -94.04385803502031 61.2004110028656, -93.9886975318655 61.2938901704951, -93.9522824524732 61.3760549440805, -93.9426923501717 61.491502950301, -93.804676572166 61.5421430732443, -93.69641544681529 61.598573904762, -93.5824475313284 61.6549169984208, -93.4946942149659 61.6810438713776, -93.4563641740674 61.8020346349905, -93.4010892366789 61.9084074808207, -93.32190375965079 61.9974730456446, -93.1770367754268 62.0318396699648, -93.113697555198 62.1166098847385, -93.0654263904156 62.1899207446467, -92.9374432540029 62.2031119824321, -92.7967037820538 62.2611297306526, -92.68520018074371 62.3574088907078, -92.6355176019556 62.4841178883299, -92.5609097442893 62.5284408665528, -92.3973812421505 62.5429100292745, -92.29000511624299 62.5757202526876, -92.19575159456041 62.695326287878, -92.0960278026409 62.834230877553, -92.00510827732511 62.8504166473105, -91.8950160639401 62.8354172685921, -91.723606384527 62.8273682724279, -91.6037180224687 62.8120141273502, -91.51237887258679 62.8096223192147, -91.3764153861611 62.8267961003598, -91.195743643854 62.8759637552232, -91.0767021706686 62.9177041853999, -90.945301069089 62.9480195986257, -90.8332252075772 62.9270273293478, -90.7121848562461 63.0189462910386, -90.6908760112189 63.1564279904595, -90.75826653966899 63.2864176159803, -90.83001343447241 63.3706194286438, -90.8963892209857 63.4225221952432, -91.04234724652819 63.4645029278679, -91.0056193874247 63.5928255403664, -90.84331157107211 63.5712992167855, -90.734394298558 63.5932146644253, -90.57693117953031 63.6349169525554, -90.4958383024956 63.6178995949904, -90.3111839970437 63.6364504873002, -90.1911506903521 63.6513583348194, -90.0785332049434 63.7674586633867, -90.09151085913879 63.8706767468345, -89.987567986873 63.956850772745, -89.8510933464807 64.0146358231847, -89.6954002542183 64.07326773821561, -89.6150550465531 64.034685895238, -89.476774932617 64.0453088761038, -89.3606832879034 64.02033502574091, -89.2708623726004 63.986059977586, -89.12059375799549 63.9970920969228, -89.00106399340849 64.0190990964462, -88.819049435583 63.9913967794379, -88.66757537690209 64.0033367967558, -88.5629534490424 64.0129498434605, -88.4285540041639 64.0731839294948, -88.3423570797154 64.0983151648131, -88.1679795916847 64.1600140962736, -88.03858503766931 64.235651929493, -87.8977998100131 64.3457898877932, -87.8045304874919 64.486819262499, -87.67589122909681 64.52863598846019, -87.5598252258534 64.5852384789727, -87.4955704786946 64.6759901377348, -87.403468411438 64.72561935974581, -87.30076911360371 64.7830381954564, -87.2086212942372 64.8866224981298, -87.13297583926349 64.9438811151214, -87.04295660816079 65.01542958800511, -86.9738190351204 65.0813780841314, -87.0019258024338 65.214266882011, -87.1682314416277 65.2549620607506, -87.2687563954912 65.2654753576017, -87.3695407435104 65.2699766928702, -87.5550724563287 65.2932921070451, -87.672191344455 65.29336076218949, -87.8180730562265 65.28059677162381, -87.98862825109281 65.2838468774315, -88.10628882606839 65.2803831223832, -88.21958538595671 65.2826414135705, -88.3569145495667 65.28509043657439, -88.481838319183 65.29619119576709, -88.5829431100365 65.3128995606663, -88.7499735227598 65.3185834441707, -88.821048993616 65.3223828774679, -88.9447825770542 65.3325909965773, -89.03952443690309 65.32480137568299, -89.12854429728149 65.4086865640338, -89.2718930900939 65.47440615841749, -89.3944288907806 65.5483960190611, -89.47274469730991 65.61487855869861, -89.5859955023904 65.65442933124871, -89.6893509905557 65.7181347698038, -89.8548555487445 65.76428496358029, -89.892712677548 65.8680752478745, -89.8472491674151 65.9957913234109, -89.7289553357201 65.9677914549118, -89.58537003200129 65.908060935264, -89.4675644692248 65.8565320132419, -89.33667450902141 65.8462018255539, -89.1824996027743 65.7857999206299, -89.0757032607967 65.7328366707758, -88.9438901303252 65.6937665516851, -88.7899365049656 65.6880445198388, -88.6762889810516 65.6670560636864, -88.57616072353849 65.5965070586539, -88.4880335311225 65.56534098929529, -88.361385490448 65.50024700199759, -88.2690468664197 65.46194744811631, -88.1663932793262 65.3914518484241, -88.07439798857619 65.3724699218495, -87.9584234895524 65.33616164144669, -87.8748434303799 65.3235044831454, -87.7509648942145 65.3238249295769, -87.6514622896529 65.3308592395623, -87.5082279661476 65.3211317739123, -87.4191700041923 65.3224364078141, -87.3157687765078 65.3291045084663, -87.1970172123744 65.36031637310219, -87.0824203887553 65.391353511131, -86.19775771305351 64.85291030109521, -86.2442882170275 64.7571059717632, -86.32390094037601 64.66191400482749, -86.3809077265102 64.4934798466177, -86.35802712735 64.413348313374, -86.3106332449282 64.2786666072782, -86.22036216947841 64.187564008772, -86.2779869616289 64.0708571495379, -86.3801827380429 64.05316457378611, -86.47285701873631 64.0198469978407, -86.6226068279427 63.9899779037573, -86.724581347751 63.9622259702524, -86.8859964979399 63.916262666389, -86.9900538332177 63.8612318328829, -87.10030622305371 63.7731084958605, -87.1830012486087 63.7357053790001, -87.173403404943 63.5933752024037, -87.0755182139943 63.5522069946571, -86.9497552186285 63.5508222707313, -86.8146919967382 63.5675344721382, -86.71865315352009 63.6085844397202, -86.59764329460231 63.6556501865069, -86.5092567233191 63.6640196407939, -86.3792594076954 63.6473265355912, -86.2353155541694 63.6404715360327, -86.1552068852894 63.6621123217263, -85.9680806546985 63.6859389384313, -85.79514510006619 63.7071448542517, -85.6993351253158 63.7117873507057, -85.6090106328344 63.5890723529068, -85.63833798161259 63.4528800204966, -85.645616358608 63.2824965547723, -85.6180055296314 63.1828566588078, -85.509271323113 63.1111022070013, -85.3826309500583 63.1142798589284, -85.2088561543879 63.1131240196579, -85.05288839028699 63.1557685364888, -84.9375547940184 63.1815177526422, -84.80197278111891 63.2255660770129, -84.7200406927237 63.2648765408198, -84.6114133391543 63.2991477911377, -84.46032077738199 63.3875457892069, -84.42369971007351 63.4929153675502, -84.3627942522529 63.5631820996742, -84.2592480835322 63.6143906076405, -84.1496136358606 63.6134407571852, -84.0352337022735 63.6136810911095, -83.9035960978815 63.6852906027792, -83.7422038462304 63.7682183252156, -83.6065913472128 63.8946145224424, -83.584580587624 64.0302842417244, -83.49345508968059 64.1090348641677, -83.3827448918632 64.1013444420924, -83.1991129159284 64.1116136224708, -83.07296084596631 64.1778520384409, -83.0066231907077 64.0764802712476, -82.94601520883479 63.9640840289548, -82.7939841901181 63.9521097051988, -82.63841313855541 63.9574464782724, -82.5287557986411 63.9509996477156, -82.4869618965743 63.7920373903133, -82.3810886897912 63.6545404410886, -82.26029243334899 63.6605257089943, -82.1756061226244 63.6781000274944, -82.01801326829749 63.651164459872, -81.94321464463999 63.6374239242748, -81.80551926450239 63.6250948323607, -81.6371918333364 63.5614771325637, -81.5207443331844 63.5585512674271, -81.435592609811 63.5258631305791, -81.31211079517701 63.5023188263528, -81.1656187099354 63.4575228434045, -81.0769574713101 63.445498922937, -80.9414593750501 63.48022030912, -80.8146130266698 63.550197129494, -80.6725231372329 63.6020388779919, -80.5647197569111 63.6408458032913, -80.4219737436933 63.7144236988946, -80.4587932625989 63.8407779229629, -80.55911225372751 63.9453616638098, -80.6660459140877 63.9920268507587, -80.71445474596069 64.033819580696, -80.3046263074668 64.09006107806491, -79.0904559802441 64.2550682373605, -79.09042986435421 64.2550718099133, -77.9650089573083 64.4100325023033, -77.8272233003151 64.3721120512303, -77.6572174185489 64.3663442384959, -77.559309350646 64.3563802538457, -77.4368040945332 64.3257787581832, -77.2720472210024 64.2663305222359, -77.1466580675157 64.2855947513967, -76.9916744612073 64.2493932816747, -76.87635611024621 64.24878293698301, -76.70648755675521 64.2424047714631, -76.6052073099693 64.2889974937394, -76.4764535822669 64.27468475549711, -76.354238259488 64.2964437966439, -76.2682702053057 64.317554338462, -76.14462056818461 64.3744238565758, -76.0178810062034 64.3816412703284, -75.91278605023589 64.3963583797355, -75.7954459270877 64.4687918628542, -75.6769690338937 64.5719794368016, -75.50846613600331 64.54076759105151, -75.4066975852252 64.5199240885259, -75.26134990617309 64.47008125864321, -75.0765277296709 64.4542960505224, -74.94823938673829 64.4170035736561, -74.7806367614773 64.40159220471649, -74.6101197140535 64.4119147850394, -74.5589798963051 64.5428886124196, -74.4577606865064 64.6090049553145, -74.3456237853093 64.5845451205609, -74.213337660005 64.6295814464267, -74.0764433536777 64.5839271541149, -73.95660072664219 64.4317054692321, -73.8716550343523 64.5373344480264, -73.72642944636181 64.5669365082134, -73.6222652536385 64.4982948456307, -73.51404985072 64.42818834031971, -73.4140741991649 64.3656654517992, -73.2567178440532 64.2992439464511, -73.17885220036879 64.27727129293589, -73.0262184425271 64.2150154365133, -72.9183387403406 64.1730079913258, -72.89667121780241 64.0405388054216, -72.7271002005138 63.988319419006, -72.60951589254429 63.8962059231649, -72.4569584295878 63.8165321574332, -72.3577304779791 63.8243980678166, -72.210933226687 63.8205108975599, -72.1250872168016 63.7320747691354, -71.9750016879774 63.6924095506603, -71.8269303419616 63.7619553070918, -71.67220613160769 63.6913147447797, -71.51773368466171 63.5926056372404, -71.57384024313259 63.4262543043927, -71.6588241080461 63.417434720536, -71.7607070705748 63.3189354095415, -71.6622038781064 63.1676788411057, -71.558505089938 63.1224060151256, -71.4669980851935 63.0994415406946, -71.3256787294896 63.0382804991458, -71.1630733697401 63.0500068870083, -70.82220713335251 63.1167564776294, -70.92711897566021 63.0537643732273, -70.8385797831304 62.9195671310183, -70.7098413133258 62.8894119518002, -70.5622811212766 62.8754272763478, -70.4596046797122 62.8648834565064, -70.33521496080169 62.7985802021147, -70.171114228139 62.7537231812798, -70.0178777689438 62.7597580369039, -69.83246051104371 62.7897911583353, -69.6793842642724 62.7753449040441, -69.52267640938869 62.6744728622328, -69.41952693072319 62.583488513784, -69.27991656569679 62.5175133248801, -69.15217753766311 62.4323425763489, -69.08314674022979 62.4139709953652, -68.9529586846955 62.3789711493991, -68.7664275265091 62.3391762306986, -68.6182493455308 62.2785416181013, -68.50950753254649 62.2540474481313, -68.38235598124341 62.2433777438878, -68.3025677345132 62.2349472643049, -68.15387839597111 62.2275353119052, -68.04071152911369 62.2018738444024, -67.9512263199386 62.2076073381082, -67.7808847464339 62.1904335740502, -67.667031235503 62.1683731808777, -67.5475243460717 62.1769142932601, -67.4579933542098 62.1444474058232, -67.32158734378081 62.1284294945256, -67.2217414050418 62.0822869144096, -67.0966879360993 62.047626576905, -67.00144470690761 62.0415908840121, -66.8809755518802 62.0379386886197, -66.7458287362071 62.010521850603, -66.56848938137981 61.9408073255976, -66.38661301427911 61.8848849311947, -66.2605215757101 61.8666706344423, -66.1703828831634 61.8680953889911, -66.05410316772689 61.8776442043167, -66.00581322420081 61.9763169972317, -66.0284912942377 62.1202253086511, -66.0977332048235 62.22617411964, -66.15206509962459 62.3074199749519, -66.2784021682254 62.3385812068573, -66.39642556209 62.3532548951973, -66.49938548075529 62.4683787713633, -66.6196345500943 62.606103143845, -66.72430870248451 62.6434864261577, -66.8661701200549 62.6626958686195, -66.9795012193058 62.7005728337693, -67.11189343043741 62.8094941613265, -67.2228401454563 62.860798026208, -67.2971047148107 62.9185220279693, -67.40728086282149 62.9699250745826, -67.4872827372085 63.0039674330507, -67.6298914518289 63.0330010920268, -67.7365657036442 63.0789834534237, -67.8876354280325 63.1482202090954, -67.9837276999733 63.1604730142183, -68.1048443992495 63.1794435023158, -68.1727079036468 63.2291223048505, -68.2685407877272 63.3055345101096, -68.3723692770204 63.3671151690299, -68.49981075536201 63.4394761622952, -68.6105057015768 63.4779244946198, -68.7273270597959 63.5467111180237, -68.7948930207962 63.6070787039191, -68.6855256420946 63.7386590718588, -68.49940644894841 63.7373620803958, -68.35683587007929 63.6653329657439, -68.1920713792907 63.6187211814374, -68.06613289831461 63.5909959640925, -67.992333722723 63.5498315649748, -67.8937161140074 63.5086557228833, -67.7660381436453 63.558918182728, -67.5598460266726 63.5650407771102, -67.4963312776663 63.502723880103, -67.3908853549751 63.4287416394152, -67.27697079896311 63.3634721665073, -67.18624961642659 63.3173906233786, -67.0267875607972 63.2847291874022, -66.93208383220301 63.2137033357404, -66.85270756310349 63.1551935072746, -66.7301641604476 63.0855638369016, -66.5590520172367 63.0848581227043, -66.5560689390303 63.2054750444379, -66.64127406774401 63.2679483443407))"
p = shapely.geometry.Polygon(wkt.loads(mywkt))
print(p.is_valid)
shape_feature = ShapelyFeature([p], ccrs.Geodetic(), edgecolor='black', facecolor="red")
ax.add_feature(shape_feature)
plt.show()
The polygon does not have ccw sequence. To get it right, you need to reverse the sequence. Here is the relevant code that does the trick for you.
# Your code is OK up to this line:
p = shapely.geometry.Polygon(wkt.loads(mywkt))
# Add these lines to reverse vertices sequence
px = p.exterior
if px.is_ccw==False:
px.coords = list(px.coords)[::-1]
# Continue your remaining code.
Hope this is useful.

Plot two graphs on top of each other

I'm using matplotlib and I wish to plot a contourf on top of a pcolormesh, displaying both at the same time as described. Here is the code:
"""space for module inclusion"""
fig, ax = plt.subplots()
ax.pcolormesh(*arguments here*)
ax.contour(*arguments here*)
plt.show()
However, when I try to display the data, only contourf is shown (overrides pcolormesh). Any Ideas on this one?
EDIT_1:
So basically the values I'm using are the following:
X:
[ 63.37480164 63.37519836 63.37559891 63.37599945 63.37639999
63.37680054 63.37720108 63.37760162 63.37799835 63.3783989
63.37879944 63.37919998 63.37960052 63.38000107 63.38040161
63.38079834 63.38119888 63.38159943 63.38199997 63.38240051
63.38280106 63.3832016 63.38359833 63.38399887 63.38439941
63.38479996 63.3852005 63.38560104 63.38600159 63.38639832
63.38679886 63.3871994 63.38759995 63.38800049 63.38840103
63.38880157 63.3891983 63.38959885 63.38999939 63.39039993
63.39080048 63.39120102 63.39160156 63.39199829 63.39239883
63.39279938 63.39319992 63.39360046 63.39400101 63.39440155
63.39479828 63.39519882 63.39559937 63.39599991 63.39640045
63.39680099 63.39720154 63.39759827 63.39799881 63.39839935
63.3987999 63.39920044 63.39960098 63.40000153 63.40039825
63.4007988 63.40119934 63.40159988 63.40200043 63.40240097
63.40280151 63.40319824 63.40359879 63.40399933 63.40439987
63.40480042 63.40520096 63.4056015 63.40599823 63.40639877
63.40679932 63.40719986 63.4076004 63.40800095 63.40840149
63.40879822 63.40919876 63.4095993 63.40999985 63.41040039
63.41080093 63.41120148 63.41159821 63.41199875 63.41239929
63.41279984 63.41320038 63.41360092 63.41400146 63.41439819
63.41479874 63.41519928 63.41559982 63.41600037 63.41640091
63.41680145 63.41719818 63.41759872 63.41799927 63.41839981
63.41880035 63.4192009 63.41960144 63.41999817 63.42039871
63.42079926 63.4211998 63.42160034 63.42200089 63.42240143
63.42279816 63.4231987 63.42359924 63.42399979 63.42440033
63.42480087 63.42520142 63.42559814 63.42599869 63.42639923
63.42679977 63.42720032 63.42760086 63.4280014 63.42839813
63.42879868 63.42919922 63.42959976 63.43000031 63.43040085
63.43080139 63.43119812 63.43159866 63.43199921 63.43239975
63.43280029 63.43320084 63.43360138 63.43399811 63.43439865
63.43479919 63.43519974 63.43560028 63.43600082 63.43640137
63.4367981 63.43719864 63.43759918 63.43799973 63.43840027
63.43880081 63.43920135 63.4396019 63.43999863 63.44039917
63.44079971 63.44120026 63.4416008 63.44200134 63.44240189
63.44279861 63.44319916 63.4435997 63.44400024 63.44440079
63.44480133 63.44520187 63.4455986 63.44599915 63.44639969
63.44680023 63.44720078 63.44760132 63.44800186 63.44839859
63.44879913 63.44919968 63.44960022 63.45000076 63.45040131
63.45080185 63.45119858 63.45159912 63.45199966 63.45240021
63.45280075 63.45320129 63.45360184 63.45399857 63.45439911
63.45479965 63.4552002 63.45560074 63.45600128 63.45640182
63.45679855 63.4571991 63.45759964 63.45800018 63.45840073
63.45880127 63.45920181 63.45959854 63.45999908 63.46039963
63.46080017 63.46120071 63.46160126 63.4620018 63.46239853
63.46279907 63.46319962 63.46360016 63.4640007 63.46440125
63.46480179 63.46519852 63.46559906 63.4659996 63.46640015
63.46680069 63.46720123 63.46760178 63.4679985 63.46839905
63.46879959 63.46920013 63.46960068 63.47000122 63.47040176
63.47079849 63.47119904 63.47159958 63.47200012 63.47240067
63.47280121 63.47320175 63.47359848 63.47399902 63.47439957
63.47480011 63.47520065 63.4756012 63.47600174 63.47639847
63.47679901 63.47719955 63.4776001 63.47800064 63.47840118
63.47880173 63.47919846 63.479599 63.47999954 63.48040009
63.48080063 63.48120117 63.48160172 63.48199844 63.48239899
63.48279953 63.48320007 63.48360062 63.48400116 63.4844017
63.48479843 63.48519897 63.48559952 63.48600006 63.4864006
63.48680115 63.48720169 63.48759842 63.48799896 63.48839951
63.48880005 63.48920059 63.48960114 63.49000168 63.49039841
63.49079895 63.49119949 63.49160004 63.49200058 63.49240112
63.49280167 63.49319839 63.49359894 63.49399948 63.49440002
63.49480057 63.49520111 63.49560165 63.49599838 63.49639893
63.49679947 63.49720001 63.49760056 63.4980011 63.49840164
63.49879837 63.49919891 63.49959946 63.5 63.50040054
63.50080109 63.50120163 63.50159836 63.5019989 63.50239944
63.50279999 63.50320053 63.50360107 63.50400162 63.50439835
63.50479889 63.50519943 63.50559998 63.50600052 63.50640106
63.50680161 63.50719833 63.50759888 63.50799942 63.50839996
63.50880051 63.50920105 63.50960159 63.50999832 63.51039886
63.51079941 63.51119995 63.51160049 63.51200104 63.51240158
63.51279831 63.51319885 63.5135994 63.51399994 63.51440048
63.51480103 63.51520157 63.5155983 63.51599884 63.51639938
63.51679993 63.51720047 63.51760101 63.51800156 63.51839828
63.51879883 63.51919937 63.51959991 63.52000046 63.520401
63.52080154 63.52119827 63.52159882 63.52199936 63.5223999
63.52280045 63.52320099 63.52360153 63.52399826 63.5243988
63.52479935 63.52519989 63.52560043 63.52600098 63.52640152
63.52679825 63.52719879 63.52759933 63.52799988 63.52840042
63.52880096 63.52920151 63.52959824 63.52999878 63.53039932
63.53079987 63.53120041 63.53160095 63.5320015 63.53239822
63.53279877 63.53319931 63.53359985 63.5340004 63.53440094
63.53480148 63.53519821 63.53559875 63.5359993 63.53639984
63.53680038 63.53720093 63.53760147 63.5379982 63.53839874
63.53879929 63.53919983 63.53960037 63.54000092 63.54040146
63.54079819 63.54119873 63.54159927 63.54199982 63.54240036
63.5428009 63.54320145 63.54359818 63.54399872 63.54439926
63.5447998 63.54520035 63.54560089 63.54600143 63.54639816
63.54679871 63.54719925 63.54759979 63.54800034 63.54840088
63.54880142 63.54919815 63.54959869 63.54999924 63.55039978
63.55080032 63.55120087 63.55160141 63.55199814 63.55239868
63.55279922 63.55319977 63.55360031 63.55400085 63.5544014
63.55479813 63.55519867 63.55559921 63.55599976 63.5564003
63.55680084 63.55720139 63.55759811 63.55799866 63.5583992
63.55879974 63.55920029 63.55960083 63.56000137 63.5603981
63.56079865 63.56119919 63.56159973 63.56200027 63.56240082
63.56280136 63.5632019 63.56359863 63.56399918 63.56439972
63.56480026 63.56520081 63.56560135 63.56600189 63.56639862
63.56679916 63.56719971 63.56760025 63.56800079 63.56840134
63.56880188 63.56919861 63.56959915 63.56999969 63.57040024
63.57080078 63.57120132 63.57160187 63.5719986 63.57239914
63.57279968 63.57320023 63.57360077 63.57400131 63.57440186
63.57479858 63.57519913 63.57559967 63.57600021 63.57640076
63.5768013 63.57720184 63.57759857 63.57799911 63.57839966
63.5788002 63.57920074 63.57960129 63.58000183 63.58039856
63.5807991 63.58119965 63.58160019 63.58200073 63.58240128
63.58280182 63.58319855 63.58359909 63.58399963 63.58440018
63.58480072 63.58520126 63.58560181 63.58599854 63.58639908
63.58679962 63.58720016 63.58760071 63.58800125 63.58840179
63.58879852 63.58919907 63.58959961 63.59000015 63.5904007
63.59080124 63.59120178 63.59159851 63.59199905 63.5923996
63.59280014 63.59320068 63.59360123 63.59400177 63.5943985
63.59479904 63.59519958 63.59560013 63.59600067 63.59640121
63.59680176 63.59719849 63.59759903 63.59799957 63.59840012
63.59880066 63.5992012 63.59960175 63.59999847 63.60039902
63.60079956 63.6012001 63.60160065 63.60200119 63.60240173
63.60279846 63.60319901 63.60359955 63.60400009 63.60440063
63.60480118 63.60520172 63.60559845 63.60599899 63.60639954
63.60680008 63.60720062 63.60760117 63.60800171 63.60839844
63.60879898 63.60919952 63.60960007 63.61000061 63.61040115
63.6108017 63.61119843 63.61159897 63.61199951 63.61240005
63.6128006 63.61320114 63.61360168 63.61399841 63.61439896
63.6147995 63.61520004 63.61560059 63.61600113 63.61640167
63.6167984 63.61719894 63.61759949 63.61800003 63.61840057
63.61880112 63.61920166 63.61959839 63.61999893 63.62039948
63.62080002 63.62120056 63.6216011 63.62200165 63.62239838
63.62279892 63.62319946 63.62360001 63.62400055 63.62440109
63.62480164 63.62519836 63.62559891 63.62599945 63.62639999
63.62680054 63.62720108 63.62760162 63.62799835 63.6283989
63.62879944 63.62919998 63.62960052 63.63000107 63.63040161
63.63079834 63.63119888 63.63159943 63.63199997 63.63240051
63.63280106 63.6332016 63.63359833 63.63399887 63.63439941
63.63479996 63.6352005 63.63560104 63.63600159 63.63639832
63.63679886 63.6371994 63.63759995 63.63800049 63.63840103
63.63880157 63.6391983 63.63959885 63.63999939 63.64039993
63.64080048 63.64120102 63.64160156 63.64199829 63.64239883
63.64279938 63.64319992 63.64360046 63.64400101 63.64440155
63.64479828 63.64519882 63.64559937 63.64599991 63.64640045
63.64680099 63.64720154 63.64759827 63.64799881 63.64839935
63.6487999 63.64920044 63.64960098 63.65000153 63.65039825
63.6507988 63.65119934 63.65159988 63.65200043 63.65240097
63.65280151 63.65319824 63.65359879 63.65399933 63.65439987
63.65480042 63.65520096 63.6556015 63.65599823 63.65639877
63.65679932 63.65719986 63.6576004 63.65800095 63.65840149
63.65879822 63.65919876 63.6595993 63.65999985 63.66040039
63.66080093 63.66120148 63.66159821 63.66199875 63.66239929
63.66279984]
Y:
[[ 2.49405336 2.49405479 2.49405622 ..., 2.49506283 2.49506426
2.49506545]
[ 2.50891113 2.50891256 2.50891399 ..., 2.50994205 2.50994349
2.50994492]
[ 2.52241206 2.52241349 2.52241492 ..., 2.52346492 2.52346635
2.52346778]
...,
[ 3.86142349 3.8614254 3.86142731 ..., 3.86282992 3.86283183
3.86283374]
[ 3.87396121 3.87396312 3.87396502 ..., 3.87538362 3.87538576
3.87538767]
[ 3.88761282 3.88761473 3.88761663 ..., 3.8890295 3.88903141
3.88903356]]
Z:
[[ 1.17835083e+03 1.18324207e+03 1.19204639e+03 ..., -5.34249163e+00
5.41835642e+00 3.46183872e+00]
[ 1.25111658e+03 1.24381042e+03 1.25598743e+03 ..., 1.37508184e-01
2.57289410e+00 -3.10967302e+00]
[ 1.31315002e+03 1.30969629e+03 1.30394031e+03 ..., 3.06716180e+00
7.64734685e-01 -9.59618759e+00]
...,
[ 3.51441078e+01 3.44107513e+01 3.44107513e+01 ..., -5.19034863e+00
-1.89025664e+00 -4.45699453e+00]
[ 2.77138577e+01 2.72105122e+01 2.67071648e+01 ..., -1.48025024e+00
5.33136606e-01 -9.76903498e-01]
[ 2.52477798e+01 2.67249184e+01 2.82020588e+01 ..., 1.36409312e-01
-2.32875556e-01 -2.07929993e+00]]
and the code is the following:
fig,ax = plt.subplots()
ax.pcolormesh(x,y,z, cmap='gist_rainbow', linewidth=0, zorder=1)
#plt.set_xlabel('Time [s]')
#plt.set_ylabel('R [m]; ECE')
#plt.view_init(90,-90)
#plt.set_axis_off()
ax.contour(z,zorder=2)
plt.show()
which outputs: http://www.image-upload.net/di/4T7EQ1AJ/Capture.png
another code:
fig,ax = plt.subplots()
#ax.pcolormesh(x,y,z, cmap='gist_rainbow', linewidth=0, zorder=1)
#plt.set_xlabel('Time [s]')
#plt.set_ylabel('R [m]; ECE')
#plt.view_init(90,-90)
#plt.set_axis_off()
print x
print "\n\n"
print y
print "\n\n"
print z
ax.contour(z,zorder=2)
plt.show()
which outputs: http://www.image-upload.net/di/4T7EQ1AJ/Capture.png
and finally, this code
fig,ax = plt.subplots()
ax.pcolormesh(x,y,z, cmap='gist_rainbow', linewidth=0, zorder=1)
#plt.set_xlabel('Time [s]')
#plt.set_ylabel('R [m]; ECE')
#plt.view_init(90,-90)
#plt.set_axis_off()
print x
print "\n\n"
print y
print "\n\n"
print z
#ax.contour(z,zorder=2)
plt.show()
which outputs: http://www.image-upload.net/di/JEKL/Capture.png
What I want is this contour http://www.image-upload.net/di/4T7EQ1AJ/Capture.png on top of http://www.image-upload.net/di/JEKL/Capture.png without the messy white background! :)
Contourf is a filled contour. So it is covering up everything underneath it. There are two options then:
1) You could try setting an alpha in contourf... i.e. alpha=0.25. This will make the filled contour partially see through.
2) Better option: use contour instead of contourf, which will then just plot contour lines.
You just need to use zorder which controls what order artists are rendered (which elements with high zorder 'above' elements with lower zorder)
fig, ax = plt.subplots()
ax.pcolormesh(..., zorder=1)
ax.contour(..., zorder=2)
plt.show()

Categories

Resources