Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Error for bbox_inches='tight' in savefig with make_axes_locatable #12355

Closed
Assignees
jklymak
Milestone
@jiaozhh

Description

@jiaozhh

Bug report

Bug summary

When setting bbox_inches='tight' in savefig function, the colorbar is plotted in the wrong way.

Code for reproduction

importmatplotlib.pyplotaspltimportnumpyasnpfrommpl_toolkits.basemapimportBasemapoutfile=r'E:\wrong.tif'# read in data on lat/lon grid.hgt=np.loadtxt(r'E:\tmp\basemap\500hgtdata.gz')lons=np.loadtxt(r'E:\tmp\basemap\500hgtlons.gz')lats=np.loadtxt(r'E:\tmp\basemap\500hgtlats.gz')lons,lats=np.meshgrid(lons,lats)mnh=Basemap(lon_0=-105,boundinglat=20.,resolution='c',area_thresh=10000.,projection='nplaea')xnh,ynh=mnh(lons,lats)CS=mnh.contour(xnh,ynh,hgt,15,linewidths=0.5,colors='k')CS=mnh.contourf(xnh,ynh,hgt,15,cmap=plt.cm.Spectral)mnh.drawcoastlines(linewidth=0.5)delat=30.circles=np.arange(0.,90.,delat).tolist()+ \np.arange(-delat,-90,-delat).tolist()mnh.drawparallels(circles,labels=[1,0,0,0])delon=45.meridians=np.arange(0,360,delon)mnh.drawmeridians(meridians,labels=[1,0,0,1])plt.title('NH 500 hPa Height (cm.Spectral)')# colorbar on bottom.mnh.colorbar(pad='5%')plt.savefig(outfile,dpi=300,bbox_inches='tight')# wrong# plt.savefig(outfile, dpi=300) # rightplt.show()

Actual outcome

The wrong one:
default

# If applicable, paste the console output here# None#

Expected outcome

The correct figure:
default

Matplotlib version

  • Operating system: Windows 10 x64
  • Matplotlib version: 3.0.0
  • Matplotlib backend (print(matplotlib.get_backend())): module://backend_interagg
  • Python version: 3.6.6
  • Jupyter version (if applicable): None
  • basemap version: 1.2.0
  • PyCharm version: 2018.2.4

I install matplotlib and basemap fromhttps://www.lfd.uci.edu/~gohlke/pythonlibs.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp