David Bateman wrote:
> Ben Abbott wrote:
>>
>> I think that depends upon compatibility in other areas.
>>
>> Trusting my memory, plot3 (<real_matrix>, <real_matrix>,
>> <real_matrix>) produces a series of 3D lines in Matlab, but produces
>> a single line in Octave ... the Octave result will zig-zag (see the
>> code below)
>>
>> [x, y] = meshgrid (0:10, 0:10);
>> z = x.*y;
>> figure(1)
>> clf
>> plot3 (x, y, z)
>>
>> Same for plot3 (<real_matrix>, <complex_matrix)
>>
>> y = y + 1i*z;
>> figure(2)
>> clf
>> plot3 (x, y)
>>
>> This issue is what I think needs attention, and I have a faint
>> recollection that maintaining the complex_vector/matrix feature was
>> problematic.
>>
>> Ben
>>
> Ok, this is clearly a bug. I think the attached addresses this. and now
>
> [x, y] = meshgrid (0:10, 0:10); z = x.*y; figure(1); clf; h =
> plot3(x,y + 1i *z); zlim(0,100)
>
> and
>
> [x, y] = meshgrid (0:10, 0:10); z = x.*y; figure(1); clf; h =
> plot3(x,y,z); zlim(0,100)
>
> both work correctly on my machine. Note the zlim is needed to get
> around the issue addressed in
>
>
http://hg.tw-math.de/octave-graphics-mq/rev/7747c2f2f3ed>
> D.
>
>
Please use the attached instead, that moves the color definition inside
the loop over the columns of the matrices so that __next_line_color__ is
called for each column.
D.
--
David Bateman
David.Bateman@...
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
# HG changeset patch
# User David Bateman <
dbateman@...>
# Date 1220278869 -7200
# Node ID daa6e85de4043d3efd0998cc3136e9091ec13a93
# Parent 79ace969785cac0e104146191869c69089178130
correctly plot matrices in plot3
diff --git a/scripts/ChangeLog b/scripts/ChangeLog
--- a/scripts/ChangeLog
+++ b/scripts/ChangeLog
@@ -1,3 +1,8 @@ 2008-08-31 Michael Goffioul <michael.g
+2008-09-01 David Bateman <
dbateman@...>
+
+ * plot/__line__.m: Remove empty clause fof if/then/else test
+ * plot/plot3.m: Correctly plot matrices.
+
2008-08-31 Michael Goffioul <
michael.goffioul@...>
* plot/__plt2mm__.m, plot/__plt2mv__.m, plot/__plt2ss__.m,
diff --git a/scripts/plot/__line__.m b/scripts/plot/__line__.m
--- a/scripts/plot/__line__.m
+++ b/scripts/plot/__line__.m
@@ -42,8 +42,7 @@ function h = __line__ (p, varargin)
num_data_args = 0;
endif
- if (rem (nvargs - num_data_args, 2) == 0)
- else
+ if (rem (nvargs - num_data_args, 2) != 0)
print_usage ("line");
endif
diff --git a/scripts/plot/plot3.m b/scripts/plot/plot3.m
--- a/scripts/plot/plot3.m
+++ b/scripts/plot/plot3.m
@@ -161,9 +161,9 @@ function retval = plot3 (varargin)
y = y(:);
z = z(:);
elseif (length (x) == rows (z) && length (y) == columns (z))
+ [x, y] = meshgrid (x, y);
+ else
error ("plot3: [length(x), length(y)] must match size(z)");
- else
- [x, y] = meshgrid (x, y);
endif
endif
@@ -175,22 +175,28 @@ function retval = plot3 (varargin)
if (! isempty (key))
set (gca (), "key", "on");
endif
- color = options.color;
- if (isempty (options.color))
- color = __next_line_color__ ();
- endif
-
- hg = hggroup ();
- tmp(++idx) = hg;
- properties = __add_datasource__ ("plot3", hg, {"x", "y", "z"}, properties{:});
-
- hline = line (x(:), y(:), z(:), "keylabel", key, "color", color,
- "linestyle", options.linestyle,
- "marker", options.marker, "parent", hg);
-
- __add_line_series__ (hline, hg);
-
- set (hg, properties{:});
+
+ for i = 1 : columns (x)
+ color = options.color;
+ if (isempty (options.color))
+ color = __next_line_color__ ();
+ endif
+
+ hg = hggroup ();
+ tmp(++idx) = hg;
+ properties = __add_datasource__ ("plot3", hg, {"x", "y", "z"}, properties{:});
+
+ hline = line (x(:, i), y(:, i), z(:, i), "keylabel", key,
+ "color", color,
+ "linestyle", options.linestyle,
+ "marker", options.marker, "parent", hg);
+
+ __add_line_series__ (hline, hg);
+
+ if (! isempty (properties))
+ set (hg, properties{:});
+ endif
+ endfor
x_set = 0;
y_set = 0;
@@ -213,9 +219,9 @@ function retval = plot3 (varargin)
y = y(:);
z = z(:);
elseif (length (x) == rows (z) && length (y) == columns (z))
+ [x, y] = meshgrid (x, y);
+ else
error ("plot3: [length(x), length(y)] must match size(z)");
- else
- [x, y] = meshgrid (x, y);
endif
endif
@@ -228,22 +234,28 @@ function retval = plot3 (varargin)
if (! isempty (key))
set (gca (), "key", "on");
endif
- color = options.color;
- if (isempty (color))
- color = __next_line_color__ ();
- endif
-
- hg = hggroup ();
- tmp(++idx) = hg;
- properties = __add_datasource__ ("plot3", hg, {"x", "y", "z"}, properties{:});
-
- hline = line (x(:), y(:), z(:), "keylabel", key, "color", color,
- "linestyle", options.linestyle,
- "marker", options.marker, "parent", hg);
-
- __add_line_series__ (hline, hg);
-
- set (hg, properties{:});
+
+ for i = 1 : columns (x)
+ color = options.color;
+ if (isempty (color))
+ color = __next_line_color__ ();
+ endif
+
+ hg = hggroup ();
+ tmp(++idx) = hg;
+ properties = __add_datasource__ ("plot3", hg, {"x", "y", "z"}, properties{:});
+
+ hline = line (x(:, i), y(:, i), z(:, i), "keylabel", key,
+ "color", color,
+ "linestyle", options.linestyle,
+ "marker", options.marker, "parent", hg);
+
+ __add_line_series__ (hline, hg);
+
+ if (! isempty (properties))
+ set (hg, properties{:});
+ endif
+ endfor
x = new;
y_set = 0;
@@ -285,9 +297,9 @@ function retval = plot3 (varargin)
y = y(:);
z = z(:);
elseif (length (x) == rows (z) && length (y) == columns (z))
+ [x, y] = meshgrid (x, y);
+ else
error ("plot3: [length(x), length(y)] must match size(z)");
- else
- [x, y] = meshgrid (x, y);
endif
endif
@@ -300,24 +312,28 @@ function retval = plot3 (varargin)
if (! isempty (key))
set (gca (), "key", "on");
endif
- color = options.color;
- if (isempty (color))
- color = __next_line_color__ ();
- endif
-
- hg = hggroup ();
- tmp(++idx) = hg;
- properties = __add_datasource__ ("plot3", hg, {"x", "y", "z"}, properties{:});
-
- hline = line (x(:), y(:), z(:), "keylabel", key, "color", color,
- "linestyle", options.linestyle,
- "marker", options.marker, "parent", hg);
-
- __add_line_series__ (hline, hg);
-
- if (! isempty (properties))
- set (hg, properties{:});
- endif
+
+ for i = 1 : columns (x)
+ color = options.color;
+ if (isempty (color))
+ color = __next_line_color__ ();
+ endif
+
+ hg = hggroup ();
+ tmp(++idx) = hg;
+ properties = __add_datasource__ ("plot3", hg, {"x", "y", "z"}, properties{:});
+
+ hline = line (x(:, i), y(:, i), z(:, i), "keylabel", key,
+ "color", color,
+ "linestyle", options.linestyle,
+ "marker", options.marker, "parent", hg);
+
+ __add_line_series__ (hline, hg);
+
+ if (! isempty (properties))
+ set (hg, properties{:});
+ endif
+ endfor
endif
set (gca (), "view", [-37.5, 30]);
_______________________________________________
Bug-octave mailing list
Bug-octave@...
https://www-old.cae.wisc.edu/mailman/listinfo/bug-octave