Hello everybody!
There is a need to build a gradient graph to display the results of calculating the accuracy of geodetic latitude.
My program cyclically calculates the accuracy of calculating the latitude for a given height (in the altitude range from -1 km to 10 km with a step of 1 km for all latitudes about -90 to +90 with a step of 0.16 degrees, the accuracy is magically calculated)
As a result, I get a list that contains 1125 numbers - the accuracy of calculating each i-th latitude at a specific height .
As a result, I have 11 such lists. (at each of the heights)
There is a need to display it on gradient graphics, it can be done with matplotlib, but I do not understand how. I read the documentation and looked at the examples of the script on the website of this library, but I do not understand how it works.
It should be like on the screen, only along the Y axis - heights from -1 km to 10 km, along the X axis - latitudes from -90 to +90, and along the Z axis (the bar to the right) - just accuracy.
Here is a clipping from the script for pcolormesh from their off site:
import numpy as np dx, dy = 0.05, 0.05 y, x = np.mgrid[slice(1, 5 + dy, dy), slice(1, 5 + dx, dx)] z = np.sin(x)**10 + np.cos(10 + y*x) * np.cos(x) But I just can not understand what is happening with these variables - x, y, z. At the same time, I basically understand what mgrid does, but what is happening inside it in this piece of code is not. (already dealt with this)
Accordingly, without understanding how this example works, I cannot figure out how to solve my problem.
PS If it turned out to be very messy, incomprehensible or something else - do not throw slippers, please) I am still a student and am just learning, and I recently met the python in general, but I have to solve such questions
PS2 Having a little rummaged, (thanks to the first answer under this question) I more or less understood that yes how. Even it turned out to build a graph.
However, it does not look like a gradient, as if it is turned vertically. The obtained numerical values are generally correct, and I should get a graph like this:
that is, the problem seems to be in drawing this graph itself, because my numerical values and the standard are very similar (just look at the order of numbers along the Z axis to be sure). But I do not understand why my so goes. Here is the code snippet:
y, x = np.mgrid[-1000:10000:1000, -0.16:89.84:0.16] z = np.array(lst_b) levels = MaxNLocator(nbins=200).tick_values(z.min(), z.max()) cmap = plt.get_cmap('PiYG') norm = BoundaryNorm(levels, ncolors=cmap.N, clip=True) fig, ax0 = plt.subplots() im = ax0.contourf(x, y, z, cmap=cmap, norm=norm) fig.colorbar(im, ax=ax0) fig.tight_layout() plt.show() approx. lst_b is a list of 11 lists, each of which contains the numbers I need.
