本文整理汇总了Python中matplotlib.figure.Figure.subplots_adjust方法的典型用法代码示例。如果您正苦于以下问题:Python Figure.subplots_adjust方法的具体用法?Python Figure.subplots_adjust怎么用?Python Figure.subplots_adjust使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.figure.Figure
的用法示例。
在下文中一共展示了Figure.subplots_adjust方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import subplots_adjust [as 别名]
def __init__(self, matrix, matx, maty, dominio, tipodis, X, Y, tiempos, tiemposobs, superficies, ming, maxg, selected = None, parent = None):
fig = Figure(figsize = (1.8 * 4, 2.4 * 4))
self.ax = None
self.axt = None
fig.subplots_adjust(hspace=.2, wspace=.3, bottom=.07, left=.08, right=.92, top=.94)
print "tipos q ",tiempos
print "tiempos obs ", tiemposobs
self.fig = fig
self.matrix = matrix
self.dominio=dominio
self.tipodis=tipodis
self.X=X
self.Y=Y
self.matx = matx
self.maty = maty
self.ming=ming
self.maxg=maxg
self.tiempos = tiempos
self.tiemposobs = tiemposobs
self.superficies=superficies
示例2: DevPlot
# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import subplots_adjust [as 别名]
class DevPlot(Plot):
def __init__(self,k1={'intel_snb' : ['intel_snb','intel_snb','intel_snb']},k2={'intel_snb':['LOAD_1D_ALL','INSTRUCTIONS_RETIRED','LOAD_OPS_ALL']},processes=1,**kwargs):
self.k1 = k1
self.k2 = k2
super(DevPlot,self).__init__(processes=processes,**kwargs)
def plot(self,jobid,job_data=None):
self.setup(jobid,job_data=job_data)
cpu_name = self.ts.pmc_type
type_name=self.k1[cpu_name][0]
events = self.k2[cpu_name]
ts=self.ts
n_events = len(events)
self.fig = Figure(figsize=(8,n_events*2+3),dpi=110)
do_rate = True
scale = 1.0
if type_name == 'mem':
do_rate = False
scale=2.0**10
if type_name == 'cpu':
scale=ts.wayness*100.0
for i in range(n_events):
self.ax = self.fig.add_subplot(n_events,1,i+1)
self.plot_lines(self.ax, [i], 3600., yscale=scale, do_rate = do_rate)
self.ax.set_ylabel(events[i],size='small')
self.ax.set_xlabel("Time (hr)")
self.fig.subplots_adjust(hspace=0.5)
#self.fig.tight_layout()
self.output('devices')
示例3: configure_subplots
# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import subplots_adjust [as 别名]
def configure_subplots(self, button):
toolfig = Figure(figsize=(6, 3))
canvas = self._get_canvas(toolfig)
toolfig.subplots_adjust(top=0.9)
tool = SubplotTool(self.canvas.figure, toolfig)
w = int(toolfig.bbox.width)
h = int(toolfig.bbox.height)
window = Gtk.Window()
try:
window.set_icon_from_file(window_icon)
except Exception:
# we presumably already logged a message on the
# failure of the main plot, don't keep reporting
pass
window.set_title("Subplot Configuration Tool")
window.set_default_size(w, h)
vbox = Gtk.Box()
vbox.set_property("orientation", Gtk.Orientation.VERTICAL)
window.add(vbox)
vbox.show()
canvas.show()
vbox.pack_start(canvas, True, True, 0)
window.show()
示例4: run
# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import subplots_adjust [as 别名]
def run(self, postResults):
#create tree with relevant datas
source = sortTree(postResults, ['modules', 'controller', 'type'])
#create plot
fig = Figure()
fig.subplots_adjust(wspace=0.5, hspace=0.25)
#plot for L1NormAbs
axes = fig.add_subplot(111)
self.plotVariousController(source, axes,\
xPath=['modules', 'disturbance', 'sigma'],\
yPath=['metrics', 'L1NormAbs'],\
typ='line')
self.plotSettings(axes,\
titel=r'Fehlerintegral w(t) und y(t) \"uber Sigma',\
grid=True,\
xlabel=r'$\sigma \, \lbrack m\rbrack$',\
ylabel=r'$E \, \lbrack ms \rbrack$',\
)
#extract controllerNames
controllerNames = [x[:-len('Controller')] for x in source.keys()]
canvas = FigureCanvas(fig)
#write output files
fileName = self.name[len('eval_'):]\
+ '_Controller_(' + ''.join(controllerNames) + ')'
self.writeOutputFiles(fileName, fig)
return [{'figure': canvas, 'name': self.name}]
示例5: save_plotSpectrum
# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import subplots_adjust [as 别名]
def save_plotSpectrum(y,Fs,image_name):
"""
Plots a Single-Sided Amplitude Spectrum of y(t)
"""
fig = Figure(linewidth=0.0)
fig.set_size_inches(fig_width,fig_length, forward=True)
Figure.subplots_adjust(fig, left = fig_left, right = fig_right, bottom = fig_bottom, top = fig_top, hspace = fig_hspace)
n = len(y) # length of the signal
_subplot = fig.add_subplot(2,1,1)
print "Fi"
_subplot.plot(arange(0,n),y)
xlabel('Time')
ylabel('Amplitude')
_subploti_2=fig.add_subplot(2,1,2)
k = arange(n)
T = n/Fs
frq = k/T # two sides frequency range
frq = frq[range(n/2)] # one side frequency range
Y = fft(y)/n # fft computing and normalization
Y = Y[range(n/2)]
_subplot_2.plot(frq,abs(Y),'r') # plotting the spectrum
xlabel('Freq (Hz)')
ylabel('|Y(freq)|')
print "here"
canvas = FigureCanvasAgg(fig)
if '.eps' in outfile_name:
canvas.print_eps(outfile_name, dpi = 110)
if '.png' in outfile_name:
canvas.print_figure(outfile_name, dpi = 110)
示例6: matrix_figure
# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import subplots_adjust [as 别名]
def matrix_figure(N1=160, N2=32):
r=0.4
fsx=20.
fsy=fsx*N2/N1
f=Figure(figsize=(fsx,fsy),frameon=False)
#f=plt.figure(figsize=(fsx,fsy),frameon=False)
ax=f.add_subplot(111,axisbg='k')
ax.set_xlim([-2*r,N1-1+2*r])
ax.set_ylim([-2*r,N2-1+2*r])
ax.set_axis_bgcolor('k')
ax.set_yticks([])
ax.set_xticks([])
ax.set_frame_on(False)
x=np.arange(N1)
y=np.arange(N2)
xx,yy=np.meshgrid(x,y)
cmap = col.ListedColormap([ '#6E6E6E','#FE2E2E', '#64FE2E', '#FF8000'])
colors=np.random.randint(0,4,(N1,N2))
patches = []
for x1,y1 in zip(xx.flatten(), yy.flatten()):
circle = Circle((x1,y1), r)
patches.append(circle)
p = PatchCollection(patches, cmap=cmap)
p.set_array(colors.flatten())
ax.add_collection(p)
f.subplots_adjust(0,0,1,1)
return ax, colors
示例7: MplCanvas
# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import subplots_adjust [as 别名]
class MplCanvas(FigureCanvas):
def __init__(self):
self.fig = Figure()
self.fig.patch.set_facecolor('white')
self.ax = self.fig.add_subplot(111)
#self.ax.set_frame_on(False)
self.ax.axes.get_yaxis().set_visible(False)
self.ax.get_xaxis().tick_bottom()
self.ax.autoscale(enable = True, axis='y', tight= True)
self.ax.autoscale(enable = False, axis='x', tight= True)
self.fig.subplots_adjust(0.005,0.2,0.995,1,0,0)
self.xdata = 0
#self.ax.spines['right'].set_color('none')
#self.ax.spines['top'].set_color('none')
#self.ax.spines['left'].set_color('none')
FigureCanvas.__init__(self, self.fig)
FigureCanvas.setSizePolicy(self, QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Expanding)
FigureCanvas.updateGeometry(self)
def mousePressEvent(self, event):
inv = self.ax.transData.inverted()
self.xdata = int(inv.transform((event.x(),event.y()))[0])
self.emit(QtCore.SIGNAL('chartClicked'))
示例8: processOne
# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import subplots_adjust [as 别名]
def processOne(fn,done,gpus,telescope,outdir,plotdir,redo=False):
print fn
info = decodeFilename(fn)
print info
pklname = ('ds_%s_%s_%s_%s.pkl' % (info['source'],info['mjd'],
info['scan'],telescope))
outfn = os.path.join(outdir,'pkls',pklname)
if (not redo) and (outfn in done):
return fn,None,pklname
try:
#if True:
ds = loadDynSpecFromCycSpecScan(int(info['scan']), int(info['mjd']),
gpus=gpus, telescope=telescope)
print "loaded dynspec"
dynspec.pickle(outfn, ds)
print "pickled",outfn
fig = Figure(figsize=(10,12))
fig.subplots_adjust(left=0.09,bottom=0.05,top=0.95,right=0.95)
ds.plot(fig=fig)
plotname = os.path.join(plotdir,pklname + '.png')
esc_fname = outfn.replace('_',r'\_')
fig.suptitle(('%s @ %s %s' % (info['source'],telescope,esc_fname)),size='medium')
canvas = FigureCanvasAgg(fig)
canvas.print_figure(plotname)
except Exception,e:
print fn,e,pklname
return fn,e,pklname
示例9: _diffHist
# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import subplots_adjust [as 别名]
def _diffHist(pixels, mean, clippedMedian, sigma, upperKey, lowerKey,
plotPath):
fig = Figure(figsize=(6, 6))
canvas = FigureCanvas(fig)
fig.subplots_adjust(left=0.15, bottom=0.13, wspace=0.25, hspace=0.25,
right=0.95)
ax = fig.add_subplot(111)
nPixels = len(pixels)
# Plot histogram
nCounts, bins, patches = ax.hist(pixels,
bins=int(nPixels / 1000),
histtype='stepfilled', fc='0.5',
log=True, normed=True)
# Plot estimates of the image difference
ax.axvline(mean, ls="-", c='k', label="mean")
ax.axvline(clippedMedian, ls='--', c='k', label="clipped median")
# ax.axvline(fittedMean, ls='--', c='r', label="fitted mean")
ax.legend()
ax.text(0.05, 0.95,
r"Clipped $\Delta= %.2e \pm %.2e$" % (clippedMedian, sigma),
ha="left", va="top", transform=ax.transAxes)
ax.set_xlabel("Image Difference (counts)")
upperKey = upperKey.replace("_", "\_")
lowerKey = lowerKey.replace("_", "\_")
ax.set_title("%s - %s" % (upperKey, lowerKey))
canvas.print_figure(plotPath)
示例10: plot_vo
# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import subplots_adjust [as 别名]
def plot_vo(tri, colors=None):
import matplotlib as mpl
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
from matplotlib.figure import Figure
fig = Figure(figsize=(4,4))
canvas = FigureCanvas(fig)
fig.subplots_adjust(left=0.15, bottom=0.13,wspace=0.25, right=0.95)
ax = fig.add_subplot(111, aspect='equal')
if colors is None:
colors = [(0,1,0,0.2)]
#lc = mpl.collections.LineCollection(numpy.array(
# [(tri.circumcenters[i], tri.circumcenters[j])
# for i in xrange(len(tri.circumcenters))
# for j in tri.triangle_neighbors[i] if j != -1]),
# colors=colors)
lines = [(tri.circumcenters[i], tri.circumcenters[j])
for i in xrange(len(tri.circumcenters))
for j in tri.triangle_neighbors[i] if j != -1]
lines = numpy.array(lines)
lc = mpl.collections.LineCollection(lines, colors=colors)
# ax = pl.gca()
ax.add_collection(lc)
# pl.draw()
# pl.savefig("voronoi")
ax.plot(tri.x, tri.y, '.k')
ax.set_xlim(-50,550)
ax.set_ylim(-50,550)
canvas.print_figure("voronoi", dpi=300.)
示例11: __init__
# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import subplots_adjust [as 别名]
def __init__(self, parent=None, width=5, height=4, dpi=100):
fig = Figure(figsize=(width, height), dpi=dpi)
self.axes = fig.add_subplot(111)
self.axes.hold(False)
super(GraphWidget, self).__init__(fig)
self.setParent(parent)
fig.subplots_adjust(bottom=0.2)
FigureCanvas.setSizePolicy(self,
QtGui.QSizePolicy.Expanding,
QtGui.QSizePolicy.Expanding)
FigureCanvas.updateGeometry(self)
self.below_absolute_value = 0.0
self.below_absolute_enabled = False
self.above_absolute_value = 0.0
self.above_absolute_enabled = False
self.delayed_plot_timer = QtCore.QTimer()
self.delayed_plot_timer.setSingleShot(True)
self.delayed_plot_timer.timeout.connect(self.plot)
self.readPlotData()
self.plot()
示例12: plot_alpha_parameters
# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import subplots_adjust [as 别名]
def plot_alpha_parameters(pdict, outinfo):
from matplotlib.figure import Figure
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigCanvas
pars = []
parlist, div_idxs = _sort_alpha(pdict)
# in some fits we don't include systematics, don't draw anything
if not parlist:
return
xlab, xpos, ypos, yerr = _get_lab_x_y_err(parlist)
fig = Figure(figsize=(8, 4))
fig.subplots_adjust(bottom=0.2)
canvas = FigCanvas(fig)
ax = fig.add_subplot(1,1,1)
ax.set_xlim(0, len(xlab))
ax.set_ylim(-2.5, 2.5)
ax.errorbar(
xpos, ypos, yerr=yerr, **_eb_style)
ax.axhline(0, **_hline_style)
for hline in div_idxs:
ax.axvline(hline, **_hline_style)
ax.set_xticks(xpos)
ax.set_xticklabels(xlab)
ax.tick_params(labelsize=_txt_size)
for lab in ax.get_xticklabels():
lab.set_rotation(60 if len(xlab) < 10 else 90)
outdir = outinfo['outdir']
fig.tight_layout(pad=0.3, h_pad=0.3, w_pad=0.3)
canvas.print_figure(
join(outdir, 'alpha' + outinfo['ext']), bboxinches='tight')
示例13: plot_loads_devs
# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import subplots_adjust [as 别名]
def plot_loads_devs(response, start, alldata, allmeans, meandates, maxload, notesets):
fig = Figure(figsize=(12,8), dpi=72)
rect = fig.patch
rect.set_facecolor('white')
canvas = FigureCanvas(fig)
ax = fig.add_subplot(111)
colorlist = ['b', 'g', 'r', 'y', 'c']
plts = []
labels = []
colorlist_count = 0
for dev in alldata.keys():
labels.append(dev)
plt = ax.plot(alldata[dev]['dates'], alldata[dev]['loads'], colorlist[colorlist_count] + 'x')[0]
plts.append(plt)
colorlist_count += 1
ax.plot(meandates, allmeans, 'ks')
for i in range(len(meandates)):
outstr = "%.03f ug/cm^2\n" % (allmeans[i])
for j in notesets[i]:
outstr += j + "\n"
ax.text(meandates[i], allmeans[i], outstr)
ax.set_ylabel('$ug/cm^2$')
ax.set_xlabel('Image Record Time (from EXIF)')
ax.set_title("%s" % (str(start)))
fig.autofmt_xdate()
ax.legend(plts, labels, numpoints=1, loc='lower right')
fig.subplots_adjust(left=0.07, bottom=0.10, right=0.91, \
top=0.95, wspace=0.20, hspace=0.00)
canvas.print_png(response)
示例14: On_Double
# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import subplots_adjust [as 别名]
def On_Double(self, event):
"""Finds best fit with selection and returns a pyplot graph."""
widget = event.widget
selection = widget.curselection()
choice = widget.get(selection[0])
base_data = pd.read_csv(PATH+choice+'.csv', index_col='Year')
base_index = base_data.columns[0]
best_fit, r2 = find_best_correlation(data_frame, base_index)
fig = Figure(figsize=(6, 4), dpi=100)
#Axis of original data set
ax1 = fig.add_subplot(111)
ax1.plot(data_frame.index, data_frame[base_index], color='r')
ax1.set_ylabel(base_index)
ax1.annotate(r'$ r ^ 2$ = %s' % r2, xy=(0.05, 0.9),\
xycoords='axes fraction', size='large')
#Axis of best fit
ax2 = ax1.twinx()
ax2.plot(data_frame.index, data_frame[best_fit], color='k')
ax2.set_ylabel(best_fit)
fig.subplots_adjust(left=0.2, top=0.85, right=0.8, bottom=0.15)
canvas = FigureCanvasTkAgg(fig, self)
canvas.show()
canvas.get_tk_widget().grid(row=1, column=2, ipady=10, ipadx=10)
示例15: MplCanvas
# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import subplots_adjust [as 别名]
class MplCanvas(FigureCanvas):
def __init__(self, figsize=(8, 6), dpi=80):
self.fig = Figure(figsize=figsize, dpi=dpi)
self.fig.subplots_adjust(wspace=0, hspace=0, left=0, right=1.0, top=1.0, bottom=0)
self.ax = self.fig.add_subplot(111, frameon=False)
self.ax.patch.set_visible(False)
self.ax.set_axis_off()
FigureCanvas.__init__(self, self.fig)
FigureCanvas.setSizePolicy(self, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
FigureCanvas.updateGeometry(self)
#self.setAlpha(0.0)
def saveFig(self, str_io_buf):
self.setAlpha(0.0)
self.fig.savefig(str_io_buf, transparent=True, frameon=False, format='png')
# 140818 Save file to StringIO Buffer not disk file
def getFig(self):
return self.fig
def setAlpha(self, value):
self.fig.patch.set_alpha(value)
self.ax.patch.set_alpha(value)
self.ax.set_axis_off()
def set_face_color(self, color):
self.fig.set_facecolor(color) # "#000000"