python多子图导出至pdf_python将多个子图数字保存为pdf

importmatplotlibimportmatplotlib.pyplotaspltimportnumpyasnpimportsysimporttimeitfrommatplotlib.backends.backend_pdfimportPdfPagesmatplotlib.rcParams.update({'font.size':6})# Dimensions for any n-rows x m-cols array of subplots / pg.n,m=4,5# Don't forget to indent after the with statementwithPdfPages('auto_subplotting.pdf')aspdf:# Let's time the execution required to create and save# each full page of subplots to the pdfstart_time=timeit.default_timer()# Before beginning the iteration through all the data,# initialize the layout for the plots and create a# representation of the subplots that can be easily# iterated over for knowing when to create the next page# (and also for custom settings like partial axes labels)f,axarr=plt.subplots(n,m,sharex='col',sharey='row')arr_ij=[(x,y)forx,yinnp.ndindex(axarr.shape)]subplots=[axarr[index]forindexinarr_ij]# To conserve needed plotting real estate,# only label the bottom row and leftmost subplots# as determined automatically using n and msplot_index=0fors,splotinenumerate(subplots):splot.set_ylim(0,.15)splot.set_xlim(0,50)last_row=(n*m-s

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值