本文整理汇总了Python中matplotlib.pylab.colorbar方法的典型用法代码示例。如果您正苦于以下问题:Python pylab.colorbar方法的具体用法?Python pylab.colorbar怎么用?Python pylab.colorbar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.pylab
的用法示例。
在下文中一共展示了pylab.colorbar方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: generate_png_chess_dp_vertex
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import colorbar [as 别名]
def generate_png_chess_dp_vertex(self):
"""Produces pictures of the dominant product vertex a chessboard convention"""
import matplotlib.pylab as plt
plt.ioff()
dab2v = self.get_dp_vertex_doubly_sparse()
for i, ab in enumerate(dab2v):
fname = "chess-v-{:06d}.png".format(i)
print('Matrix No.#{}, Size: {}, Type: {}'.format(i+1, ab.shape, type(ab)), fname)
if type(ab) != 'numpy.ndarray': ab = ab.toarray()
fig = plt.figure()
ax = fig.add_subplot(1,1,1)
ax.set_aspect('equal')
plt.imshow(ab, interpolation='nearest', cmap=plt.cm.ocean)
plt.colorbar()
plt.savefig(fname)
plt.close(fig)
示例2: plot_confusion_matrix
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import colorbar [as 别名]
def plot_confusion_matrix(cm, genre_list, name, title):
pylab.clf()
pylab.matshow(cm, fignum=False, cmap='Blues', vmin=0, vmax=1.0)
ax = pylab.axes()
ax.set_xticks(range(len(genre_list)))
ax.set_xticklabels(genre_list)
ax.xaxis.set_ticks_position("bottom")
ax.set_yticks(range(len(genre_list)))
ax.set_yticklabels(genre_list)
pylab.title(title)
pylab.colorbar()
pylab.grid(False)
pylab.show()
pylab.xlabel('Predicted class')
pylab.ylabel('True class')
pylab.grid(False)
pylab.savefig(
os.path.join(CHART_DIR, "confusion_matrix_%s.png" % name), bbox_inches="tight")
开发者ID:PacktPublishing,项目名称:Building-Machine-Learning-Systems-With-Python-Second-Edition,代码行数:20,代码来源:utils.py
示例3: plot_alignment_to_numpy
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import colorbar [as 别名]
def plot_alignment_to_numpy(alignment, info=None):
fig, ax = plt.subplots(figsize=(6, 4))
im = ax.imshow(alignment, aspect='auto', origin='lower',
interpolation='none')
fig.colorbar(im, ax=ax)
xlabel = 'Decoder timestep'
if info is not None:
xlabel += '\n\n' + info
plt.xlabel(xlabel)
plt.ylabel('Encoder timestep')
plt.tight_layout()
fig.canvas.draw()
data = save_figure_to_numpy(fig)
plt.close()
return data
示例4: matrix
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import colorbar [as 别名]
def matrix(msg, mobj):
"""
Interpret a user string, convert it to a list and graph it as a matrix
Uses ast.literal_eval to parse input into a list
"""
fname = bot_data("{}.png".format(mobj.author.id))
try:
list_input = literal_eval(msg)
if not isinstance(list_input, list):
raise ValueError("Not a list")
m = np_matrix(list_input)
fig = plt.figure()
ax = fig.add_subplot(1,1,1)
ax.set_aspect('equal')
plt.imshow(m, interpolation='nearest', cmap=plt.cm.ocean)
plt.colorbar()
plt.savefig(fname)
await client.send_file(mobj.channel, fname)
f_remove(fname)
return
except Exception as ex:
logger("!matrix: {}".format(ex))
return await client.send_message(mobj.channel, "Failed to render graph")
示例5: real
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import colorbar [as 别名]
def real(val, outline=None, ax=None, cbar=False, cmap='RdBu', outline_alpha=0.5):
"""Plots the real part of 'val', optionally overlaying an outline of 'outline'
"""
if ax is None:
fig, ax = plt.subplots(1, 1, constrained_layout=True)
vmax = np.abs(val).max()
h = ax.imshow(np.real(val.T), cmap=cmap, origin='lower left', vmin=-vmax, vmax=vmax)
if outline is not None:
ax.contour(outline.T, 0, colors='k', alpha=outline_alpha)
ax.set_ylabel('y')
ax.set_xlabel('x')
if cbar:
plt.colorbar(h, ax=ax)
return ax
示例6: abs
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import colorbar [as 别名]
def abs(val, outline=None, ax=None, cbar=False, cmap='magma', outline_alpha=0.5, outline_val=None):
"""Plots the absolute value of 'val', optionally overlaying an outline of 'outline'
"""
if ax is None:
fig, ax = plt.subplots(1, 1, constrained_layout=True)
vmax = np.abs(val).max()
h = ax.imshow(np.abs(val.T), cmap=cmap, origin='lower left', vmin=0, vmax=vmax)
if outline_val is None and outline is not None: outline_val = 0.5*(outline.min()+outline.max())
if outline is not None:
ax.contour(outline.T, [outline_val], colors='w', alpha=outline_alpha)
ax.set_ylabel('y')
ax.set_xlabel('x')
if cbar:
plt.colorbar(h, ax=ax)
return ax
示例7: plot_spectrogram_to_numpy
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import colorbar [as 别名]
def plot_spectrogram_to_numpy(spectrogram):
spectrogram = spectrogram.transpose(1, 0)
fig, ax = plt.subplots(figsize=(12, 3))
im = ax.imshow(spectrogram, aspect="auto", origin="lower",
interpolation='none')
plt.colorbar(im, ax=ax)
plt.xlabel("Frames")
plt.ylabel("Channels")
plt.tight_layout()
fig.canvas.draw()
data = _save_figure_to_numpy(fig)
plt.close()
return data
####################
# PLOT SPECTROGRAM #
####################
开发者ID:andi611,项目名称:Self-Supervised-Speech-Pretraining-and-Representation-Learning,代码行数:21,代码来源:audio.py
示例8: plot_spectrogram_to_numpy
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import colorbar [as 别名]
def plot_spectrogram_to_numpy(spectrogram):
fig, ax = plt.subplots(figsize=(12, 3))
im = ax.imshow(spectrogram, aspect="auto", origin="lower",
interpolation='none')
plt.colorbar(im, ax=ax)
plt.xlabel("Frames")
plt.ylabel("Channels")
plt.tight_layout()
fig.canvas.draw()
data = save_figure_to_numpy(fig)
plt.close()
return data
# from https://github.com/NVIDIA/vid2vid/blob/951a52bb38c2aa227533b3731b73f40cbd3843c4/models/networks.py#L17
示例9: plot_alignment
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import colorbar [as 别名]
def plot_alignment(alignment, fn):
# [4, encoder_step, decoder_step]
fig, axes = plt.subplots(2, 2)
for i in range(2):
for j in range(2):
g = axes[i][j].imshow(alignment[i*2+j,:,:].T,
aspect='auto', origin='lower',
interpolation='none')
plt.colorbar(g, ax=axes[i][j])
plt.savefig(fn)
plt.close()
return fn
示例10: plot_spectrogram_to_numpy
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import colorbar [as 别名]
def plot_spectrogram_to_numpy(spectrogram):
fig, ax = plt.subplots(figsize=(12, 3))
im = ax.imshow(spectrogram, aspect="auto", origin="lower",
interpolation='none')
plt.colorbar(im, ax=ax)
plt.xlabel("Frames")
plt.ylabel("Channels")
plt.tight_layout()
fig.canvas.draw()
data = save_figure_to_numpy(fig)
plt.close()
return data
示例11: plot_data
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import colorbar [as 别名]
def plot_data(data, fn, figsize=(12, 4)):
fig, axes = plt.subplots(1, len(data), figsize=figsize)
for i in range(len(data)):
if len(data) == 1:
ax = axes
else:
ax = axes[i]
g = ax.imshow(data[i], aspect='auto', origin='bottom',
interpolation='none')
plt.colorbar(g, ax=ax)
plt.savefig(fn)
示例12: plot_alignment
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import colorbar [as 别名]
def plot_alignment(alignment, fn):
# [4, encoder_step, decoder_step]
fig, axes = plt.subplots(1, 2)
for j in range(2):
g = axes[j].imshow(alignment[j,:,:].T,
aspect='auto', origin='lower',
interpolation='none')
plt.colorbar(g, ax=axes[j])
plt.savefig(fn)
plt.close()
return fn
示例13: reshape_and_plot
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import colorbar [as 别名]
def reshape_and_plot(fig, ax, input_array, vmin, vmax, colorbar=True ):
assert( (input_array>=vmin).all() )
assert( (input_array<=vmax).all() )
reshaped_array = np.reshape( input_array, (defaults.points_per_dim,defaults.points_per_dim) )
im = ax.imshow( reshaped_array, extent = [defaults.upper_lim,defaults.lower_lim,defaults.upper_lim,defaults.lower_lim], vmin=vmin, vmax=vmax )
if colorbar:
fig.colorbar( im, ax= ax)
return im
示例14: plot_smooth_xor_data_2d
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import colorbar [as 别名]
def plot_smooth_xor_data_2d(ax):
ngrid = 1000
xA = get_base_grid(ngrid)
xB = get_base_grid(ngrid)
#xAv, yBv = np.meshgrid(xA, xB)
xComb = np.array( [elem for elem in itertools.product(xA, xB)] )
y = smooth_xor(xComb)
mappable = ax.imshow(-y.reshape(ngrid,ngrid), extent = [-3.,3.,-3.,3.])
plt.colorbar(mappable)
x,not_used = make_smooth_xor_data()
ax.scatter(x[:,0],x[:,1], color='r', marker='+')
testA,testB, not_used = get_test_points()
ax.plot(testA[:250],testB[:250], 'k--')
ax.plot(testA[250:],testB[250:], 'k--')
ax.text(-2.8,0.75,'Cross-section 1', fontsize=12)
ax.text(-2.25,-2.5,'Cross-section 2', fontsize=12)
#zv = y.reshape(xA.shape[0],xB.shape[0])
#fig = plt.figure()
#ax = fig.add_subplot(111, projection='3d')
#ax.plot_wireframe(xAv, yBv, zv)
示例15: plot_alignment_to_numpy
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import colorbar [as 别名]
def plot_alignment_to_numpy(alignment, info=None):
fig, ax = plt.subplots(figsize=(6, 4))
im = ax.imshow(alignment, aspect='auto', origin='lower', interpolation='none')
fig.colorbar(im, ax=ax)
xlabel = 'Decoder timestep'
if info is not None:
xlabel += '\n\n' + info
plt.xlabel(xlabel)
plt.ylabel('Encoder timestep')
plt.tight_layout()
fig.canvas.draw()
data = save_figure_to_numpy(fig)
plt.close()
return data