I am trying to plot a tricontourf on a polar plot, however it seems that it glitches out when plotting over the 0 longitude point.
It’s clear when plotting as a scatter plot that the points are just fine.
Furthermore, when plotting the tricontourf in other locations not containing 0 longitude it works just fine.
Here is the code for the tricontourf and scatter plot respectively:
axes.tricontourf(prediction['Longitude'], prediction['Latitude'], prediction['Measurement'], levels = np.linspace(0, 2, 50), cmap='viridis', zorder=10) axes.scatter(prediction['Longitude'], prediction['Latitude'], c=prediction['Measurement'], cmap='viridis', zorder=10, norm = plt.Normalize(0, 2),s=10)
In addition, here are the data points centred on 0 lon, 62 lat and these are the ones centred on -90 lon, 62 lat.
Does anyone know why this is happening?
Advertisement
Answer
To anyone wondering: the solution is to convert the longitudes from 0-360 to -180-180. I achieved this by the following two lines of code:
prediction['Longitude'] = (prediction['Longitude'] + 180) % 360 - 180 prediction = prediction.sort_values('Longitude')