[CHANGESET]: Re: scatter - markersize

David Bateman David.Bateman at motorola.com
Wed Mar 19 11:37:45 CDT 2008


David Bateman wrote:
> Christoph Keller wrote:
>   
>> in my opinion, scatter(X,Y,S) places the scatter-marks constant in size, even
>> if a "weigth"-vector S is given as an argument of scatter.
>>
>> In __scatter__.m I found:
>>
>>   h = patch("faces", [1:length(x)].', "vertices", [x, y, z], "facecolor",
>> 	      "none", "edgecolor", "flat", "cdata", c, "marker", marker, 
>> 	      "markersize", s, "linestyle", "none");
>>
>> where 's' is a scalar rather than a vector. Is this by design or by
>> accident?
>>
>> thank you for your comments, sincerely
>> Christoph Keller
>> (octave 3.0.0, Windows XP)
>>   
>>     
>
> The calculation of "s" in __scatter__.m is
>
> <quote>
>   if (istart < nargin && firstnonnumeric > istart)
>     s = varargin{istart};
>     if (isempty (s))
>       s = 8;
>     endif
>   else
>     s = 8;
>   endif
>   ## Note markersize is in points^2 for 2D and points for 3D, and
>   ## the below is an approximation, that is empircally visually correct.
>   if (nd == 2)
>     s = sqrt (s) / 2;
>   else
>     s = s / 4;
>   endif
> </quote>
>
> Therefore if you pass a value for s as a vector, it is passed to patch
> as a vector.. The code
>
>  n = 100; x = randn(n,1); y = randn(n,1); c = sqrt(x.^2 + y.^2);
> scatter(x, y, 1:100, c)
>
> works fine for me under Octave 3.0.0 and gnuplot 4.2.3 that I'm using..
> However, it appears to be broken under 3.1.x
>
> D.
>
>   
Here is a changeset that gets the markersize for scatter plots working
again in 3.1.x. However.

n = 100; x = randn(n,1); y = randn(n,1); c = sqrt(x.^2 + y.^2);
scatter(x, y, 1:100, c)

won't work in 3.1.x though it works in 3.0.0... The reason is that the
patch objects now require that the markersize is a scalar value. This is
compatible with the behavior of the Matlab patch objects. However,
matlab allows vector markersizes to scatter plots, and does this by
using an hggroup to form a "scattergroup" which is a group of N patch
objects each with different marker sizes.

I see two ways of fixing this issue

1) The right way would be to implement a scattergroup and keep the
markersize as a scalar value in the patch objects. This seems to me to
be a significant amount of work and I don't want to do something like
that if Shai or Michael are working in the background on the graphics.

2) The hack would be to allow patch markersize to be a matrix and so
keep the same behavior as Octave 3.0.0, and a visually similar behavior
to matlab, but with a handle that is incompatible. I'd be happy enough
to propose a patch for this if people want this to be done, but its not
the right thing to do..

D.

-- 
David Bateman                                David.Bateman at motorola.com
Motorola Labs - Paris                        +33 1 69 35 48 04 (Ph) 
Parc Les Algorithmes, Commune de St Aubin    +33 6 72 01 06 33 (Mob) 
91193 Gif-Sur-Yvette FRANCE                  +33 1 69 35 77 01 (Fax) 

The information contained in this communication has been classified as: 

[x] General Business Information 
[ ] Motorola Internal Use Only 
[ ] Motorola Confidential Proprietary

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patch7738
Url: https://www.cae.wisc.edu/pipermail/bug-octave/attachments/20080319/b62afb28/attachment-0001.ksh 


More information about the Bug-octave mailing list