[Matplotlib-users] Problem using imshow with Matplotlib/Basemap

Mauro Cavalcanti maurobio at gmail.com
Mon Oct 9 19:54:40 EDT 2017


Hi,

Thanks for you reply and suggestions.

I changed the imshow call to:

im = m.imshow(grilla_salida, cmap='summer', extent=(lon_inf, lat_inf,
lon_sup, lat_sup), aspect='auto', interpolation='none')

However, the figure is stil wrong (see attachment).

Maybe if instead of imshow, should I use meshgrid/pcolormesh?

Best regards,

2017-10-09 11:29 GMT-03:00 Benjamin Root <ben.v.root at gmail.com>:

> First, you shouldn't need to transpose your image... that'll effectively
> rotate the data by 90 degrees. Second, you didn't specify the extents of
> your image, so Basemap is putting everything starting at coordinate 0,0 in
> the default projection.
>
> If you specify the extent keyword argument to imshow as the (lon1, lat1,
> lon2, lat2) tuple for the lower-left and upper right corners, you won't
> even need the origin='lower', and you definitely won't need the transpose.
>
> Cheers!
> Ben Root
>
>
> On Sun, Oct 8, 2017 at 2:33 PM, Mauro Cavalcanti <maurobio at gmail.com>
> wrote:
>
>> Dear ALL,
>>
>> I have a simple dataset of longitudes/latitudes (see the attached csv
>> file).
>>
>> From such data, I want to generate a grid like this:
>>
>> 0 0 0 0 0 0 0 0 0 0 0 0 0
>> 0 0 0 0 0 0 0 0 0 0 0 0 0
>> 0 0 0 0 0 0 0 0 0 0 0 0 0
>> 0 0 0 0 0 0 1 0 0 0 0 0 0
>> 0 0 0 0 0 0 1 1 2 0 0 0 0
>> 0 0 0 0 0 1 1 1 1 0 0 0 0
>> 0 0 0 1 0 1 0 0 0 0 0 0 0
>> 0 0 0 2 0 0 0 0 0 0 0 0 0
>> 0 0 0 0 0 0 0 0 0 1 3 0 0
>> 0 0 0 0 0 0 0 0 0 0 0 0 0
>> 0 0 0 0 0 0 0 0 0 1 0 0 0
>> 0 0 0 0 0 0 0 0 0 1 0 0 0
>> 0 0 0 0 0 0 0 0 0 0 0 0 0
>> 0 0 0 0 0 0 0 0 0 0 1 0 0
>> 0 0 0 0 0 0 0 0 0 0 1 0 0
>> 0 0 0 0 0 0 0 0 0 0 0 0 0
>> 0 0 0 0 0 0 0 0 0 0 0 0 0
>>
>> which gives the number of data records in each cell of the grid, using
>> one of the variables in the dataset ("spp") as a categorical (grouping)
>> factor.
>>
>> From this grid, I then want to create a heat map, superimposed on a
>> Matplotlib/Basemap.
>>
>> I wrote some code which does what I want (see the attachments).
>>
>> It (mostly) works, but te problem is that the grid image is not being
>> displayed correctly: as shown in the attached figure, it appears too small,
>> and in the lower left corner of the map, instead of where it should be (the
>> West coast of Africa, along the Gulf of Guinea).
>>
>> Thanks in advance for any assistance you can provide.
>>
>> Best regards,
>>
>> --
>> Dr. Mauro J. Cavalcanti
>> E-mail: maurobio at gmail.com
>> Web: http://sites.google.com/site/maurobio
>> "Life is complex. It consists of real and imaginary parts."
>>
>> _______________________________________________
>> Matplotlib-users mailing list
>> Matplotlib-users at python.org
>> https://mail.python.org/mailman/listinfo/matplotlib-users
>>
>>
>


-- 
Dr. Mauro J. Cavalcanti
E-mail: maurobio at gmail.com
Web: http://sites.google.com/site/maurobio
"Life is complex. It consists of real and imaginary parts."
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20171009/e51604c0/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Figure_1.png
Type: image/png
Size: 47105 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20171009/e51604c0/attachment-0001.png>


More information about the Matplotlib-users mailing list