本文整理汇总了Python中matplotlib.backends.backend_agg.FigureCanvasAgg.set_window_title方法的典型用法代码示例。如果您正苦于以下问题:Python FigureCanvasAgg.set_window_title方法的具体用法?Python FigureCanvasAgg.set_window_title怎么用?Python FigureCanvasAgg.set_window_title使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.backends.backend_agg.FigureCanvasAgg
的用法示例。
在下文中一共展示了FigureCanvasAgg.set_window_title方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: plot
# 需要导入模块: from matplotlib.backends.backend_agg import FigureCanvasAgg [as 别名]
# 或者: from matplotlib.backends.backend_agg.FigureCanvasAgg import set_window_title [as 别名]
def plot(self, title, scol, logT=False, ylim=False, pw=3, ph=4):
""" Return boxplot from the given tables.
"""
self.xtickrotation, self.xtickalign = 0, "center"
if len(self.group_tags) < 2:
ticklabelsize = pw * 1.5
else:
ticklabelsize = pw * 6
tw = len(self.group_tags) * pw
th = ph
f, axarr = plt.subplots(1, len(self.group_tags), dpi=300, sharey=scol,
figsize=(tw, th))
# f, axarr = plt.subplots(1, len(self.group_tags), dpi=300, sharey = scol)
# nm = len(self.group_tags) * len(self.color_tags) * len(self.sort_tags)
# if nm > 30:
# f.set_size_inches(nm * 0.25 ,nm * 0.15)
# legend_x = 1.2
# self.xtickrotation, self.xtickalign = 70,"right"
canvas = FigureCanvas(f)
canvas.set_window_title(title)
try:
axarr = axarr.reshape(-1)
except:
axarr = [axarr]
# plt.subplots_adjust(bottom=0.3)
if logT:
if self.df:
axarr[0].set_ylabel("Read number difference (log)",
fontsize=ticklabelsize + 1)
else:
axarr[0].set_ylabel("Read number (log)", fontsize=ticklabelsize + 1)
else:
if self.df:
axarr[0].set_ylabel("Read number difference", fontsize=ticklabelsize + 1)
else:
axarr[0].set_ylabel("Read number", fontsize=ticklabelsize + 1)
for i, g in enumerate(self.sortDict.keys()):
# if self.df:
# axarr[i].set_title(g + "_df", y=1.02, fontsize=ticklabelsize + 2)
# else:
axarr[i].set_title(g, y=1.02, fontsize=ticklabelsize + 2)
if logT and not self.df:
axarr[i].set_yscale('log')
else:
axarr[i].locator_params(axis='y', nbins=4)
axarr[i].tick_params(axis='y', direction='out')
axarr[i].yaxis.tick_left()
axarr[i].yaxis.grid(True, linestyle='-', which='major', color='lightgrey', alpha=0.7, zorder=1)
if ylim:
axarr[i].set_ylim([-ylim, ylim])
d = [] # Store data within group
color_t = [] # Store tag for coloring boxes
x_ticklabels = [] # Store ticklabels
for j, a in enumerate(self.sortDict[g].keys()):
# if len(a) > 10:
# print(a)
self.xtickrotation = 70
self.xtickalign = "right"
for k, c in enumerate(self.sortDict[g][a].keys()):
if not numpy.any(self.sortDict[g][a][c]): # When there is no matching data, skip it
continue
else:
if self.df:
d.append(self.sortDict[g][a][c])
else:
d.append([x + 1 for x in self.sortDict[g][a][c]])
color_t.append(self.colors[k])
x_ticklabels.append(a) # + "." + c
# Fine tuning boxplot
# print(d)
bp = axarr[i].boxplot(d, notch=False, sym='o', vert=True, whis=1.5, positions=None,
widths=None, patch_artist=True, bootstrap=None)
z = 10 # zorder for boxplot
plt.setp(bp['whiskers'], color='black', linestyle='-', linewidth=0.8, zorder=z)
plt.setp(bp['fliers'], markerfacecolor='gray', color='white', alpha=0.3, markersize=1.8, zorder=z)
plt.setp(bp['caps'], color='white', zorder=z)
plt.setp(bp['medians'], color='black', linewidth=1.5, zorder=z + 1)
legends = []
for patch, color in zip(bp['boxes'], color_t):
patch.set_facecolor(color) # When missing the data, the color patch will exceeds
patch.set_edgecolor("none")
patch.set_zorder(z)
legends.append(patch)
# Fine tuning subplot
axarr[i].set_xticks([len(self.color_tags) * n + 1 + (len(self.color_tags) - 1) / 2 for n, s in
enumerate(self.sortDict[g].keys())])
# plt.xticks(xlocations, sort_tags, rotation=90, fontsize=10)
axarr[i].set_xticklabels(self.sortDict[g].keys(), rotation=self.xtickrotation,
ha=self.xtickalign)
# axarr[i].set_xticklabels(self.sortDict[g].keys(), rotation=70, ha=self.xtickalign, fontsize=10)
#.........这里部分代码省略.........