本文整理汇总了Python中matplotlib.figure.Figure.set_figheight方法的典型用法代码示例。如果您正苦于以下问题:Python Figure.set_figheight方法的具体用法?Python Figure.set_figheight怎么用?Python Figure.set_figheight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.figure.Figure
的用法示例。
在下文中一共展示了Figure.set_figheight方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: reports_pie
# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import set_figheight [as 别名]
def reports_pie(request,scope):
month, year, late , dates_gc = current_reporting_period()
period = (dates_gc[0],dates_gc[1])
completed = len(scope.current_entries())
incomplete = len(scope.health_posts()) - len(scope.current_entries())
fig = Figure()
ax=fig.add_subplot(111, axisbg='r')
fig.set_figheight(2)
fig.set_figwidth(2)
fig.set_facecolor('w')
labels = 'Completed', 'Incomlete'
fracs = [completed,incomplete]
explode=(0,0.01)
pie(fracs, explode=explode, labels=None,colors=('g','r'), autopct='%1.1f%%', shadow=True)
title('Reports..', bbox={'facecolor':'0.5', 'pad':5})
ax.pie(fracs, explode=explode, labels=None,colors=('#52E060','#F7976E'), shadow=True)
canvas=FigureCanvas(fig)
response=HttpResponse(content_type='image/png')
canvas.print_png(response)
return response
示例2: tricontouring_response
# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import set_figheight [as 别名]
def tricontouring_response(tri_subset, data, request, dpi=None):
"""
triang_subset is a matplotlib.Tri object in lat/lon units (will be converted to projected coordinates)
xmin, ymin, xmax, ymax is the bounding pox of the plot in PROJETED COORDINATES!!!
request is the original getMap request object
"""
dpi = dpi or 80.
bbox = request.GET['bbox']
width = request.GET['width']
height = request.GET['height']
colormap = request.GET['colormap']
colorscalerange = request.GET['colorscalerange']
cmin = colorscalerange.min
cmax = colorscalerange.max
crs = request.GET['crs']
nlvls = request.GET['numcontours']
EPSG4326 = pyproj.Proj(init='EPSG:4326')
tri_subset.x, tri_subset.y = pyproj.transform(EPSG4326, crs, tri_subset.x, tri_subset.y)
fig = Figure(dpi=dpi, facecolor='none', edgecolor='none')
fig.set_alpha(0)
fig.set_figheight(height/dpi)
fig.set_figwidth(width/dpi)
ax = fig.add_axes([0., 0., 1., 1.], xticks=[], yticks=[])
ax.set_axis_off()
if request.GET['logscale'] is True:
norm_func = mpl.colors.LogNorm
else:
norm_func = mpl.colors.Normalize
# Set out of bound data to NaN so it shows transparent?
# Set to black like ncWMS?
# Configurable by user?
if cmin is not None and cmax is not None:
lvls = np.linspace(cmin, cmax, nlvls)
norm = norm_func(vmin=cmin, vmax=cmax, clip=True)
else:
lvls = nlvls
norm = norm_func()
if request.GET['image_type'] == 'filledcontours':
ax.tricontourf(tri_subset, data, lvls, norm=norm, cmap=colormap, extend='both')
elif request.GET['image_type'] == 'contours':
ax.tricontour(tri_subset, data, lvls, norm=norm, cmap=colormap, extend='both')
ax.set_xlim(bbox.minx, bbox.maxx)
ax.set_ylim(bbox.miny, bbox.maxy)
ax.set_frame_on(False)
ax.set_clip_on(False)
ax.set_position([0., 0., 1., 1.])
canvas = FigureCanvasAgg(fig)
response = HttpResponse(content_type='image/png')
canvas.print_png(response)
return response
示例3: buildMetadataImage
# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import set_figheight [as 别名]
def buildMetadataImage(self, layerInfoList, width):
"""
Creates the metadata caption for figures in styles that display a title only.
"""
# Find first non-outline layer.
nonOutlineLayers = [l for l in layerInfoList if l.id != outline_layer.OUTLINE_LAYER_ID]
layerInfo = nonOutlineLayers[0] if len(nonOutlineLayers) > 0 else None
# Get the title of the first set of keyword data, i.e., that for the layer rather than one
# of its antecedent layers or datasets.
titleText = ''
if layerInfo and (len(layerInfo.keywordData) > 0):
titleText = layerInfo.keywordData[0].get('title', '')
height = 500
dpi = 100
transparent = False
figsize = (width / float(dpi), height / float(dpi))
fig = Figure(figsize=figsize, dpi=dpi, facecolor='w', frameon=(not transparent))
renderer = Renderer(fig.dpi)
text = fig.text(0.5, 0.98, titleText,
fontdict=titleFont,
horizontalalignment='center',
verticalalignment='top')
# Trim the height of the text image.
extent = text.get_window_extent(renderer)
textHeight = (extent.y1 - extent.y0 + 8)
fig.set_figheight(textHeight / float(dpi))
return image_util.figureToImage(fig)
示例4: quiver_response
# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import set_figheight [as 别名]
def quiver_response(lon, lat, dx, dy, request, dpi=None):
dpi = dpi or 80.
bbox = request.GET['bbox']
width = request.GET['width']
height = request.GET['height']
colormap = request.GET['colormap']
colorscalerange = request.GET['colorscalerange']
vectorscale = request.GET['vectorscale']
cmin = colorscalerange.min
cmax = colorscalerange.max
crs = request.GET['crs']
unit_vectors = None # We don't support requesting these yet, but wouldn't be hard
EPSG4326 = pyproj.Proj(init='EPSG:4326')
x, y = pyproj.transform(EPSG4326, crs, lon, lat) # TODO order for non-inverse?
fig = Figure(dpi=dpi, facecolor='none', edgecolor='none')
fig.set_alpha(0)
fig.set_figheight(height/dpi)
fig.set_figwidth(width/dpi)
ax = fig.add_axes([0., 0., 1., 1.], xticks=[], yticks=[])
ax.set_axis_off()
mags = np.sqrt(dx**2 + dy**2)
cmap = mpl.cm.get_cmap(colormap)
if request.GET['logscale'] is True:
norm_func = mpl.colors.LogNorm
else:
norm_func = mpl.colors.Normalize
# Set out of bound data to NaN so it shows transparent?
# Set to black like ncWMS?
# Configurable by user?
if cmin is not None and cmax is not None:
mags[mags > cmax] = cmax
mags[mags < cmin] = cmin
norm = norm_func(vmin=cmin, vmax=cmax)
else:
norm = norm_func()
# plot unit vectors
if unit_vectors:
ax.quiver(x, y, dx/mags, dy/mags, mags, cmap=cmap, norm=norm, scale=vectorscale)
else:
ax.quiver(x, y, dx, dy, mags, cmap=cmap, norm=norm, scale=vectorscale)
ax.set_xlim(bbox.minx, bbox.maxx)
ax.set_ylim(bbox.miny, bbox.maxy)
ax.set_frame_on(False)
ax.set_clip_on(False)
ax.set_position([0., 0., 1., 1.])
canvas = FigureCanvasAgg(fig)
response = HttpResponse(content_type='image/png')
canvas.print_png(response)
return response
示例5: buildMetadataImage
# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import set_figheight [as 别名]
def buildMetadataImage(self, layerInfoList, width):
"""
Creates the metadata caption for figures in the style used by WMSViz.
"""
self.metadataItems = self._buildMetadataItems(layerInfoList)
self.width = width
width=self.width;height=1600;dpi=100;transparent=False
figsize=(width / float(dpi), height / float(dpi))
fig = Figure(figsize=figsize, dpi=dpi, facecolor='w', frameon=(not transparent))
axes = fig.add_axes([0.04, 0.04, 0.92, 0.92], frameon=True,xticks=[], yticks=[])
renderer = Renderer(fig.dpi)
title, titleHeight = self._drawTitleToAxes(axes, renderer)
txt, textHeight = self._drawMetadataTextToAxes(axes, renderer, self.metadataItems)
# fit the axis round the text
pos = axes.get_position()
newpos = Bbox( [[pos.x0, pos.y1 - (titleHeight + textHeight) / height], [pos.x1, pos.y1]] )
axes.set_position(newpos )
# position the text below the title
newAxisHeight = (newpos.y1 - newpos.y0) * height
txt.set_position( (0.02, 0.98 - (titleHeight/newAxisHeight) ))
for loc, spine in axes.spines.iteritems():
spine.set_edgecolor(borderColor)
# Draw heading box
headingBoxHeight = titleHeight - 1
axes.add_patch(Rectangle((0, 1.0 - (headingBoxHeight/newAxisHeight)), 1, (headingBoxHeight/newAxisHeight),
facecolor=borderColor,
fill = True,
linewidth=0))
# reduce the figure height
originalHeight = fig.get_figheight()
pos = axes.get_position()
topBound = 20 / float(dpi)
textHeight = (pos.y1 - pos.y0) * originalHeight
newHeight = topBound * 2 + textHeight
# work out the new proportions for the figure
border = topBound / float(newHeight)
newpos = Bbox( [[pos.x0, border], [pos.x1, 1 - border]] )
axes.set_position(newpos )
fig.set_figheight(newHeight)
return image_util.figureToImage(fig)
示例6: save_plot
# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import set_figheight [as 别名]
def save_plot(fname, plot_name, plot):
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
from matplotlib.figure import Figure
from matplotlib.dates import DateFormatter
fig = Figure()
ax = fig.add_subplot(111)
ax.xaxis.set_major_formatter(DateFormatter('%H:%M'))
ax.set_xlabel("Time")
ax.set_ylabel(plot_name)
fig.set_figheight(20)
fig.set_figwidth(30)
fig.autofmt_xdate()
handles = []
labels = []
for graph in plot:
x, y = plot[graph]
handles.append(ax.plot(x, y))
labels.append(graph)
fig.legend(handles, labels, 1, shadow=True)
canvas = FigureCanvas(fig)
canvas.print_figure(fname, dpi=80)
示例7: getImage
# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import set_figheight [as 别名]
def getImage(self):
figure = Figure()
axes = figure.add_subplot(111)
yAxes = self.signal_read()
xAxes = [1]
aux = 1
for x in range (0, len(yAxes)-1):
aux += 1.0/self.sampleRate
xAxes.append(aux)
axes.plot(xAxes, yAxes)
canvas = FigureCanvas(figure)
figure.set_figwidth(6)
figure.set_figheight(2)
figure.savefig(self.fileImage)
fig = QLabel()
fig.setPixmap(QPixmap(self.fileImage))
fig.setFixedSize(600, 200)
return fig
示例8: quiver_response
# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import set_figheight [as 别名]
def quiver_response(lon,
lat,
dx,
dy,
request,
vectorscale,
unit_vectors=False,
dpi=80):
bbox = request.GET['bbox']
width = request.GET['width']
height = request.GET['height']
colormap = request.GET['colormap']
colorscalerange = request.GET['colorscalerange']
cmin = colorscalerange.min
cmax = colorscalerange.max
crs = request.GET['crs']
EPSG4326 = pyproj.Proj(init='EPSG:4326')
x, y = pyproj.transform(EPSG4326, crs, lon, lat) # TODO order for non-inverse?
fig = Figure(dpi=dpi, facecolor='none', edgecolor='none')
fig.set_alpha(0)
fig.set_figheight(height/dpi)
fig.set_figwidth(width/dpi)
ax = fig.add_axes([0., 0., 1., 1.], xticks=[], yticks=[])
ax.set_axis_off()
mags = np.sqrt(dx**2 + dy**2)
cmap = mpl.cm.get_cmap(colormap)
# Set out of bound data to NaN so it shows transparent?
# Set to black like ncWMS?
# Configurable by user?
norm = None
if cmin is not None and cmax is not None:
mags[mags > cmax] = cmax
mags[mags < cmin] = cmin
bounds = np.linspace(cmin, cmax, 15)
norm = mpl.colors.BoundaryNorm(bounds, cmap.N)
# plot unit vectors
if unit_vectors:
ax.quiver(x, y, dx/mags, dy/mags, mags, cmap=cmap, scale=vectorscale)
else:
ax.quiver(x, y, dx, dy, mags, cmap=cmap, norm=norm, scale=vectorscale)
ax.set_xlim(bbox.minx, bbox.maxx)
ax.set_ylim(bbox.miny, bbox.maxy)
ax.set_frame_on(False)
ax.set_clip_on(False)
ax.set_position([0., 0., 1., 1.])
canvas = FigureCanvasAgg(fig)
response = HttpResponse(content_type='image/png')
canvas.print_png(response)
return response
示例9: contouring_response
# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import set_figheight [as 别名]
def contouring_response(lon, lat, data, request, dpi=None):
dpi = dpi or 80.
bbox, width, height, colormap, cmin, cmax, crs = _get_common_params(request)
nlvls = request.GET['numcontours']
EPSG4326 = pyproj.Proj(init='EPSG:4326')
x, y = pyproj.transform(EPSG4326, crs, lon, lat)
fig = Figure(dpi=dpi, facecolor='none', edgecolor='none')
fig.set_alpha(0)
fig.set_figheight(height/dpi)
fig.set_figwidth(width/dpi)
ax = fig.add_axes([0., 0., 1., 1.], xticks=[], yticks=[])
ax.set_axis_off()
if request.GET['logscale'] is True:
norm_func = mpl.colors.LogNorm
else:
norm_func = mpl.colors.Normalize
if cmin is not None and cmax is not None:
data[data > cmax] = cmax
data[data < cmin] = cmin
lvls = np.linspace(cmin, cmax, nlvls)
norm = norm_func(vmin=cmin, vmax=cmax)
else:
lvls = nlvls
norm = norm_func()
if request.GET['image_type'] == 'filledcontours':
ax.contourf(x, y, data, lvls, norm=norm, cmap=colormap)
elif request.GET['image_type'] == 'contours':
ax.contour(x, y, data, lvls, norm=norm, cmap=colormap)
elif request.GET['image_type'] == 'filledhatches':
hatches = DEFAULT_HATCHES[:lvls]
ax.contourf(x, y, data, lvls, norm=norm, cmap=colormap, hatches=hatches)
elif request.GET['image_type'] == 'hatches':
hatches = DEFAULT_HATCHES[:lvls]
ax.contourf(x, y, data, lvls, norm=norm, colors='none', hatches=hatches)
ax.set_xlim(bbox.minx, bbox.maxx)
ax.set_ylim(bbox.miny, bbox.maxy)
ax.set_frame_on(False)
ax.set_clip_on(False)
ax.set_position([0., 0., 1., 1.])
canvas = FigureCanvasAgg(fig)
response = HttpResponse(content_type='image/png')
canvas.print_png(response)
return response
示例10: tricontourf_response
# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import set_figheight [as 别名]
def tricontourf_response(tri_subset,
data,
request,
dpi=80.0,
nlvls=15):
"""
triang_subset is a matplotlib.Tri object in lat/lon units (will be converted to projected coordinates)
xmin, ymin, xmax, ymax is the bounding pox of the plot in PROJETED COORDINATES!!!
request is the original getMap request object
"""
bbox = request.GET['bbox']
width = request.GET['width']
height = request.GET['height']
colormap = request.GET['colormap']
colorscalerange = request.GET['colorscalerange']
cmin = colorscalerange.min
cmax = colorscalerange.max
crs = request.GET['crs']
EPSG4326 = pyproj.Proj(init='EPSG:4326')
tri_subset.x, tri_subset.y = pyproj.transform(EPSG4326, crs, tri_subset.x, tri_subset.y)
fig = Figure(dpi=dpi, facecolor='none', edgecolor='none')
fig.set_alpha(0)
fig.set_figheight(height/dpi)
fig.set_figwidth(width/dpi)
ax = fig.add_axes([0., 0., 1., 1.], xticks=[], yticks=[])
ax.set_axis_off()
# Set out of bound data to NaN so it shows transparent?
# Set to black like ncWMS?
# Configurable by user?
if cmin and cmax:
data[data > cmax] = cmax
data[data < cmin] = cmin
lvls = np.linspace(float(cmin), float(cmax), int(nlvls))
ax.tricontourf(tri_subset, data, levels=lvls, cmap=colormap)
else:
ax.tricontourf(tri_subset, data, cmap=colormap)
ax.set_xlim(bbox.minx, bbox.maxx)
ax.set_ylim(bbox.miny, bbox.maxy)
ax.set_frame_on(False)
ax.set_clip_on(False)
ax.set_position([0., 0., 1., 1.])
canvas = FigureCanvasAgg(fig)
response = HttpResponse(content_type='image/png')
canvas.print_png(response)
return response
示例11: create_projected_fig
# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import set_figheight [as 别名]
def create_projected_fig(lonmin, latmin, lonmax, latmax, projection, height, width):
from mpl_toolkits.basemap import Basemap
from matplotlib.figure import Figure
fig = Figure(dpi=80, facecolor='none', edgecolor='none')
fig.set_alpha(0)
fig.set_figheight(height)
fig.set_figwidth(width)
m = Basemap(llcrnrlon=lonmin, llcrnrlat=latmin,
urcrnrlon=lonmax, urcrnrlat=latmax, projection=projection,
resolution=None,
lat_ts = 0.0,
suppress_ticks=True)
m.ax = fig.add_axes([0, 0, 1, 1], xticks=[], yticks=[])
return fig, m
示例12: contourf_response
# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import set_figheight [as 别名]
def contourf_response(lon,
lat,
data,
request,
dpi=80,
nlvls = 15):
xmin, ymin, xmax, ymax = wms_handler.get_bbox(request)
width, height = wms_handler.get_width_height(request)
colormap = wms_handler.get_colormap(request)
cmin, cmax = wms_handler.get_climits(request)
#proj = get_pyproj(request)
#xcrs, ycrs = proj(lon.flatten(),lat.flatten())
CRS = get_pyproj(request)
xcrs, ycrs = pyproj.transform(EPSG4326, CRS, lon.flatten(),lat.flatten()) #TODO order for non-inverse?
#logger.info("xcrs, ycrs: {0} {1}".format(xcrs, ycrs))
xcrs = xcrs.reshape(data.shape)
ycrs = ycrs.reshape(data.shape)
sxcrs = np.argsort(xcrs[1,:])
sycrs = np.argsort(ycrs[:,1])
fig = Figure(dpi=dpi, facecolor='none', edgecolor='none')
fig.set_alpha(0)
fig.set_figheight(height/dpi)
fig.set_figwidth(width/dpi)
ax = fig.add_axes([0., 0., 1., 1.], xticks=[], yticks=[])
lvls = np.linspace(cmin, cmax, nlvls)
#ax.contourf(xcrs, ycrs, data, levels=lvls, cmap=colormap)
ax.contourf(xcrs[sycrs,:][:,sxcrs], ycrs[sycrs,:][:,sxcrs], data[sycrs,:][:,sxcrs], levels=lvls, cmap=colormap)
ax.set_xlim(xmin, xmax)
ax.set_ylim(ymin, ymax)
ax.set_frame_on(False)
ax.set_clip_on(False)
ax.set_position([0, 0, 1, 1])
canvas = FigureCanvasAgg(fig)
response = HttpResponse(content_type='image/png')
canvas.print_png(response)
return response
示例13: blank_canvas
# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import set_figheight [as 别名]
def blank_canvas(width, height, dpi=5):
"""
return a transparent (blank) response
used for tiles with no intersection with the current view or for some other error.
"""
fig = Figure(dpi=dpi, facecolor='none', edgecolor='none')
fig.set_alpha(0)
ax = fig.add_axes([0, 0, 1, 1])
fig.set_figheight(height/dpi)
fig.set_figwidth(width/dpi)
ax.set_frame_on(False)
ax.set_clip_on(False)
ax.set_position([0, 0, 1, 1])
canvas = FigureCanvasAgg(fig)
return canvas
示例14: getImage
# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import set_figheight [as 别名]
def getImage(self):
figure = Figure()
axes = figure.add_subplot(111)
axes.plot(self.signal_read())
canvas = FigureCanvas(figure)
figure.set_figwidth(6)
figure.set_figheight(2)
figure.savefig(self.fileImage)
fig = QLabel()
fig.setPixmap(QPixmap(self.fileImage))
fig.setFixedSize(600, 200)
return fig
示例15: radial_summary
# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import set_figheight [as 别名]
def radial_summary(values,name):
# Set the colors for the plot
colors=["#A7DB40","#D8E067","#FFB81F","#FF743D","#C4213D","#707070"]
# Create a figure and a canvas to draw in
fig = Figure()
canvas = FigureCanvas(fig)
fig.set_figwidth(1)
fig.set_figheight(1)
# Set the figure configuration and parameters
ax = fig.add_subplot(1,1,1)
# Plot the pie with the diferent values and colors
ax.pie(values,colors=colors, shadow=True, startangle=90)
#Save the graphic as an image
canvas.print_figure('tweetclass/static/tweetclass/summary_pie_'+name+'.png',bbox_inches='tight')