matplotlib / basemap

Plot on map projections (with coastlines and political boundaries) using matplotlib
MIT License
779 stars 392 forks source link

Bad quality with python3 in bluemarble() #511

Closed gcpmendez closed 3 years ago

gcpmendez commented 3 years ago

I am currently running this code in python 2 and python3 and it produces an image with a different quality. In python2 it has much better quality.

Code: from mpl_toolkits.basemap import Basemap import matplotlib.pyplot as plt

map = Basemap(llcrnrlon=-10.5,llcrnrlat=33,urcrnrlon=10.,urcrnrlat=46., resolution='i', projection='cass', lat_0 = 39.5, lon_0 = 0.) map.bluemarble() map.drawcoastlines() plt.show()

Versions: basemap 1.0.6/1.2.2 matplotlib 1.2.0/3.3.4

Images: p2 - https://ibb.co/3h4pXbS p3 - https://ibb.co/qsZ8L76

What happens?

WeatherGod commented 3 years ago

Most likely, the dpi settings for the files are different. Matplotlib changed the default DPI in version 2.0, as well as the default figure size, if I remember correctly. Indeed, the two images have different pixel resolutions (800x600 vs. 640x480). I don't think this is a basemap issue.

On Fri, Feb 26, 2021 at 9:14 AM Germán Méndez notifications@github.com wrote:

I am currently running this code in python 2 and python3 and it produces an image with a different quality. In python2 it has much better quality.

Code: from mpl_toolkits.basemap import Basemap import matplotlib.pyplot as plt

map = Basemap(llcrnrlon=-10.5,llcrnrlat=33,urcrnrlon=10.,urcrnrlat=46., resolution='i', projection='cass', lat_0 = 39.5, lon_0 = 0.) map.bluemarble() map.drawcoastlines() plt.show()

Versions: basemap 1.0.6/1.2.2 matplotlib 1.2.0/3.3.4

Images: p2 - https://ibb.co/3h4pXbS p3 - https://ibb.co/qsZ8L76

What happens?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/matplotlib/basemap/issues/511, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACHF6EOJNEGKPOD2IQWP53TA6UFLANCNFSM4YIQM5MA .

gcpmendez commented 3 years ago

I could change the resolution with $ plt.savefig('p3.png',format='png',dpi=200) but the result it's not the same

guziy commented 3 years ago

Try passing the scale argument to the bluemarble method:

map.bluemarble(scale=2)
gcpmendez commented 3 years ago

Try passing the scale argument to the bluemarble method:

map.bluemarble(scale=2)

not works

molinav commented 3 years ago

Hola @gcpmendez!

Sorry for the late reply, I was a bit busy lately and could not respond. I open the issue again because I want to take a look to it. When I find out I will write another reply.

gcpmendez commented 3 years ago

It's already solved

The original image in p2 have more quality that p3 in .local/lib/python3.7/site-packages/mpl_toolkits/basemap_data/bmng.jpg

After that I solved this issue: PIL.Image.DecompressionBombError: Image size (233280000 pixels) exceeds limit of 178956970 pixels, could be decompression bomb DOS attack with the line: PIL.Image.MAX_IMAGE_PIXELS = 933120000

Thanks for your support