savefig ( 'plot_matplotlib_contour_lines_rect. set_label ( 'K' ) #- save graphic output to PNG file plt. colorbar ( cnplot, pad = 0.07, shrink = 0.3 ) cbar. PlateCarree ()) #- add colorbar cbar = plt. tsurf, linewidths = 1.5, cmap = 'jet', levels = 15, transform = ccrs. set_title ( 'Temperature', fontsize = 10, fontweight = 'bold' ) #- create contour line plot cnplot = ax. gridlines ( draw_labels = True, linewidth = 0.5, color = 'gray', xlocs = range ( - 180, 180, 30 ), ylocs = range ( - 90, 90, 30 )) #- add title ax. BORDERS, linewidth = 0.6, edgecolor = 'dimgray' ) ax. PlateCarree ()) #- add coastlines, country border lines, and grid lines ax. figure ( figsize = ( 12, 12 )) #- choose map projection ax = plt. open_dataset ( 'rectilinear_grid_2D.nc' ) #- create figure and axes object fig = plt. Plt.imshow(zi, vmin=z.min(), vmax=z.""" DKRZ matplotlib script: matplotlib_contour_lines.py - contour lines over map plot - rectilinear grid (lat/lon) - colorbar 08.02.21 meier-fleischer(at) """ import cartopy import cartopy.crs as ccrs import cartopy.feature as cfeature import matplotlib.pyplot as plt import numpy as np import xarray as xr def main (): #- open netcdf file ds = xr. # Set up a regular grid of interpolation points If you have millions of points, this implementation will be inefficient, but as a starting point: import numpy as np a "thin-plate-spline" is a particular type of radial basis function) is often a good choice. There's no one way to do this, and the "best" method depends entirely on the a-priori information you should be incorporating into the interpolation.īefore I go into a rant on "black-box" interpolation methods, though, a radial basis function (e.g. In contour plot, a 2d contour plot presents contour lines of a 2D numerical array z, i.e. Xs, ys = np.linspace(-4, 4), np.linspace(-4, 4) A contour plot has a function of two variables of curves along which the function has constant values so that these curves join the points with equal values.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |