本文整理汇总了Python中matplotlib.pyplot.figtext方法的典型用法代码示例。如果您正苦于以下问题:Python pyplot.figtext方法的具体用法?Python pyplot.figtext怎么用?Python pyplot.figtext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.pyplot
的用法示例。
在下文中一共展示了pyplot.figtext方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: scatter_fret_nd_na
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import figtext [as 别名]
def scatter_fret_nd_na(d, i=0, show_fit=False, no_text=False, gamma=1.,
**kwargs):
"""Scatterplot of FRET versus gamma-corrected burst size."""
default_kwargs = dict(mew=0, ms=3, alpha=0.3, color=blue)
default_kwargs.update(**kwargs)
plot(d.E[i], gamma*d.nd[i]+d.na[i], 'o', **default_kwargs)
xlabel("FRET Efficiency (E)")
ylabel("Burst size (#ph)")
if show_fit:
_fitted_E_plot(d, i, F=1., no_E=no_text, ax=gca())
if i == 0 and not no_text:
plt.figtext(0.4, 0.01, _get_fit_E_text(d), fontsize=14)
示例2: update_plot
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import figtext [as 别名]
def update_plot(self):
layers = self.get_trainable_layers()
for layer in layers:
for param in self.parameters:
weights = [w for w in layer.weights if
param in w.name.split("_")]
if len(weights) == 0:
continue
val = numpy.column_stack((w.get_value() for w in weights))
name = layer.name + "_" + param
self.layers_stats[name]["values"] = val.ravel()
for s in self.stats:
if s == "raster":
if len(val.shape) > 2:
val = val.reshape((val.shape[0], -1), order='F')
self.layers_stats[name][s] = val
# self.fig.colorbar()
else:
self.layers_stats[name][s].append(
getattr(numpy, s)(val))
plt.figtext(.02, .02, get_model_desc(self.model), wrap=True,
fontsize=8)
self.fig.tight_layout()
self.fig.subplots_adjust(bottom=.2)
self.fig.canvas.draw()
self.fig.canvas.flush_events()
示例3: _skipplot
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import figtext [as 别名]
def _skipplot(self, key):
import matplotlib.pyplot as plt
fig = plt.figure()
plt.figtext(0.5, 0.5, 'No data available.', ha='center')
fig.set_size_inches(*self.size_inches)
if self.autosave:
self.savefig(fig, key)
plt.close(fig)
fig = None
print('Skipped Plot.')
return fig
示例4: plot_frame
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import figtext [as 别名]
def plot_frame(settings, organisms, foods, gen, time):
fig, ax = plt.subplots()
fig.set_size_inches(9.6, 5.4)
plt.xlim([settings['x_min'] + settings['x_min'] * 0.25, settings['x_max'] + settings['x_max'] * 0.25])
plt.ylim([settings['y_min'] + settings['y_min'] * 0.25, settings['y_max'] + settings['y_max'] * 0.25])
# PLOT ORGANISMS
for organism in organisms:
plot_organism(organism.x, organism.y, organism.r, ax)
# PLOT FOOD PARTICLES
for food in foods:
plot_food(food.x, food.y, ax)
# MISC PLOT SETTINGS
ax.set_aspect('equal')
frame = plt.gca()
frame.axes.get_xaxis().set_ticks([])
frame.axes.get_yaxis().set_ticks([])
plt.figtext(0.025, 0.95,r'GENERATION: '+str(gen))
plt.figtext(0.025, 0.90,r'T_STEP: '+str(time))
plt.savefig(str(gen)+'-'+str(time)+'.png', dpi=100)
## plt.show()
示例5: classify_one_image
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import figtext [as 别名]
def classify_one_image(self, imgf,
classes=['afraid', 'angry', 'disgusted', 'happy', 'neutral', 'sad', 'surprised']):
normalize = transforms.Normalize(mean=[0.485, 0.456, 0.406],
std=[0.229, 0.224, 0.225])
transf = transforms.Compose([
transforms.Scale(256),
transforms.CenterCrop(224),
transforms.ToTensor(),
normalize,
])
# Face detection
args = {}
args['threshold'] = 0.0
args['window'] = False
args['ignore_multi'] = True
args['grow'] = 10
args['resize'] = True
args['row_resize'] = 512
args['col_resize'] = 512
args['min_proportion'] = 0.1
with tempfile.TemporaryDirectory() as tempdir:
args['o'] = tempdir
face_detector.transform(extract_faces.AttributeDict(args), [imgf])
cropped = Image.open(tempdir + '/' + os.path.basename(imgf))
cropped = transf(cropped)
input_var = Variable(cropped.view(1, *cropped.shape))
if torch.cuda.is_available():
input_var = input_var.cuda()
output = self.model.forward(input_var).cpu().data.numpy()
softmax = np.exp(output) / np.sum(np.exp(output))
clss = np.argmax(softmax)
fig = plt.figure()
plt.imshow(Image.open(imgf))
fig.subplots_adjust(bottom=0.2)
plt.figtext(0.1, 0.05, ', '.join(classes))
plt.figtext(0.1, 0.10, ', '.join(['{:.3}'.format(a) for a in softmax.reshape(-1)]))
plt.title(classes[clss])
plt.show()
示例6: heatmap_full
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import figtext [as 别名]
def heatmap_full(single_env, cmap="Blues", cols=None):
# Figure layout calculations
if cols is None:
cols = single_env.columns
cbar_width_in = 0.41
reserved = { # in inches
"left": 0.605, # for y-axis
"top": 0.28, # for title
"bottom": 0.49, # for x-axis
"right": cbar_width_in + 0.02, # for color bar plus margin
}
reserved_height = reserved["top"] + reserved["bottom"]
width, nominal_height = plt.rcParams.get("figure.figsize")
portion_for_heatmap = nominal_height - reserved_height
# We want height to vary depending on number of labels. Take figure size as specifying the
# height for a 'typical' figure with 6 rows.
height_per_row = nominal_height * portion_for_heatmap / 6
num_rows = len(pd.unique(single_env.index.get_level_values(0)))
height_for_heatmap = height_per_row * max(num_rows, 4)
height = reserved_height + height_for_heatmap
gridspec_kw = {
"top": 1 - reserved["top"] / height,
"bottom": reserved["bottom"] / height,
"wspace": 0.05,
"hspace": 0.05,
}
# Actually plot the heatmap
subplot_wspace = 0.05 / width
left = reserved["left"] / width
max_right = 1 - reserved["right"] / width
per_plot_width = (max_right - left) / len(cols)
single_env *= 100 / num_episodes(single_env) # convert to percentages
fig = plt.figure(figsize=(width, height))
for i, col in enumerate(cols):
right = left + per_plot_width - subplot_wspace
gridspec_kw.update({"left": left, "right": right})
cbar = i == len(cols) - 1
subplot_cbar_width = cbar_width_in / width if cbar else 0.0
_pretty_heatmap(
single_env, col, cmap, fig, gridspec_kw, cbar_width=subplot_cbar_width, yaxis=i == 0
)
if len(cols) > 1:
mid_x = (left + right - subplot_cbar_width) / 2
mid_y = (1 + gridspec_kw["top"]) / 2
plt.figtext(
mid_x, mid_y, col, va="center", ha="center", size=plt.rcParams.get("axes.titlesize")
)
left += per_plot_width
return fig
示例7: draw_plot
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import figtext [as 别名]
def draw_plot(self):
self.fig.clf()
layers = self.get_trainable_layers()
height = len(self.layers_stats)
width = len(self.stats) + 1
plot_count = 1
for layer in layers:
for param in self.parameters:
weights = [w for w in layer.weights if
param in w.name.split("_")]
if len(weights) == 0:
continue
val = numpy.column_stack((w.get_value() for w in weights))
name = layer.name + "_" + param
self.layers_stats[name]["values"] = val.ravel()
ax = self.fig.add_subplot(height, width, plot_count)
ax.hist(self.layers_stats[name]["values"], bins=50)
ax.set_title(name, fontsize=10)
ax.grid(True)
ax.tick_params(labelsize=8)
plot_count += 1
for s in self.stats:
axs = self.fig.add_subplot(height, width, plot_count)
if s == "raster":
if len(val.shape) > 2:
val = val.reshape((val.shape[0], -1), order='F')
self.layers_stats[name][s] = val
m = axs.imshow(self.layers_stats[name][s],
cmap='coolwarm',
interpolation='nearest',
aspect='auto', ) # aspect='equal'
cbar = self.fig.colorbar(mappable=m)
cbar.ax.tick_params(labelsize=8)
else:
self.layers_stats[name][s].append(
getattr(numpy, s)(val))
axs.plot(self.layers_stats[name][s])
axs.set_ylabel(s, fontsize="small")
axs.set_xlabel('epoch', fontsize="small")
axs.grid(True)
axs.set_title(name + " - " + s, fontsize=10)
axs.tick_params(labelsize=8)
plot_count += 1
# plt.figtext(.1, .1, get_model_desc(self.model), wrap=True, fontsize=8)
desc = get_model_desc(self.model)
self.fig.text(.02, .02, desc, verticalalignment='bottom', wrap=True,
fontsize=8)
self.fig.tight_layout()
self.fig.subplots_adjust(bottom=.14)
self.fig.canvas.draw()
self.fig.canvas.flush_events()