当前位置: 首页>>代码示例>>Python>>正文


Python Figure.set_figsize_inches方法代码示例

本文整理汇总了Python中matplotlib.figure.Figure.set_figsize_inches方法的典型用法代码示例。如果您正苦于以下问题:Python Figure.set_figsize_inches方法的具体用法?Python Figure.set_figsize_inches怎么用?Python Figure.set_figsize_inches使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在matplotlib.figure.Figure的用法示例。


在下文中一共展示了Figure.set_figsize_inches方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: simple_plot

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import set_figsize_inches [as 别名]
def simple_plot(request):
    
    from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
    from matplotlib.figure import Figure
    from matplotlib.dates import DateFormatter
    c = Country.objects.all().order_by('?')[:1].get()
    res=[]
    year=[]
    aids = Aid.objects.filter(pcountry=c)
    for aid in aids:
        res.append(aid.dollars)
        year.append(aid.datesigned)
    fig=Figure(facecolor="#f4faf6")
    fig.set_figsize_inches( ( 4.50 ,3.472) )
    ax=fig.add_subplot(111)
    ax.set_axis_bgcolor("#f4faf6")
    x=[]
    y=[]
    
    
    ax.plot_date(year, res, '.-')
    ax.xaxis.set_major_formatter(DateFormatter('%Y-%m-%d'))
    ax.set_xlabel('date received', alpha=0.5)
    ax.set_ylabel('amount in Dollars', alpha=0.5)
    ax.set_title('Total amount of USAID tenders for work in '+c.country)



    fig.autofmt_xdate()
    

    canvas=FigureCanvas(fig)
    response=HttpResponse(content_type='image/png')
    canvas.print_png(response)
    return response
开发者ID:jgosier,项目名称:Ujima,代码行数:37,代码来源:views.py

示例2: on_paint_request

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import set_figsize_inches [as 别名]
 def on_paint_request(self, printer):
     from matplotlib.figure import Figure
     from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
     rect = printer.pageRect( QtGui.QPrinter.Inch )
     dpi = printer.resolution()
     fig = Figure( facecolor='#ffffff')
     fig.set_figsize_inches( (rect.width(),rect.height()) )
     fig.set_dpi( dpi )
     self._value.plot_on_figure( fig )
     canvas = FigureCanvas(fig)
     canvas.render( printer )
开发者ID:kurtraschke,项目名称:camelot,代码行数:13,代码来源:charteditor.py

示例3: vtkRenderer

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import set_figsize_inches [as 别名]
cubeTexture.InterpolateOn()
cubeTexture.SetInput(imflip.GetOutput())
cubeActor.SetTexture(cubeTexture)

ren = vtkRenderer()
ren.AddActor(cubeActor)

win = plugInManager['VtkWindow'].winManager.newWindow()
win.vtkWidget.GetRenderWindow().AddRenderer(ren)

# Now create our plot
fig = Figure()
canvas = FigureCanvasAgg(fig)
ax = fig.add_subplot(111)
ax.grid(True)
ax.set_xlabel('Hello from VTK!', size=16)
ax.bar(xrange(10), p.rand(10))

# Powers of 2 image to be clean
w,h = 1024, 1024
dpi = canvas.figure.get_dpi()
fig.set_figsize_inches(w / dpi, h / dpi)
canvas.draw() # force a draw

# This is where we tell the image importer about the mpl image
extent = (0, w - 1, 0, h - 1, 0, 0)
importer.SetWholeExtent(extent)
importer.SetDataExtent(extent)
importer.SetImportVoidPointer(canvas.buffer_rgba(0,0), 1)
importer.Update()
开发者ID:BackupTheBerlios,项目名称:simuvis4-svn,代码行数:32,代码来源:mpl_vtk_test.py

示例4: Figure

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import set_figsize_inches [as 别名]
# longitudes go from 20 to 380.
etopo = nx.array(load('etopo20data.gz'),'d')
lons = nx.array(load('etopo20lons.gz'),'d')
lats = nx.array(load('etopo20lats.gz'),'d')
# create figure.
fig = Figure()
canvas = FigureCanvas(fig)
# create axes instance, leaving room for colorbar at bottom.
ax = fig.add_axes([0.125,0.175,0.75,0.75])
# create Basemap instance for Robinson projection.
# set 'ax' keyword so pylab won't be imported.
m = Basemap(projection='robin',lon_0=0.5*(lons[0]+lons[-1]),ax=ax)
# reset figure size to have same aspect ratio as map.
# fig will be 8 inches wide.
# (don't use createfigure, since that imports pylab).
fig.set_figsize_inches((8,m.aspect*8.))
# make filled contour plot.
x, y = m(*meshgrid(lons, lats))
cs = m.contourf(x,y,etopo,30,cmap=cm.jet)
# draw coastlines.
m.drawcoastlines()
# draw a line around the map region.
m.drawmapboundary()
# draw parallels and meridians.
m.drawparallels(nx.arange(-60.,90.,30.),labels=[1,0,0,0],fontsize=10)
m.drawmeridians(nx.arange(0.,420.,60.),labels=[0,0,0,1],fontsize=10)
# add a title.
ax.set_title('Robinson Projection')
# add a colorbar.
cax = fig.add_axes([0.125, 0.05, 0.75, 0.05],frameon=False)
fig.colorbar(cs, cax=cax, tickfmt='%d', orientation='horizontal',clabels=cs.levels[::3]) 
开发者ID:,项目名称:,代码行数:33,代码来源:

示例5: Basemap

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import set_figsize_inches [as 别名]
matplotlib.use('Agg')

from mpl_toolkits.basemap import Basemap
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
from matplotlib.figure import Figure

if __name__ == "__main__":
	# Create the basemap
	m = Basemap(llcrnrlon=1, \
        	    llcrnrlat=40.6, \
	            urcrnrlon=8.8, \
	            urcrnrlat = 49.6, \
	            resolution = 'l', \
	            projection = 'tmerc', \
                    lon_0 = 4.9, \
                    lat_0 = 45.1)

	# Set Up the Canvas
	fig = Figure()
	canvas = FigureCanvas(fig)
	m.ax = fig.add_axes([0, 0, 1, 1])
	fig.set_figsize_inches((8/m.aspect, 8.))

	# Draw
	m.drawcoastlines(color='gray')
	m.drawcountries(color='gray')
	m.fillcontinents(color='beige')
	x, y = m(lons, lats)
	m.plot(x, y, 'bo')
	#canvas.print_figure('map.png', dpi=100)
开发者ID:dangpzanco,项目名称:CXRBNanoSat-Simulation-Environment,代码行数:32,代码来源:Mercator.py


注:本文中的matplotlib.figure.Figure.set_figsize_inches方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。