Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Contour plot using m_map

495 views
Skip to first unread message

Phil Ashton

unread,
Jun 13, 2011, 8:26:05 AM6/13/11
to
Hi there I am trying to produce a contour plot onto a map using longitude and latitude data...

I have a 3 matrices x & y containing long and lat co-ordinates and 'z' a specific data value at those co-ordinates.

Using the following i can produce the map but none of the data held in z is appearing???

...

m_proj('lambert','long',[2 -6],'lat',[-49.9 56]);
m_coast('patch',[1 .9 .7]);
m_tbase('contourf',[x:y:z];
m_grid('box','fancy','tickdir','in');

( x, y and z are all the same size)

ANy help is greatly appreciated

Phil Ashton

unread,
Jun 13, 2011, 8:27:04 AM6/13/11
to

flash

unread,
Jun 13, 2011, 8:38:04 AM6/13/11
to
"flash" wrote in message <it4vkt$hfr$1...@newscl01ah.mathworks.com>...

How do i associate the values held in x and y with the Long and Lat values of the grid?

Any ideas??

flash

unread,
Jun 13, 2011, 9:16:02 AM6/13/11
to
"flash" wrote in message <it50bc$j6m$1...@newscl01ah.mathworks.com>...

If I take the m_map out of it

[Lat, Long] = meshgrid(linspace(min(x), max(x)), linspace(min(y), max(y)));
Grid = griddata(x, y, z, Lat, Long);
contourf(Lat, Long, Grid, 50);

I get what I'm after I'm then just unsure how to get this to sit on top of the m_map stuff so that it appears on the map...?

TideMan

unread,
Jun 13, 2011, 4:22:00 PM6/13/11
to
On Jun 14, 1:16 am, "flash " <phil...@hotmail.com> wrote:
> "flash" wrote in message <it50bc$j6...@newscl01ah.mathworks.com>...
> > "flash" wrote in message <it4vkt$hf...@newscl01ah.mathworks.com>...

Use m_contourf, not m_tbase
m_contourf(Lat,Long,Grid,50)

flash

unread,
Jun 14, 2011, 4:22:04 AM6/14/11
to
TideMan <mul...@gmail.com> wrote in message <631e14ff-b605-4cc9...@k15g2000pri.googlegroups.com>...

Thank you for your reply...

Using the below code it sort of works however i was trying to get the contour to fill the land on the map as opposed to just sitting in almost a diamond shape on top of it:

clc
clear
x = xlsread('MAP','Sheet1','C4:C12');
y = xlsread('MAP','Sheet1','D4:D12');
z = xlsread('MAP','Sheet1','E4:E12');


m_proj('lambert','long',[2 -6],'lat',[49.9 55.5]);
[lat, long] = meshgrid(linspace(min(x), max(x)),linspace(min(y), max(y)));
TempGrid = griddata(x, y, z, lat, long);
m_contour(lat, long, TempGrid, 20);
m_coast('line');
m_grid;
colormap(flipud(gray));

At the moment the size of the contour plor is governed by:

[lat, long] = meshgrid(linspace(min(x), max(x)),linspace(min(y), max(y)));

I want it to be governed by the map itself so it colours in the map

Any ideas how m_map handles this, as in some of the examples (which i appreciate link to databases) the land is perfectly coloured through i believe the 'patch' command but i'm not able to get this to work either??

TideMan

unread,
Jun 14, 2011, 6:45:23 AM6/14/11
to
On Jun 14, 8:22 pm, "flash " <phil...@hotmail.com> wrote:
> TideMan <mul...@gmail.com> wrote in message <631e14ff-b605-4cc9-9321-505e5528e...@k15g2000pri.googlegroups.com>...

Yes, but you have specified
m_coast('line')
This specifies the coastline as a line.
Doh
Did you bother typing:
help m_coast
And after you typed it, did you bother reading what it said:
M_COAST('line', (standard line option,...,...) ) draws the
coastline
as a simple line.
M_COAST('patch' ( ,standard patch options,...,...) ) draws
the
coastline as a number of patches.

You have specify it as a patch, e.g.,
m_coast('patch',[0.808 1 0.808])
will make it a nice light green.

flash

unread,
Jun 14, 2011, 8:31:04 AM6/14/11
to
TideMan <mul...@gmail.com> wrote in message <030e94bb-e734-4bd6...@34g2000pru.googlegroups.com>...

Yes i appreciate that but even with the above code, the data which i am trying to contour is not appearing as a patch on the map, it sits as part of a separate grid on top of the map???

TideMan

unread,
Jun 14, 2011, 3:46:56 PM6/14/11
to
On Jun 15, 12:31 am, "flash " <phil...@hotmail.com> wrote:
> TideMan <mul...@gmail.com> wrote in message <030e94bb-e734-4bd6-86a2-b493b783d...@34g2000pru.googlegroups.com>...

Type:
help hold on

And once you've understood that, try plotting the coastline before
m_contour

phani...@gmail.com

unread,
Oct 20, 2013, 6:16:51 AM10/20/13
to
Namastey ,

hello there..

I am new to use matlab..

here is my problem.. I am having data of monthly average of u_current v_current for particular location. like wise for three locations. all are in different excel sheets..

I want to plot them on a Indian base map..to know how the current pattern for monthly wise..

My data consists of three columns. 1st column is jun,jul,aug,....
2nd column is u_ current values.. 3rd column is v_current values...

I donno how to do... If you please provide me some code..It would be very helpful for my project..

Thank you in advance..

phani...@gmail.com

unread,
Oct 20, 2013, 7:30:07 AM10/20/13
to
hey there...

In my matlab when i type m_proj or m_contour it is showing

??? Undefined function or method 'm_proj' for input arguments of type
'char'.

so what to do with that..

help me out ..

thanks in advance..

TideMan

unread,
Oct 20, 2013, 4:05:30 PM10/20/13
to
It's an extra toolbox that you have to download and install.
Google m_map to find it.

phani...@gmail.com

unread,
Oct 21, 2013, 2:23:41 AM10/21/13
to
thank you Tideman..

But how to draw vector plots for ocean currents at a particular location..
like I am having monthly average data of u-current and v_current at location.

now i want to plot current direction at that location for january..and save that image..
after that for february... so on.. help me out..

thanks in advance..

TideMan

unread,
Oct 21, 2013, 5:03:57 AM10/21/13
to
m_demo
gives examples.
You'll see plots of currents there.

Then
help m_proj
help m_vec

You need to read the manual and have a go, then if you have trouble, show the code that is causing the problem.

phani

unread,
Oct 22, 2013, 11:43:07 AM10/22/13
to
TideMan <mul...@gmail.com> wrote in message <f8c948f7-8497-4260...@googlegroups.com>...
Thank you Tideman

I plotted ocean currents using m_proj and m_vec commands its very easy using mat-lab

thanks a lot for your help...
0 new messages