Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
How to draw markers on a 2-D colormap plot?

Subject: How to draw markers on a 2-D colormap plot?

From: Md. Shahriar Karim

Date: 30 Dec, 2012 00:02:19

Message: 1 of 5

Hi,

I am trying to draw markers on top of a 2D colormap plot. The meshgrid created for the 2D colormap plot will also be the locations of markers on the X-Y plane. However, not all the points from the grid will be plotted; instead, I shall plot only those points that satisfy a predefined condition. Can anybody help me in this regard?

Example:
-----------------------------------
figure(1)

I plotted the colormap plot as follows:

V1 = [ ] %length n
V2 = [ ] %length m

DATA = matrix (m, n)

[X,Y] = meshgrid(V1, V2);

  surf(x,y,DATA );

shading interp
set(gca,'cameraposition',[0 0 180])
colormap(jet)
--------------------------------------

Now, I would like to plot marker as follows:

plot(V1(),V2(),'o','MarkerSize',10,'MarkerFaceColor','black','MarkerEdgeColor','black')

---------------------------------------

I plot this marker and it's found behind the colormap! Is there any way to solve it?

Or, better ways to draw markers on top of a color map?

Thanks in advance,

Shahriar

Subject: How to draw markers on a 2-D colormap plot?

From: Sadik

Date: 30 Dec, 2012 02:02:23

Message: 2 of 5

Hi Shahriar,

You should use plot3.

Let us say condition is DATA<0.5. Then,

Xcond = X(DATA<0.5);
Ycond = Y(DATA<0.5);
Zcond = DATA<0.5;

plot3(Xcond,Ycond,Zcond,'*')

Best.

Subject: How to draw markers on a 2-D colormap plot?

From: Md. Shahriar Karim

Date: 30 Dec, 2012 19:33:07

Message: 3 of 5

"Sadik " <sadik.hava@gmail.com> wrote in message <kbo7bf$3om$1@newscl01ah.mathworks.com>...
> Hi Shahriar,
>
> You should use plot3.
>
> Let us say condition is DATA<0.5. Then,
>
> Xcond = X(DATA<0.5);
> Ycond = Y(DATA<0.5);
> Zcond = DATA<0.5;
>
> plot3(Xcond,Ycond,Zcond,'*')
>
> Best.

Hi Sadik,

Thanks for your reply. But I am looking to plot markers on X-Y plane and not in 3D. Because, I have a 2-D plot where the colormap is representing the third dimension.

Say, the third dimension is Z-value....

What I am trying is to plot markers on the colormap for some specific values of Z. I am not plotting Z here, but plotting markers with XY location denoted by V1() and V2().

I hope it's clear to you now. Thanks,

Shahriar

Subject: How to draw markers on a 2-D colormap plot?

From: Sadik

Date: 30 Dec, 2012 23:16:09

Message: 4 of 5

You are using surf, I would not consider that to be a 2D plot.

Please give the following a try and you will probably see that it works.'

Best.

Xcond = X(DATA<0.5);
Ycond = Y(DATA<0.5);
Zcond = DATA(DATA<0.5);

surf(X,Y,DATA)
hold on
plot3(Xcond,Ycond,Zcond,'*')

Subject: How to draw markers on a 2-D colormap plot?

From: Md. Shahriar Karim

Date: 31 Dec, 2012 14:50:26

Message: 5 of 5

"Sadik " <sadik.hava@gmail.com> wrote in message <kbqhvp$bj$1@newscl01ah.mathworks.com>...
> You are using surf, I would not consider that to be a 2D plot.
>
> Please give the following a try and you will probably see that it works.'
>
> Best.
>
> Xcond = X(DATA<0.5);
> Ycond = Y(DATA<0.5);
> Zcond = DATA(DATA<0.5);
>
> surf(X,Y,DATA)
> hold on
> plot3(Xcond,Ycond,Zcond,'*')

Hi Sadik,

Thanks a lot. I got the clue from your last comment :) and finally, with a little modification got this working. I added another command "view(2)" after the plot3 command.

Yes, I used surf, but it appears as if the plot is in 2D (due the the "cameraposition" stetting) and the colormap makes the third dimension.

Thanks again.

Shahriar

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us