本文整理汇总了Python中matplotlib.pyplot.set_cmap方法的典型用法代码示例。如果您正苦于以下问题:Python pyplot.set_cmap方法的具体用法?Python pyplot.set_cmap怎么用?Python pyplot.set_cmap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.pyplot
的用法示例。
在下文中一共展示了pyplot.set_cmap方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _debug_save_map_nodes
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import set_cmap [as 别名]
def _debug_save_map_nodes(self, seed):
"""Saves traversible space along with nodes generated on the graph. Takes
the seed as input."""
img_path = os.path.join(self.logdir, '{:s}_{:d}_graph.png'.format(self.building_name, seed))
node_xyt = self.to_actual_xyt_vec(self.task.nodes)
plt.set_cmap('jet');
fig, ax = utils.subplot(plt, (1,1), (12,12))
ax.plot(node_xyt[:,0], node_xyt[:,1], 'm.')
ax.set_axis_off(); ax.axis('equal');
if self.room_dims is not None:
for i, r in enumerate(self.room_dims['dims']*1):
min_ = r[:3]*1
max_ = r[3:]*1
xmin, ymin, zmin = min_
xmax, ymax, zmax = max_
ax.plot([xmin, xmax, xmax, xmin, xmin],
[ymin, ymin, ymax, ymax, ymin], 'g')
ax.imshow(self.traversible, origin='lower');
with fu.fopen(img_path, 'w') as f:
fig.savefig(f, bbox_inches='tight', transparent=True, pad_inches=0)
示例2: init_figure
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import set_cmap [as 别名]
def init_figure(self):
self.init_fig = True
if self.args.figure == True:# and self.obj_fig==None:
self.obj_fig = plt.figure(figsize=(16,12))
plt.set_cmap('viridis')
self.gridspec = gridspec.GridSpec(3,5)
self.ax_map = plt.subplot(self.gridspec[0,0])
self.ax_scan = plt.subplot(self.gridspec[1,0])
self.ax_pose = plt.subplot(self.gridspec[2,0])
self.ax_bel = plt.subplot(self.gridspec[0,1])
self.ax_lik = plt.subplot(self.gridspec[1,1])
self.ax_gtl = plt.subplot(self.gridspec[2,1])
self.ax_pbel = plt.subplot(self.gridspec[0,2:4])
self.ax_plik = plt.subplot(self.gridspec[1,2:4])
self.ax_pgtl = plt.subplot(self.gridspec[2,2:4])
self.ax_act = plt.subplot(self.gridspec[0,4])
self.ax_rew = plt.subplot(self.gridspec[1,4])
self.ax_err = plt.subplot(self.gridspec[2,4])
plt.subplots_adjust(hspace = 0.4, wspace=0.4, top=0.95, bottom=0.05)
示例3: plot_sff2
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import set_cmap [as 别名]
def plot_sff2(SFF, walls, i):
"""
plots a numbered image. Useful for making movies
"""
print("plot_sff: %.6d"%i)
fig = plt.figure()
ax = fig.add_subplot(111)
ax.cla()
plt.set_cmap('jet')
cmap = plt.get_cmap()
cmap.set_bad(color='k', alpha=0.8)
vect = SFF * walls
vect[vect < 0] = np.Inf
# print (vect)
max_value = np.max(SFF)
min_value = np.min(SFF)
plt.imshow(vect, cmap=cmap, interpolation='nearest', vmin=min_value, vmax=max_value, extent=[0, dim_y, 0, dim_x]) # lanczos nearest
plt.colorbar()
# print(i)
plt.title("%.6d"%i)
figure_name = os.path.join('sff', '%.6d.png'%i)
plt.savefig(figure_name)
plt.close()
示例4: plot_sff
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import set_cmap [as 别名]
def plot_sff(SFF, walls):
fig = plt.figure()
ax = fig.add_subplot(111)
ax.cla()
plt.set_cmap('jet')
cmap = plt.get_cmap()
cmap.set_bad(color='k', alpha=0.8)
vect = SFF.copy()
vect[walls < 0] = np.Inf
max_value = np.max(SFF)
min_value = np.min(SFF)
plt.imshow(vect, cmap=cmap, interpolation='nearest', vmin=min_value, vmax=max_value, extent=[0, dim_y, 0, dim_x]) # lanczos nearest
plt.colorbar()
figure_name = os.path.join('sff', 'SFF.png')
plt.savefig(figure_name, dpi=600)
plt.close()
示例5: plot_dff
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import set_cmap [as 别名]
def plot_dff(dff, walls, name="DFF", max_value=None, title=""):
fig = plt.figure()
ax = fig.add_subplot(111)
ax.cla()
plt.set_cmap('jet')
cmap = plt.get_cmap()
cmap.set_bad(color='k', alpha=0.8)
vect = dff.copy()
vect[walls < 0] = np.Inf
im = ax.imshow(vect, cmap=cmap, interpolation='nearest', vmin=0, vmax=max_value, extent=[0, dim_y, 0, dim_x]) # lanczos nearest
plt.colorbar(im, format='%.1f')
#cbar = plt.colorbar()
if title:
plt.title(title)
figure_name = os.path.join('dff', name+'.png')
plt.savefig(figure_name, dpi=600)
plt.close()
logging.info("plot dff. figure: {}.png".format(name))
示例6: plot_matrix_and_get_image
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import set_cmap [as 别名]
def plot_matrix_and_get_image(plot_data, fig_height=8, fig_width=12, axis_off=False, colormap="jet"):
fig = plt.figure()
fig.set_figheight(fig_height)
fig.set_figwidth(fig_width)
plt.matshow(plot_data, fig.number)
if fig_height < fig_width:
plt.colorbar(orientation="horizontal")
else:
plt.colorbar(orientation="vertical")
plt.set_cmap(colormap)
if axis_off:
plt.axis('off')
img = fig_to_img(fig)
plt.close(fig)
return img
示例7: visualize_pc_dataset
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import set_cmap [as 别名]
def visualize_pc_dataset(dataset_filepath):
dataset = import_python_file(dataset_filepath)
dataset_reader = PairedCompDatasetReader(dataset)
tensor_pvs_pvs_subject = dataset_reader.opinion_score_3darray
plt.figure()
# plot the rate of winning x, 0 <= x <= 1.0, of one PVS compared against another PVS
mtx_pvs_pvs = np.nansum(tensor_pvs_pvs_subject, axis=2) \
/ (np.nansum(tensor_pvs_pvs_subject, axis=2) +
np.nansum(tensor_pvs_pvs_subject, axis=2).transpose())
plt.imshow(mtx_pvs_pvs, interpolation='nearest')
plt.title(r'Paired Comparison Winning Rate')
plt.ylabel(r"PVS ($j$)")
plt.xlabel(r"PVS ($j'$) [Compared Against]")
plt.set_cmap('jet')
plt.colorbar()
plt.tight_layout()
示例8: draw_lines
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import set_cmap [as 别名]
def draw_lines(num_samples, sample_rate, lines):
"""Debugging function to draw detected lines in black"""
lines_matrix = np.zeros((num_samples, num_samples))
for line in lines:
lines_matrix[line.lag:line.lag + 4, line.start:line.end + 1] = 1
# Import here since this function is only for debugging
import librosa.display
import matplotlib.pyplot as plt
librosa.display.specshow(
lines_matrix,
y_axis='time',
x_axis='time',
sr=sample_rate / (N_FFT / 2048))
plt.colorbar()
plt.set_cmap("hot_r")
plt.show()
示例9: _vis_readout_maps
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import set_cmap [as 别名]
def _vis_readout_maps(outputs, global_step, output_dir, metric_summary, N):
# outputs is [gt_map, pred_map]:
if N >= 0:
outputs = outputs[:N]
N = len(outputs)
plt.set_cmap('jet')
fig, axes = utils.subplot(plt, (N, outputs[0][0].shape[4]*2), (5,5))
axes = axes.ravel()[::-1].tolist()
for i in range(N):
gt_map, pred_map = outputs[i]
for j in [0]:
for k in range(gt_map.shape[4]):
# Display something like the midpoint of the trajectory.
id = np.int(gt_map.shape[1]/2)
ax = axes.pop();
ax.imshow(gt_map[j,id,:,:,k], origin='lower', interpolation='none',
vmin=0., vmax=1.)
ax.set_axis_off();
if i == 0: ax.set_title('gt_map')
ax = axes.pop();
ax.imshow(pred_map[j,id,:,:,k], origin='lower', interpolation='none',
vmin=0., vmax=1.)
ax.set_axis_off();
if i == 0: ax.set_title('pred_map')
file_name = os.path.join(output_dir, 'readout_map_{:d}.png'.format(global_step))
with fu.fopen(file_name, 'w') as f:
fig.savefig(f, bbox_inches='tight', transparent=True, pad_inches=0)
plt.close(fig)
示例10: plot_optimizer
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import set_cmap [as 别名]
def plot_optimizer(opt, lower, upper):
import matplotlib.pyplot as plt
plt.set_cmap("viridis")
if not opt.models:
print('Can not plot opt, since models do not exist yet.')
return
model = opt.models[-1]
x = np.linspace(lower, upper).reshape(-1, 1)
x_model = opt.space.transform(x)
# Plot Model(x) + contours
y_pred, sigma = model.predict(x_model, return_std=True)
plt.plot(x, -y_pred, "g--", label=r"$\mu(x)$")
plt.fill(np.concatenate([x, x[::-1]]),
np.concatenate([-y_pred - 1.9600 * sigma,
(-y_pred + 1.9600 * sigma)[::-1]]),
alpha=.2, fc="g", ec="None")
# Plot sampled points
plt.plot(opt.Xi, -np.array(opt.yi),
"r.", markersize=8, label="Observations")
# Adjust plot layout
plt.grid()
plt.legend(loc='best')
plt.show()
示例11: visualize_att
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import set_cmap [as 别名]
def visualize_att(image_path, seq, alphas, rev_word_map, smooth=True):
"""
Visualizes caption with weights at every word.
Adapted from paper authors' repo: https://github.com/kelvinxu/arctic-captions/blob/master/alpha_visualization.ipynb
:param image_path: path to image that has been captioned
:param seq: caption
:param alphas: weights
:param rev_word_map: reverse word mapping, i.e. ix2word
:param smooth: smooth weights?
"""
image = Image.open(image_path)
image = image.resize([14 * 24, 14 * 24], Image.LANCZOS)
words = [rev_word_map[ind] for ind in seq]
for t in range(len(words)):
if t > 50:
break
plt.subplot(np.ceil(len(words) / 5.), 5, t + 1)
plt.text(0, 1, '%s' % (words[t]), color='black', backgroundcolor='white', fontsize=12)
plt.imshow(image)
current_alpha = alphas[t, :]
if smooth:
alpha = skimage.transform.pyramid_expand(current_alpha.numpy(), upscale=24, sigma=8)
else:
alpha = skimage.transform.resize(current_alpha.numpy(), [14 * 24, 14 * 24])
if t == 0:
plt.imshow(alpha, alpha=0)
else:
plt.imshow(alpha, alpha=0.8)
plt.set_cmap(cm.Greys_r)
plt.axis('off')
plt.show()
示例12: sitk_show
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import set_cmap [as 别名]
def sitk_show(nda, title=None, margin=0.0, dpi=40):
figsize = (1 + margin) * nda.shape[0] / dpi, (1 + margin) * nda.shape[1] / dpi
extent = (0, nda.shape[1], nda.shape[0], 0)
fig = plt.figure(figsize=figsize, dpi=dpi)
ax = fig.add_axes([margin, margin, 1 - 2*margin, 1 - 2*margin])
plt.set_cmap("gray")
for k in range(0,nda.shape[2]):
print "printing slice "+str(k)
ax.imshow(np.squeeze(nda[:,:,k]),extent=extent,interpolation=None)
plt.draw()
plt.pause(0.1)
#plt.waitforbuttonpress()
示例13: init_figure
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import set_cmap [as 别名]
def init_figure(self):
self.init_fig = True
if self.args.figure == True:# and self.obj_fig==None:
self.obj_fig = plt.figure(figsize=(16,12))
plt.set_cmap('viridis')
self.gridspec = gridspec.GridSpec(3,5)
self.ax_map = plt.subplot(self.gridspec[0,0])
self.ax_scan = plt.subplot(self.gridspec[1,0])
self.ax_pose = plt.subplot(self.gridspec[2,0])
self.ax_bel = plt.subplot(self.gridspec[0,1])
self.ax_lik = plt.subplot(self.gridspec[1,1])
self.ax_gtl = plt.subplot(self.gridspec[2,1])
# self.ax_prior = plt.subplot(self.gridspec[2,1])
self.ax_pbel = plt.subplot(self.gridspec[0,2:4])
self.ax_plik = plt.subplot(self.gridspec[1,2:4])
self.ax_pgtl = plt.subplot(self.gridspec[2,2:4])
self.ax_act = plt.subplot(self.gridspec[0,4])
self.ax_rew = plt.subplot(self.gridspec[1,4])
self.ax_err = plt.subplot(self.gridspec[2,4])
plt.subplots_adjust(hspace = 0.4, wspace=0.4, top=0.95, bottom=0.05)
示例14: doubleslit
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import set_cmap [as 别名]
def doubleslit(b=0.1,a=0.4,lambda_1=632,z=0.5):
"""
Return a Young's doubleslit(Frauhofer Diffraction)
Input:
--------------------------------
b: slit of width in mm
a: slit separation of in mm
lambda_1: wavelength in nm
z: slit-to-screen distance in m.
"""
lambda_1 = float(lambda_1)
theta = __np__.linspace(-0.04,0.04,1000)
theta1 = __np__.ones(100)
[theta,theta1] = __np__.meshgrid(theta,theta1)
beta = __np__.pi*(b/1000)/(lambda_1/(10**9))*__sin__(theta)
alpha = __np__.pi*(a/1000)/(lambda_1/(10**9))*__sin__(theta)
y = 4*(__sin__(beta)**2/(beta**2)*__cos__(alpha)**2)
fig = __plt__.figure(1,figsize=(12,8), dpi=80)
__plt__.imshow(-y)
__plt__.set_cmap('Greys')
__plt__.show()
theta = __np__.linspace(-0.04,0.04,1000)
beta = __np__.pi*(b/1000)/(lambda_1/(10**9))*__sin__(theta)
alpha = __np__.pi*(a/1000)/(lambda_1/(10**9))*__sin__(theta)
y = 4*(__sin__(beta)**2/(beta**2)*__cos__(alpha)**2)
y1 = 4*__sin__(beta)**2/(beta**2)
fig = __plt__.figure(2,figsize=(12, 8), dpi=80)
__plt__.plot(theta*z*1000,y)
__plt__.plot(theta*z*1000,y1,"g--")
__plt__.show()
示例15: __apershow__
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import set_cmap [as 别名]
def __apershow__(obj, extent):
if extent != 0:
obj = -abs(obj)
__plt__.imshow(obj, extent = [-extent/2,extent/2,-extent/2,extent/2])
__plt__.set_cmap('Greys')
__plt__.show()
else:
obj = -abs(obj)
__plt__.imshow(obj)
__plt__.set_cmap('Greys')
__plt__.show()