本文整理汇总了Python中matplotlib.pyplot.clim函数的典型用法代码示例。如果您正苦于以下问题:Python clim函数的具体用法?Python clim怎么用?Python clim使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了clim函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: color_plot
def color_plot(targets,k_DD,f_DD,coherence,azimuths):
f_DD_boundaries = ( f_DD - (f_DD[1]-f_DD[0])/2 )
d_phi = 1/coherence.shape[1]
angles_over_pi = np.arange(0,1+d_phi,1/coherence.shape[1])
plt.pcolor(angles_over_pi,f_DD_boundaries,coherence)
if show_azimuths:
for azimuth in azimuths:
plt.axvline(mod(azimuth),color="k",linewidth=2)
plt.xlim(0,1)
plt.ylim(0,f_DD_boundaries[-1])
plt.clim(-1,1)
plt.xlabel(r"$\phi_{DD}/\pi$")
plt.ylabel("$f_{}$".format(k_DD))
cbar = plt.colorbar()
cbar.set_label("Coherence")
plt.tight_layout()
plt.savefig(figname(targets))
if show: plt.show()
示例2: on_keypress
def on_keypress(self,event):
global colmax
global colmin
if event.key in ['1', '2', '3', '4', '5', '6', '7','8', '9', '0']:
if not os.path.exists(write_dir + runtag):
os.mkdir(write_dir + runtag)
recordtag = write_dir + runtag + "/" + runtag + "_" + event.key + ".txt"
print "recording filename in " + recordtag
f = open(recordtag, 'a+')
f.write(self.filename+"\n")
f.close()
if event.key == 'p':
if not os.path.exists(write_dir + runtag):
os.mkdir(write_dir + runtag)
pngtag = write_dir + runtag + "/%s.png" % (self.filename)
print "saving image as " + pngtag
P.savefig(pngtag)
if event.key == 'e':
if not os.path.exists(write_dir + runtag):
os.mkdir(write_dir + runtag)
epstag = write_dir + runtag + "/%s.eps" % (self.filename)
print "saving image as " + epstag
P.savefig(epstag, format='eps')
if event.key == 'r':
colmin = self.inarr.min()
colmax = self.inarr.max()
P.clim(colmin, colmax)
P.draw()
示例3: showMechStiff
def showMechStiff(model, coords, *args, **kwargs):
"""Show mechanical stiffness matrix using :func:`~matplotlib.pyplot.imshow`.
By default, *origin=lower* keyword arguments are passed to this function,
but user can overwrite these parameters."""
import math
import matplotlib
import matplotlib.pyplot as plt
arange = np.arange(model.numAtoms())
model.buildMechStiff(coords)
if not 'origin' in kwargs:
kwargs['origin'] = 'lower'
if 'jet_r' in kwargs:
import matplotlib.cm as plt
kwargs['jet_r'] = 'cmap=cm.jet_r'
MechStiff = model.getStiffness()
matplotlib.rcParams['font.size'] = '14'
fig = plt.figure(num=None, figsize=(10,8), dpi=100, facecolor='w')
show = plt.imshow(MechStiff, *args, **kwargs), plt.colorbar()
plt.clim(math.floor(np.min(MechStiff[np.nonzero(MechStiff)])), \
round(np.amax(MechStiff),1))
#plt.title('Mechanical Stiffness Matrix')# for {0}'.format(str(model)))
plt.xlabel('Indices', fontsize='16')
plt.ylabel('Indices', fontsize='16')
if SETTINGS['auto_show']:
showFigure()
return show
示例4: my_plot
def my_plot(c_plot, step):
filename = "chs-step" + str(step) + ".png"
plt.imshow(c_plot)
plt.colorbar()
plt.clim(0, 1)
plt.savefig(filename)
plt.clf()
示例5: create_animation_rate
def create_animation_rate(rate, frames=100, interval=1, fps=10, dpi=90, filename='default.mp4', format='.mp4'):
"""
Documentation needed
"""
filename = filename + '-rate_animation' + format
# Initiate figure
fig = plt.figure()
ims = plt.imshow(rate[::,::,1])
plt.xlabel('Neuron\'s x coordinate')
plt.ylabel('Neuron\'s y coordinate')
plt.title('Firing rate in a 20 ms window')
cbar = plt.colorbar()
cbar.ax.set_ylabel('Firing Rate (Hz)')
plt.clim(0,70)
# Define how to update frames
def updatefig(i):
ims.set_array( rate[:,:,i] )
return ims,
# run and save the animation
image_animation = animation.FuncAnimation(fig,updatefig, frames=frames, interval=interval, blit = True)
image_animation.save(filename, fps=fps, dpi=dpi)
plt.show()
示例6: _colormap_plot_array_response
def _colormap_plot_array_response(cmaps):
"""
Plot for illustrating colormaps: array response.
:param cmaps: list of :class:`~matplotlib.colors.Colormap`
:rtype: None
"""
import matplotlib.pyplot as plt
from obspy.signal.array_analysis import array_transff_wavenumber
# generate array coordinates
coords = np.array([[10., 60., 0.], [200., 50., 0.], [-120., 170., 0.],
[-100., -150., 0.], [30., -220., 0.]])
# coordinates in km
coords /= 1000.
# set limits for wavenumber differences to analyze
klim = 40.
kxmin = -klim
kxmax = klim
kymin = -klim
kymax = klim
kstep = klim / 100.
# compute transfer function as a function of wavenumber difference
transff = array_transff_wavenumber(coords, klim, kstep, coordsys='xy')
# plot
for cmap in cmaps:
plt.figure()
plt.pcolor(np.arange(kxmin, kxmax + kstep * 1.1, kstep) - kstep / 2.,
np.arange(kymin, kymax + kstep * 1.1, kstep) - kstep / 2.,
transff.T, cmap=cmap)
plt.colorbar()
plt.clim(vmin=0., vmax=1.)
plt.xlim(kxmin, kxmax)
plt.ylim(kymin, kymax)
plt.show()
示例7: main
def main(unused_argv):
global heat_map
tf_records_file_names = sorted(os.listdir(utils.HEAT_MAP_TF_RECORDS_DIR))
print(tf_records_file_names)
tf_records_file_names = tf_records_file_names[2:3]
for wsi_filename in tf_records_file_names:
print('Generating heatmap for: %s' % wsi_filename)
tf_records_dir = os.path.join(utils.HEAT_MAP_TF_RECORDS_DIR, wsi_filename)
raw_patches_dir = os.path.join(utils.HEAT_MAP_RAW_PATCHES_DIR, wsi_filename)
heatmap_rgb_path = os.path.join(utils.HEAT_MAP_WSIs_PATH, wsi_filename)
assert os.path.exists(heatmap_rgb_path), 'heatmap rgb image %s does not exist' % heatmap_rgb_path
heatmap_rgb = Image.open(heatmap_rgb_path)
heatmap_rgb = np.array(heatmap_rgb)
heatmap_rgb = heatmap_rgb[:, :, :1]
heatmap_rgb = np.reshape(heatmap_rgb, (heatmap_rgb.shape[0], heatmap_rgb.shape[1]))
heat_map = np.zeros((heatmap_rgb.shape[0], heatmap_rgb.shape[1]), dtype=np.float32)
assert os.path.exists(raw_patches_dir), 'raw patches directory %s does not exist' % raw_patches_dir
num_patches = len(os.listdir(raw_patches_dir))
assert os.path.exists(tf_records_dir), 'tf-records directory %s does not exist' % tf_records_dir
dataset = Dataset(DATA_SET_NAME, utils.data_subset[4], tf_records_dir=tf_records_dir, num_patches=num_patches)
build_heatmap(dataset)
# Image.fromarray(heat_map).save(os.path.join(utils.HEAT_MAP_DIR, wsi_filename), 'PNG')
plt.imshow(heat_map, cmap='hot', interpolation='nearest')
plt.colorbar()
plt.clim(0.00, 1.00)
plt.axis([0, heatmap_rgb.shape[1], 0, heatmap_rgb.shape[0]])
plt.savefig(str(os.path.join(utils.HEAT_MAP_DIR, wsi_filename))+'_heatmap.png')
plt.show()
示例8: plotSVM
def plotSVM(solver, lowerBound, upperBound, step):
assert lowerBound < upperBound
X = arange(lowerBound, upperBound, step)
Y = arange(lowerBound, upperBound, step)
X,Y = meshgrid(X,Y)
Z = zeros(X.shape)
for i in range(len(X)):
for j in range(len(Y)):
#Classify the result
result = int( svm_predict([0.], [[ X[i][j], Y[i][j] ]], solver, '-q')[0][0] )
if result == 0:
Z[i][j] = 0 #lower limit
else:
Z[i][j] = 100 #higher limit
plot.imshow(Z)
plot.gcf()
plot.clim()
plot.title("SVM Activation")
return plot
示例9: main
def main():
import matplotlib.pyplot as plt
x, y = np.mgrid[-1:1:200j, -1:1:200j]
rho = np.sqrt(x**2 + y**2)
theta = np.arctan(y / x)
theta[(theta.shape[0] / 2):] += np.pi
nm_pairs = list(n_m_upto(4, 2))
plt.ioff()
cur_max = -np.inf
cur_min = np.inf
main_axes = plt.gca()
for index, (n, m) in enumerate(nm_pairs):
image = zernike_exp(rho, theta, n, m)
cur_max = max(cur_max, np.max(np.real(image[~np.isnan(image)])),
np.max(np.imag(image[~np.isnan(image)])))
cur_min = min(cur_min, np.min(np.real(image[~np.isnan(image)])),
np.min(np.imag(image[~np.isnan(image)])))
plt.subplot(2, len(nm_pairs), index + 1)
plt.imshow(np.real(image), cmap=plt.cm.gray)
plt.title('$\\mathrm{real}(V_{%d,%d}(\\rho, \\theta))$' % (n, m))
plt.axis('off')
plt.subplot(2, len(nm_pairs), len(nm_pairs) + index + 1)
plt.imshow(np.imag(image), cmap=plt.cm.gray)
plt.title('$\\mathrm{imag}(V_{%d,%d}(\\rho, \\theta))$' % (n, m))
plt.axis('off')
for index in range(2 * len(nm_pairs)):
plt.subplot(2, len(nm_pairs), index + 1)
plt.clim(cur_min, cur_max)
print "cur_min =", cur_min
print "cur_max =", cur_max
plt.show()
plt.ion()
示例10: plot_fld
def plot_fld(fldname, step, cra=None, xlim=None, ylim=None):
flds = psc.PscFields(path, step, "p")
fld = flds[fldname]
crd_nc = flds.crd_nc
plt.figure()
kwargs = {}
plt.pcolormesh(crd_nc[1], crd_nc[2], fld[:,:,0], **kwargs)
if cra:
plt.clim(*cra)
plt.colorbar()
plt.title(fldname)
plt.xlabel("y")
plt.ylabel("z")
if xlim:
plt.xlim(*xlim)
else:
plt.xlim(crd_nc[1][0], crd_nc[1][-1])
if ylim:
plt.ylim(*ylim)
else:
plt.ylim(crd_nc[2][0], crd_nc[2][-1])
plt.axes().set_aspect('equal')
plt.savefig("%s-%06d.png" % (fldname, step), dpi=100)
plt.close()
示例11: data_movie
def data_movie(data, fig=None, pause=None, **kwargs):
"""
Display all images of a data cube as a movie.
Arguments
---------
data: ndarray
A data cube. Third dimension should be the image index.
fig: Figure instance (optional).
A figure instance where the images will be displayed.
kwargs: Keywor arguments.
Other keyword arguments are passed to imshow.
Returns
-------
Nothing.
"""
if fig is None:
fig = plt.figure()
a = fig.gca()
dmin, dmax = data.min(), data.max()
n = data.shape[-1]
im0 = a.imshow(data[..., 0].T, origin="lower", **kwargs)
plt.draw()
for k in xrange(n):
im0.set_data(data[..., k].T)
plt.title("Image " + str(k))
plt.clim([dmin, dmax])
plt.draw()
if pause is not None:
time.sleep(pause)
示例12: plot_grammar_matrices
def plot_grammar_matrices(self,
folder_path,
folder_name,
A_matrix = np.zeros(0),
B_matrix = np.zeros(0)):
if folder_name in os.listdir(folder_path):
shutil.rmtree(folder_path + '/' + folder_name,
True)
os.mkdir(folder_path + '/' + folder_name)
if(len(A_matrix) == 0):
A_matrix = self.A
if(len(B_matrix) == 0):
B_matrix = self.B
assert(A_matrix.shape[0] == A_matrix.shape[1] == A_matrix.shape[2] == B_matrix.shape[0])
N = A_matrix.shape[0]
for i in xrange(N):
plt.subplot(211)
plt.title('A %d' % i)
plt.imshow(A_matrix[i], interpolation = 'None')
plt.clim(0, 1.0)
plt.subplot(212)
plt.plot(range(len(B_matrix[i])), B_matrix[i], linestyle = 'None', marker = 'o')
plt.ylim(-0.2, 1.0)
plt.xlim(-1, len(B_matrix[i]))
plt.title('B %d' % i)
plt.savefig(folder_path + '/' + folder_name + '/' + string.lower(folder_name) + '_rule_' + str(i) + '.png', dpi = 300)
plt.close()
示例13: animate
def animate(i):
plt.clf()
m, _ = atm.pcolor_latlon(animdata[i], axlims=axlims, cmap=cmap)
plt.clim(cmin, cmax)
day = animdata[daynm + 'rel'].values[i]
plt.title('%s %s RelDay %d' % (var, yearstr, day))
return m
示例14: heat_map
def heat_map(self,DL):
fig = plt.figure()
ax = fig.add_subplot(1,1,1)
plt.imshow(DL)
plt.clim(DL.mean()-3*DL.std(),DL.mean()+3*DL.std())
plt.colorbar()
plt.show(block=False)
示例15: plot_gridsearch_result
def plot_gridsearch_result(tau_sses, tau_ranges, tau_opt, ptitle='default title',save=False):
fig = plt.figure(figsize=(24,20), facecolor='white')
subrows = np.ceil(np.sqrt(tau_ranges[-1].shape))
subcols = np.ceil(tau_ranges[-1].shape/subrows)
gs = gridspec.GridSpec(int(subrows), int(subcols), left=0.1, right=0.90, bottom=0.1, top=0.9)
gs.update(hspace=0.5, wspace=0.5)
for ctau3_idx,ctau3 in enumerate(tau_ranges[-1]):
plt.subplot(gs[ctau3_idx])
img = plt.imshow(tau_sses[:,:,ctau3_idx], aspect='auto', interpolation='none', origin='lower')
img.axes.set_yticks(np.arange(len(tau_ranges[0])))
img.axes.set_yticklabels(tau_ranges[0])
img.axes.set_xticks(np.arange(len(tau_ranges[1]),step=2))
img.axes.set_xticklabels(np.arange(tau_ranges[1][0],np.max(tau_ranges[1]),step=10))
plt.xlabel('Second time constant [ms]',fontsize=12)
plt.ylabel('First time constant [ms]',fontsize=12)
plt.title('Total SSE, for tau 3 = '+str(ctau3) + 'ms',fontsize=12)
plt.colorbar()
plt.clim(tau_sses.min(),tau_sses.min()*1.5)
plt.suptitle(ptitle,fontsize=20)
fig.text(0.8,0.95, 'Optimal set of taus: '+str(tau_opt.squeeze()))
if save==True:
if not os.path.exists(figure_path):
os.makedirs(figure_path)
plt.savefig(figure_path + ptitle, dpi=120)
plt.close(fig)