Thread Subject: Is it possible to vectorize LineProperties of a plot object?

Subject: Is it possible to vectorize LineProperties of a plot object?

From: Gustavo Morales

Date: 4 Nov, 2009 00:58:03

Message: 1 of 4

I'd like to do something like this:
>> X = [1, 2, 3]; Y = [2, 2.5, 2.9]; %for example
>> plot(X,Y,'o','MarkerSize',[20, 10, 15]);

but it causes an error:
??? Error using ==> plot
Value must be scalar

I don't want to use a for loop to asign a MarkerSize to each point (xi,yi).
I'd like to vectorize this process. ?Is it possible?

Subject: Is it possible to vectorize LineProperties of a plot object?

From: Pekka Kumpulainen

Date: 4 Nov, 2009 11:36:01

Message: 2 of 4

"Gustavo Morales" <gustavo.morales.2000@gmail.com> wrote in message <hcqjir$3vf$1@fred.mathworks.com>...
> I'd like to do something like this:
> >> X = [1, 2, 3]; Y = [2, 2.5, 2.9]; %for example
> >> plot(X,Y,'o','MarkerSize',[20, 10, 15]);
>
> but it causes an error:
> ??? Error using ==> plot
> Value must be scalar
>
> I don't want to use a for loop to asign a MarkerSize to each point (xi,yi).
> I'd like to vectorize this process. ?Is it possible?

One line object can have only one MarkerSize. If you want different sizes you will have to have separate objects for each. Easy to write your own function for that though.
I may have done the same thing somewhere in past, I think, or something very similar anyway..

Subject: Is it possible to vectorize LineProperties of a plot object?

From: Steven Lord

Date: 4 Nov, 2009 15:08:42

Message: 3 of 4


"Pekka Kumpulainen" <pekka.nospam.kumpulainen@tut.please.fi> wrote in
message news:hcrov1$r76$1@fred.mathworks.com...
> "Gustavo Morales" <gustavo.morales.2000@gmail.com> wrote in message
> <hcqjir$3vf$1@fred.mathworks.com>...
>> I'd like to do something like this:
>> >> X = [1, 2, 3]; Y = [2, 2.5, 2.9]; %for example
>> >> plot(X,Y,'o','MarkerSize',[20, 10, 15]);
>>
>> but it causes an error:
>> ??? Error using ==> plot
>> Value must be scalar
>>
>> I don't want to use a for loop to asign a MarkerSize to each point
>> (xi,yi).
>> I'd like to vectorize this process. ?Is it possible?
>
> One line object can have only one MarkerSize. If you want different sizes
> you will have to have separate objects for each. Easy to write your own
> function for that though.
> I may have done the same thing somewhere in past, I think, or something
> very similar anyway..

If the OP just wants the markers, use SCATTER.

If the OP wants markers of varying sizes and a line connecting them, use
PLOT without a marker, HOLD ON, and use SCATTER.

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ

Subject: Is it possible to vectorize LineProperties of a plot object?

From: Gustavo Morales

Date: 5 Nov, 2009 01:19:02

Message: 4 of 4

Pekka Kumpulainen and
Steven Lord
 Thank you so much! You make me think that there are truly genius at this newsgroup!
Although, I'm not completely satisfied with the scatter() command. It seems that, in practice, there isn't a direct proportion between size and the area, when you visualize the graph...
For example:
>> X = [0, 3, 2]; Y = [2, -2, 8];
>> ri = [0.1, 0.2, 10]; Ai = pi*ri.^2; Factor = 100;
>> scatter(X,Y,Factor*Ai);

If you, for example, empirically determines that Factor = 100 for small markers (r = 0.1 and 0.2), when you want to plot big markers (r = 10), those markers don't agree with the observed plot

Thank you for your help!
Regards from Venezuela!

Tags for this Thread

Everyone's Tags:

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.

Tag Activity for This Thread
Tag Applied By Date/Time
for lopps Gustavo Morales 3 Nov, 2009 19:59:05
vectorize Gustavo Morales 3 Nov, 2009 19:59:05
plot Gustavo Morales 3 Nov, 2009 19:59:04
rssFeed for this Thread
 

MATLAB Central Terms of Use

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 Terms prior to use.

Contact us at files@mathworks.com