Thread Subject: Plotting 3D graph in a plane

Subject: Plotting 3D graph in a plane

From: kagohaik

Date: 12 Oct, 2008 01:45:43

Message: 1 of 2

I am new in matlab and I would like to plot a 3D graph in a 2D graph.
The x and y axis are representing the independent variables. There are only two values for the dependent variables, which are 2,3, in which I would like to represent it with different symbols in the 2D graph. How am I going about doing this?

Thanks in advance.

Subject: Plotting 3D graph in a plane

From: Walter Roberson

Date: 12 Oct, 2008 04:51:36

Message: 2 of 2

kagohaik wrote:
> I am new in matlab and I would like to plot a 3D graph in a 2D graph.
> The x and y axis are representing the independent variables. There are only two values
> for the dependent variables, which are 2,3, in which I would like to represent it with
> different symbols in the 2D graph. How am I going about doing this?

I suggest using scatter(). It would be easier to use different colors rather than different
symbols, but here is how you can do it using different symbols:

xt = x;
xt(z~=2) = nan;
scatter(xt,y,SymbolSize,'o'); %'o' marker for first value
xt = x;
xt(z~=3) = nan;
scatter(xt,y,SymbolSize,'+') %'+' marker for second value

If you add the color information you can obviously generalize this to as many
distinctive colour / marker combinations as you can come up with (though
if you were to get into that, you'd -probably- be wanting to use value ranges
rather than exact comparisons)

xt = x;
xt(abs(z-7.2) > 4*eps(7.2)) = nan; %preserve only values really close to 7.2

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

rssFeed for this Thread

Public Submission Policy

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.

Contact us at files@mathworks.com