本文整理汇总了Python中matplotlib.image.NonUniformImage.set_interpolation方法的典型用法代码示例。如果您正苦于以下问题:Python NonUniformImage.set_interpolation方法的具体用法?Python NonUniformImage.set_interpolation怎么用?Python NonUniformImage.set_interpolation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.image.NonUniformImage
的用法示例。
在下文中一共展示了NonUniformImage.set_interpolation方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: single_plot
# 需要导入模块: from matplotlib.image import NonUniformImage [as 别名]
# 或者: from matplotlib.image.NonUniformImage import set_interpolation [as 别名]
def single_plot(data, x, y, axes=None, beta=None, cbar_label='',
cmap=plt.get_cmap('RdBu'), vmin=None, vmax=None,
phase_speeds=True, manual_locations=False, **kwargs):
"""
Plot a single frame Time-Distance Diagram on physical axes.
This function uses mpl NonUniformImage to plot a image using x and y arrays,
it will also optionally over plot in contours beta lines.
Parameters
----------
data: np.ndarray
The 2D image to plot
x: np.ndarray
The x coordinates
y: np.ndarray
The y coordinates
axes: matplotlib axes instance [*optional*]
The axes to plot the data on, if None, use plt.gca().
beta: np.ndarray [*optional*]
The array to contour over the top, default to none.
cbar_label: string [*optional*]
The title label for the colour bar, default to none.
cmap: A matplotlib colour map instance [*optional*]
The colourmap to use, default to 'RdBu'
vmin: float [*optional*]
The min scaling for the image, default to the image limits.
vmax: float [*optional*]
The max scaling for the image, default to the image limits.
phase_speeds : bool
Add phase speed lines to the plot
manual_locations : bool
Array for clabel locations.
Returns
-------
None
"""
if axes is None:
axes = plt.gca()
x = x[:xxlim]
data = data[:,:xxlim]
im = NonUniformImage(axes,interpolation='nearest',
extent=[x.min(),x.max(),y.min(),y.max()],rasterized=False)
im.set_cmap(cmap)
if vmin is None and vmax is None:
lim = np.max([np.nanmax(data),
np.abs(np.nanmin(data))])
im.set_clim(vmax=lim,vmin=-lim)
else:
im.set_clim(vmax=vmax,vmin=vmin)
im.set_data(x,y,data)
im.set_interpolation('nearest')
axes.images.append(im)
axes.set_xlim(x.min(),x.max())
axes.set_ylim(y.min(),y.max())
cax0 = make_axes_locatable(axes).append_axes("right", size="5%", pad=0.05)
cbar0 = plt.colorbar(im, cax=cax0, ticks=mpl.ticker.MaxNLocator(7))
cbar0.set_label(cbar_label)
cbar0.solids.set_edgecolor("face")
kwergs = {'levels': [1., 1/3., 1/5., 1/10., 1/20.]}
kwergs.update(kwargs)
if beta is not None:
ct = axes.contour(x,y,beta[:,:xxlim],colors=['k'], **kwergs)
plt.clabel(ct,fontsize=14,inline_spacing=3, manual=manual_locations,
fmt=mpl.ticker.FuncFormatter(betaswap))
axes.set_xlabel("Time [s]")
axes.set_ylabel("Height [Mm]")