本文整理汇总了Python中matplotlib.image.NonUniformImage.set_clim方法的典型用法代码示例。如果您正苦于以下问题:Python NonUniformImage.set_clim方法的具体用法?Python NonUniformImage.set_clim怎么用?Python NonUniformImage.set_clim使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.image.NonUniformImage
的用法示例。
在下文中一共展示了NonUniformImage.set_clim方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: execute
# 需要导入模块: from matplotlib.image import NonUniformImage [as 别名]
# 或者: from matplotlib.image.NonUniformImage import set_clim [as 别名]
def execute(self):
pylab.ioff()
self.figure = pylab.figure()
self.figure.canvas.mpl_connect('motion_notify_event', self.dataPrinter)
x = self.fieldContainer.dimensions[-1].data
y = self.fieldContainer.dimensions[-2].data
xmin=scipy.amin(x)
xmax=scipy.amax(x)
ymin=scipy.amin(y)
ymax=scipy.amax(y)
#Support for images with non uniform axes adapted
#from python-matplotlib-doc/examples/pcolor_nonuniform.py
ax = self.figure.add_subplot(111)
vmin = self.fieldContainer.attributes.get('vmin', None)
vmax = self.fieldContainer.attributes.get('vmax', None)
if vmin is not None:
vmin /= self.fieldContainer.unit
if vmax is not None:
vmax /= self.fieldContainer.unit
if MPL_LT_0_98_1 or self.fieldContainer.isLinearlyDiscretised():
pylab.imshow(self.fieldContainer.maskedData,
aspect='auto',
interpolation='nearest',
vmin=vmin,
vmax=vmax,
origin='lower',
extent=(xmin, xmax, ymin, ymax))
pylab.colorbar(format=F(self.fieldContainer), ax=ax)
else:
im = NonUniformImage(ax, extent=(xmin,xmax,ymin,ymax))
if vmin is not None or vmax is not None:
im.set_clim(vmin, vmax)
im.set_data(x, y, self.fieldContainer.maskedData)
else:
im.set_data(x, y, self.fieldContainer.maskedData)
im.autoscale_None()
ax.images.append(im)
ax.set_xlim(xmin,xmax)
ax.set_ylim(ymin,ymax)
pylab.colorbar(im,format=F(self.fieldContainer), ax=ax)
pylab.xlabel(self.fieldContainer.dimensions[-1].shortlabel)
pylab.ylabel(self.fieldContainer.dimensions[-2].shortlabel)
pylab.title(self.fieldContainer.label)
#ax=pylab.gca()
if self.show:
pylab.ion()
pylab.show()
示例2: plot_time_frequency
# 需要导入模块: from matplotlib.image import NonUniformImage [as 别名]
# 或者: from matplotlib.image.NonUniformImage import set_clim [as 别名]
def plot_time_frequency(spectrum, interpolation='bilinear',
background_color=None, clim=None, dbscale=True, **kwargs):
"""
Time-frequency plot. Modeled after image_nonuniform.py example
spectrum is a dataframe with frequencies in columns and time in rows
"""
if spectrum is None:
return None
times = spectrum.index
freqs = spectrum.columns
if dbscale:
z = 10 * np.log10(spectrum.T)
else:
z = spectrum.T
ax = plt.figure().add_subplot(111)
extent = (times[0], times[-1], freqs[0], freqs[-1])
im = NonUniformImage(ax, interpolation=interpolation, extent=extent)
if background_color:
im.get_cmap().set_bad(kwargs['background_color'])
else:
z[np.isnan(z)] = 0.0 # replace missing values with 0 color
if clim:
im.set_clim(clim)
if 'cmap' in kwargs:
im.set_cmap(kwargs['cmap'])
im.set_data(times, freqs, z)
ax.set_xlim(extent[0], extent[1])
ax.set_ylim(extent[2], extent[3])
ax.images.append(im)
if 'colorbar_label' in kwargs:
plt.colorbar(im, label=kwargs['colorbar_label'])
else:
plt.colorbar(im, label='Power (dB/Hz)')
plt.xlabel('Time (s)')
plt.ylabel('Frequency (Hz)')
return plt.gcf()
示例3: str
# 需要导入模块: from matplotlib.image import NonUniformImage [as 别名]
# 或者: from matplotlib.image.NonUniformImage import set_clim [as 别名]
scatf5 = 5.0*scatf1
# print max scatter values and their times
print 'max scatter f1 = ' + str(max(scatf1)) + ' Hz'
tofmax = times[argmax(scatf2)]
tofmaxgps = tofmax + start_time
print 'time of max f2 = ' + str(tofmax) + ' s, GPS=' + str(tofmaxgps)
fig = plt.figure(figsize=(12,12))
ax1 = fig.add_subplot(211)
# Plot Spectrogram
if plotspec==1:
im1 = NonUniformImage(ax1, interpolation='bilinear',extent=(min(t),max(t),10,55),cmap='jet')
im1.set_data(t,freq,20.0*log10(Pxx))
if witness_base=="GDS-CALIB_STRAIN":
print "setting color limits for STRAIN"
im1.set_clim(-1000,-800)
elif witness_base=="ASC-AS_B_RF45_Q_YAW_OUT_DQ" or witness_base=="ASC-AS_B_RF36_Q_PIT_OUT_DQ" or witness_base=="ASC-AS_A_RF45_Q_PIT_OUT_DQ" or witness_base=="LSC-MICH_IN1_DQ":
im1.set_clim(-200,20)
elif witness_base == "OMC-LSC_SERVO_OUT_DQ":
im1.set_clim(-240,-85)
ax1.images.append(im1)
#cbar1 = fig.colorbar(im1)
#cbar1.set_clim(-120,-40)
# plot fringe prediction timeseries
#ax1.plot(times,scatf5, c='blue', linewidth='0.2', label='f5')
ax1.plot(times,scatf4, c='purple', linewidth='0.4', label='f4')
ax1.plot(times,scatf3, c='green', linewidth='0.4', label='f3')
ax1.plot(times,scatf2, c='blue', linewidth='0.4', label='f2')
ax1.plot(times,scatf1, c='black', linewidth='0.4', label='f1')
#if plotspec < 1 and dur <= 3600:
示例4: single_plot
# 需要导入模块: from matplotlib.image import NonUniformImage [as 别名]
# 或者: from matplotlib.image.NonUniformImage import set_clim [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]")