octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

plotyy


From: David Bateman
Subject: plotyy
Date: Mon, 26 Nov 2007 18:24:23 +0100
User-agent: Thunderbird 1.5.0.7 (X11/20060921)

Here is an how plotyy might be implemented in a matlab compatible
manner.. To get the two plot axes aligned in gnuplot it forces the
margins in __go_draw_axes__ with the "set lmargin" and "set rmargin"
commands to gnuplot.

There is one issue with this that appears to be a gnuplot bug.. If I try
the example


          x = 0:0.1:2*pi;
          y1 = sin (x);
          y2 = exp(x - 1);
          ax = plotyy(x, y1, x - 1, y2, @plot, @semilogy);
          ylabel (ax(1), "Axis 1");
          ylabel (ax(2), "Axis 2");

then the text "Axis 1" appears twice, even though the xlabel command is
only sent to gnuplot once.. This might limit the usefulness of this for
publication plots until the issue is fixed in gnuplot, but plotyy is
still useful in any case.

D.

-- 
David Bateman                                address@hidden
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

*** ./scripts/plot/xlabel.m.orig27      2007-11-26 18:17:39.943227090 +0100
--- ./scripts/plot/xlabel.m     2007-11-26 18:19:27.571785196 +0100
***************
*** 21,27 ****
  ## @deftypefn {Function File} {} xlabel (@var{string})
  ## @deftypefnx {Function File} {} ylabel (@var{string})
  ## @deftypefnx {Function File} {} zlabel (@var{string})
! ## Specify x, y, and z axis labels for the current figure.
  ## @seealso{plot, semilogx, semilogy, loglog, polar, mesh, contour,
  ## bar, stairs,  ylabel, title}
  ## @end deftypefn
--- 21,29 ----
  ## @deftypefn {Function File} {} xlabel (@var{string})
  ## @deftypefnx {Function File} {} ylabel (@var{string})
  ## @deftypefnx {Function File} {} zlabel (@var{string})
! ## @deftypefnx {Function File} {} xlabel (@var{h}, @var{string})
! ## Specify x, y, and z axis labels for the current figure. If @var{h} is
! ## specified then label the axis defined by @var{h}.
  ## @seealso{plot, semilogx, semilogy, loglog, polar, mesh, contour,
  ## bar, stairs,  ylabel, title}
  ## @end deftypefn
***************
*** 30,43 ****
  
  function h = xlabel (varargin)
  
!   if (rem (nargin, 2) == 1)
!     if (nargout > 0)
!       h = __axis_label__ ("xlabel", varargin{:});
!     else
!       __axis_label__ ("xlabel", varargin{:});
      endif
    else
!     print_usage ();
    endif
  
  endfunction
--- 32,61 ----
  
  function h = xlabel (varargin)
  
!   if (isscalar (varargin{1}) && ishandle (varargin{1}))
!     ax = varargin {1};
!     if (! strcmp (get (ax, "type"), "axes"))
!       error ("xlabel: expecting first argument to be an axes object");
      endif
+     if (rem (nargin, 2) == 1)
+       print_usage ();
+     endif
+     oldh = gca ();
+     unwind_protect
+       axes (ax);
+       tmp = __axis_label__ ("xlabel", varargin{2:end});
+     unwind_protect_cleanup
+       axes (oldh);
+     end_unwind_protect
    else
!     if (rem (nargin, 2) != 1)
!       print_usage ();
!     endif
!     tmp = __axis_label__ ("xlabel", varargin{2:end});
!   endif
! 
!   if (nargout > 0)
!     h = tmp;
    endif
  
  endfunction
*** ./scripts/plot/ylabel.m.orig27      2007-11-26 18:17:32.630596793 +0100
--- ./scripts/plot/ylabel.m     2007-11-26 18:19:57.526270468 +0100
***************
*** 19,24 ****
--- 19,25 ----
  
  ## -*- texinfo -*-
  ## @deftypefn {Function File} {} ylabel (@var{string})
+ ## @deftypefnx {Function File} {} ylabel (@var{h}, @var{string})
  ## See xlabel.
  ## @end deftypefn
  
***************
*** 26,39 ****
  
  function h = ylabel (varargin)
  
!   if (rem (nargin, 2) == 1)
!     if (nargout > 0)
!       h = __axis_label__ ("ylabel", varargin{:});
!     else
!       __axis_label__ ("ylabel", varargin{:});
      endif
    else
!     print_usage ();
    endif
  
  endfunction
--- 27,56 ----
  
  function h = ylabel (varargin)
  
!   if (isscalar (varargin{1}) && ishandle (varargin{1}))
!     ax = varargin {1};
!     if (! strcmp (get (ax, "type"), "axes"))
!       error ("ylabel: expecting first argument to be an axes object");
      endif
+     if (rem (nargin, 2) == 1)
+       print_usage ();
+     endif
+     oldh = gca ();
+     unwind_protect
+       axes (ax);
+       tmp = __axis_label__ ("ylabel", varargin{2:end});
+     unwind_protect_cleanup
+       axes (oldh);
+     end_unwind_protect
    else
!     if (rem (nargin, 2) != 1)
!       print_usage ();
!     endif
!     tmp = __axis_label__ ("ylabel", varargin{2:end});
!   endif
! 
!   if (nargout > 0)
!     h = tmp;
    endif
  
  endfunction
*** ./scripts/plot/plotyy.m.orig27      2007-11-26 17:53:13.762320893 +0100
--- ./scripts/plot/plotyy.m     2007-11-26 18:01:09.599278153 +0100
***************
*** 0 ****
--- 1,115 ----
+ ## Copyright (C) 2007 David Bateman
+ ##
+ ## This file is part of Octave.
+ ##
+ ## Octave is free software; you can redistribute it and/or modify it
+ ## under the terms of the GNU General Public License as published by
+ ## the Free Software Foundation; either version 3 of the License, or (at
+ ## your option) any later version.
+ ##
+ ## Octave is distributed in the hope that it will be useful, but
+ ## WITHOUT ANY WARRANTY; without even the implied warranty of
+ ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ ## General Public License for more details.
+ ##
+ ## You should have received a copy of the GNU General Public License
+ ## along with Octave; see the file COPYING.  If not, see
+ ## <http://www.gnu.org/licenses/>.
+ 
+ ## -*- texinfo -*-
+ ## @deftypefn {Function File} {} plotyy (@var{x1}, @var{y1}, @var{x2}, 
@var{y2})
+ ## @deftypefnx {Function File} {} plotyy (@dots{}, @var{fun})
+ ## @deftypefnx {Function File} {} plotyy (@dots{}, @var{fun1}, @var{fun2})
+ ## @deftypefnx {Function File} {} plotyy (@var{h}, @dots{})
+ ## @deftypefnx {Function File} address@hidden, @var{h1}, @var{h2}] =} plotyy 
(@dots{})
+ ## Plots two sets of data with independent y-axes. The arguments @var{x1} and
+ ## @var{y1} define the arguments for the first plot and @var{x1} and @var{y2}
+ ## for the second. 
+ ##
+ ## By default the arguments are evaluated with 
+ ## @code{feval (@@plot, @var{x}, @var{y})}. However the type of plot can be
+ ## modified with the @var{fun} argument, in which case the plots are
+ ## generated by @code{feval (@var{fun}, @var{x}, @var{y})}. @var{fun} can be 
+ ## a function handle, an inline function or a string of a function name.
+ ##
+ ## The function to use for each of the plots can be independently defined 
+ ## with @var{fun1} and @var{fun2}.
+ ##
+ ## If given, @var{h} defines the principal axis in which to plot the @var{x1}
+ ## and @var{y1} data. The return value @var{ax} is a two element vector with
+ ## the axis handles of the two plots. @var{h1} and @var{h2} are handles to
+ ## the objects generated by the plot commands.
+ ##
+ ## @example
+ ## @group
+ ## x = 0:0.1:2*pi; 
+ ## y1 = sin (x);
+ ## y2 = exp(x - 1);
+ ## plotyy(x, y1, x - 1, y2, @@plot, @@semilogy);
+ ## @end group
+ ## @end example
+ ## @end deftypefn
+ 
+ function [Ax, H1, H2] = plotyy (varargin)
+ 
+   if (isscalar (varargin{1}) && ishandle (varargin{1}))
+     ax = varargin {1};
+     if (! strcmp (get (ax, "type"), "axes"))
+       error ("plotyy: expecting first argument to be an axes object");
+     endif
+     if (nargin < 5)
+       print_usage();
+     endif
+     oldh = gca ();
+     unwind_protect
+       axes (ax);
+       newplot ();
+       [ax, h1, h2] = __plotyy__ (ax, varargin{2:end});
+     unwind_protect_cleanup
+       axes (oldh);
+     end_unwind_protect
+   else
+     if (nargin < 4)
+       print_usage();
+     endif
+     newplot ();
+     [ax, h1, h2] = __plotyy__ (gca (), varargin{:});
+   endif
+ 
+   if (nargout > 0)
+     Ax = ax;
+     H1 = h1;
+     H2 = h2;
+   endif
+ endfunction
+ 
+ function [ax, h1, h2] = __plotyy__ (ax, x1, y1, x2, y2, varargin)
+   if (nargin > 5)
+     fun1 = varargin{1};
+   else
+     fun1 = @plot;
+   endif
+   if (nargin > 6)
+     fun2 = varargin{2};
+   else
+     fun2 = fun1;
+   endif
+ 
+   xlim = [min([x1(:); x2(:)]), max([x1(:); x2(:)])];
+ 
+   h1 = feval (fun1, x1, y1);
+   set (ax(1), "ycolor", get (h1, "color"));
+   set (ax(1), "position", get (ax(1), "outerposition"));
+   set (ax(1), "xlim", xlim);
+ 
+   cf = gcf ();
+   set (cf, "nextplot", "add");
+   ax(2) = axes ("position", get (ax(1), "position"));
+   colors = get (ax(1), "colororder");
+   set (ax(2), "colororder", [colors(2:end,:); colors(1,:)]);
+ 
+   h2 = feval (fun2, x2, y2);
+   set (ax(2), "ycolor", get (h2, "color"));
+   set (ax(2), "xlim", xlim);
+   set (ax(2), "yaxislocation", "right");
+ endfunction
*** ./scripts/plot/Makefile.in.orig27   2007-11-26 17:00:32.362527247 +0100
--- ./scripts/plot/Makefile.in  2007-11-26 17:03:07.948632336 +0100
***************
*** 110,115 ****
--- 110,116 ----
    peaks.m \
    pie.m \
    plot.m \
+   plotyy.m \
    plot3.m \
    polar.m \
    print.m \
*** ./scripts/plot/__go_draw_axes__.m.orig27    2007-11-26 16:06:17.317499089 
+0100
--- ./scripts/plot/__go_draw_axes__.m   2007-11-26 17:42:55.068584669 +0100
***************
*** 39,44 ****
--- 39,46 ----
  
      if (! isempty (axis_obj.position))
        pos = axis_obj.position;
+       fprintf (plot_stream, "set lmargin 10;\n");
+       fprintf (plot_stream, "set rmargin 10;\n");
      endif
  
      if (! strcmp (axis_obj.__colorbar__, "none"))
***************
*** 74,86 ****
      if (! isempty (axis_obj.xlabel))
        t = get (axis_obj.xlabel);
        angle = t.rotation;
        if (isempty (t.string))
!       fputs (plot_stream, "unset xlabel;\n");
        else
        [tt, f, s] = __maybe_munge_text__ (enhanced, t, "string",
                                           have_newer_gnuplot);
!       fprintf (plot_stream, "set xlabel \"%s\" font \"%s,%d\"",
!                undo_string_escapes (tt), f, s);
        if (have_newer_gnuplot)
          ## Rotation of xlabel not yet support by gnuplot as of 4.2, but
          ## there is no message about it.
--- 76,94 ----
      if (! isempty (axis_obj.xlabel))
        t = get (axis_obj.xlabel);
        angle = t.rotation;
+       if (strcmpi (axis_obj.xaxislocation, "top"))
+       xlabel = "x2label";
+       else
+       xlabel = "xlabel";
+       endif
+       colorspec = get_text_colorspec (axis_obj.xcolor);
        if (isempty (t.string))
!       fprintf (plot_stream, "unset %s;\n", xlabel);
        else
        [tt, f, s] = __maybe_munge_text__ (enhanced, t, "string",
                                           have_newer_gnuplot);
!       fprintf (plot_stream, "set %s \"%s\" %s font \"%s,%d\"",
!                xlabel, undo_string_escapes (tt), colorspec, f, s);
        if (have_newer_gnuplot)
          ## Rotation of xlabel not yet support by gnuplot as of 4.2, but
          ## there is no message about it.
***************
*** 93,105 ****
      if (! isempty (axis_obj.ylabel))
        t = get (axis_obj.ylabel);
        angle = t.rotation;
        if (isempty (t.string))
!       fputs (plot_stream, "unset ylabel;\n");
        else
        [tt, f, s] = __maybe_munge_text__ (enhanced, t, "string",
                                           have_newer_gnuplot);
!       fprintf (plot_stream, "set ylabel \"%s\" font \"%s,%d\"",
!                undo_string_escapes (tt), f, s);
        if (have_newer_gnuplot)
          fprintf (plot_stream, " rotate by %f;\n", angle);
        endif
--- 101,119 ----
      if (! isempty (axis_obj.ylabel))
        t = get (axis_obj.ylabel);
        angle = t.rotation;
+       if (strcmpi (axis_obj.yaxislocation, "right"))
+       ylabel = "y2label";
+       else
+       ylabel = "ylabel";
+       endif
+       colorspec = get_text_colorspec (axis_obj.ycolor);
        if (isempty (t.string))
!       fprintf (plot_stream, "unset %s;\n", ylabel);
        else
        [tt, f, s] = __maybe_munge_text__ (enhanced, t, "string",
                                           have_newer_gnuplot);
!       fprintf (plot_stream, "set %s \"%s\" %s font \"%s,%d\"",
!                ylabel, undo_string_escapes (tt), colorspec, f, s);
        if (have_newer_gnuplot)
          fprintf (plot_stream, " rotate by %f;\n", angle);
        endif
***************
*** 110,122 ****
      if (! isempty (axis_obj.zlabel))
        t = get (axis_obj.zlabel);
        angle = t.rotation;
        if (isempty (t.string))
        fputs (plot_stream, "unset zlabel;\n");
        else
        [tt, f, s] = __maybe_munge_text__ (enhanced, t, "string",
                                           have_newer_gnuplot);
!       fprintf (plot_stream, "set zlabel \"%s\" font \"%s,%d\"",
!                undo_string_escapes (tt), f, s);
        if (have_newer_gnuplot)
          ## Rotation of zlabel not yet support by gnuplot as of 4.2, but
          ## there is no message about it.
--- 124,137 ----
      if (! isempty (axis_obj.zlabel))
        t = get (axis_obj.zlabel);
        angle = t.rotation;
+       colorspec = get_text_colorspec (axis_obj.zcolor);
        if (isempty (t.string))
        fputs (plot_stream, "unset zlabel;\n");
        else
        [tt, f, s] = __maybe_munge_text__ (enhanced, t, "string",
                                           have_newer_gnuplot);
!       fprintf (plot_stream, "set zlabel \"%s\" %s font \"%s,%d\"",
!                undo_string_escapes (tt), colorspec, f, s);
        if (have_newer_gnuplot)
          ## Rotation of zlabel not yet support by gnuplot as of 4.2, but
          ## there is no message about it.
***************
*** 971,1001 ****
            endif
          
          if (isnumeric (color))
!           if (have_newer_gnuplot)
!             colorspec = sprintf ("textcolor rgb \"#%02x%02x%02x\"",
!                      round (255*color));
!           else
!             if (isequal (color, [0,0,0]))
!               typ = -1;
!             elseif (isequal (color, [1,0,0]))
!               typ = 1;
!             elseif (isequal (color, [0,1,0]))
!               typ = 2;
!             elseif (isequal (color, [0,0,1]))
!               typ = 3;
!             elseif (isequal (color, [1,0,1]))
!               typ = 4;
!             elseif (isequal (color, [0,1,1]))
!               typ = 5;
!             elseif (isequal (color, [1,1,1]))
!               typ = -1;
!             elseif (isequal (color, [1,1,0]))
!               typ = 7;
!             else
!               typ = -1;
!             endif
!             colorspec = sprintf ("textcolor lt %d", typ);
!           endif
          endif
  
          if (nd == 3)
--- 986,992 ----
            endif
          
          if (isnumeric (color))
!           colorspec = get_text_colorspec (color);
          endif
  
          if (nd == 3)
***************
*** 1530,1560 ****
  function do_tics (obj, plot_stream)
    if (strcmpi (obj.xaxislocation, "top"))
      do_tics_1 (obj.xtickmode, obj.xtick, obj.xticklabelmode, obj.xticklabel,
!              "x2", plot_stream);
      do_tics_1 ("manual", [], obj.xticklabelmode, obj.xticklabel,
!              "x", plot_stream);
    else
      do_tics_1 (obj.xtickmode, obj.xtick, obj.xticklabelmode, obj.xticklabel,
!              "x", plot_stream);
      do_tics_1 ("manual", [], obj.xticklabelmode, obj.xticklabel,
!              "x2", plot_stream);
    endif
    if (strcmpi (obj.yaxislocation, "right"))
      do_tics_1 (obj.ytickmode, obj.ytick, obj.yticklabelmode, obj.yticklabel,
!              "y2", plot_stream);
      do_tics_1 ("manual", [], obj.yticklabelmode, obj.yticklabel,
!              "y", plot_stream);
    else
      do_tics_1 (obj.ytickmode, obj.ytick, obj.yticklabelmode, obj.yticklabel,
!              "y", plot_stream);
      do_tics_1 ("manual", [], obj.yticklabelmode, obj.yticklabel,
!              "y2", plot_stream);
    endif
    do_tics_1 (obj.ztickmode, obj.ztick, obj.zticklabelmode, obj.zticklabel,
!            "z", plot_stream);
  endfunction
  
! function do_tics_1 (ticmode, tics, labelmode, labels, ax, plot_stream)
    if (strcmpi (ticmode, "manual"))
      if (isempty (tics))
        fprintf (plot_stream, "unset %stics;\n", ax);
--- 1521,1552 ----
  function do_tics (obj, plot_stream)
    if (strcmpi (obj.xaxislocation, "top"))
      do_tics_1 (obj.xtickmode, obj.xtick, obj.xticklabelmode, obj.xticklabel,
!              obj.xcolor, "x2", plot_stream);
      do_tics_1 ("manual", [], obj.xticklabelmode, obj.xticklabel,
!              obj.xcolor, "x", plot_stream);
    else
      do_tics_1 (obj.xtickmode, obj.xtick, obj.xticklabelmode, obj.xticklabel,
!              obj.xcolor, "x", plot_stream);
      do_tics_1 ("manual", [], obj.xticklabelmode, obj.xticklabel,
!              obj.xcolor, "x2", plot_stream);
    endif
    if (strcmpi (obj.yaxislocation, "right"))
      do_tics_1 (obj.ytickmode, obj.ytick, obj.yticklabelmode, obj.yticklabel,
!              obj.ycolor, "y2", plot_stream);
      do_tics_1 ("manual", [], obj.yticklabelmode, obj.yticklabel,
!              obj.ycolor, "y", plot_stream);
    else
      do_tics_1 (obj.ytickmode, obj.ytick, obj.yticklabelmode, obj.yticklabel,
!              obj.ycolor, "y", plot_stream);
      do_tics_1 ("manual", [], obj.yticklabelmode, obj.yticklabel,
!              obj.ycolor, "y2", plot_stream);
    endif
    do_tics_1 (obj.ztickmode, obj.ztick, obj.zticklabelmode, obj.zticklabel,
!            obj.zcolor, "z", plot_stream);
  endfunction
  
! function do_tics_1 (ticmode, tics, labelmode, labels, color, ax, plot_stream)
!   colorspec = get_text_colorspec (color);
    if (strcmpi (ticmode, "manual"))
      if (isempty (tics))
        fprintf (plot_stream, "unset %stics;\n", ax);
***************
*** 1567,1573 ****
        ntics = numel (tics);
        nlabels = numel (labels);
        fprintf (plot_stream, "set format %s \"%%s\";\n", ax);
!       fprintf (plot_stream, "set %stics (", ax);
        for i = 1:ntics
          fprintf (plot_stream, " \"%s\" %g", labels(k++), tics(i))
          if (i < ntics)
--- 1559,1565 ----
        ntics = numel (tics);
        nlabels = numel (labels);
        fprintf (plot_stream, "set format %s \"%%s\";\n", ax);
!       fprintf (plot_stream, "set %stics %s (", ax, colorspec);
        for i = 1:ntics
          fprintf (plot_stream, " \"%s\" %g", labels(k++), tics(i))
          if (i < ntics)
***************
*** 1589,1595 ****
      endif
    else
      fprintf (plot_stream, "set format %s \"%%g\";\n", ax);
!     fprintf (plot_stream, "set %stics;\n", ax);
    endif
  endfunction
  
--- 1581,1618 ----
      endif
    else
      fprintf (plot_stream, "set format %s \"%%g\";\n", ax);
!     fprintf (plot_stream, "set %stics %s;\n", ax, colorspec);
!   endif
! endfunction
! 
! function colorspec = get_text_colorspec (color)
!   persistent have_newer_gnuplot ...
!       = compare_versions (__gnuplot_version__ (), "4.0", ">");
! 
!   if (have_newer_gnuplot)
!     colorspec = sprintf ("textcolor rgb \"#%02x%02x%02x\"",
!                        round (255*color));
!   else
!     if (isequal (color, [0,0,0]))
!       typ = -1;
!     elseif (isequal (color, [1,0,0]))
!       typ = 1;
!     elseif (isequal (color, [0,1,0]))
!       typ = 2;
!     elseif (isequal (color, [0,0,1]))
!       typ = 3;
!     elseif (isequal (color, [1,0,1]))
!       typ = 4;
!     elseif (isequal (color, [0,1,1]))
!       typ = 5;
!     elseif (isequal (color, [1,1,1]))
!       typ = -1;
!     elseif (isequal (color, [1,1,0]))
!       typ = 7;
!     else
!       typ = -1;
!     endif
!     colorspec = sprintf ("textcolor lt %d", typ);
    endif
  endfunction
  
***************
*** 1666,1672 ****
    for i = length (s) : -1 : 1
      ## special case for "\0"  and replace with "{/Symbol \306}'
      if (strncmp (m{i}, '\0', 2))
!       str = strcat (str(1:s(i) - 1), '{\Symbol \306}', str(s(i) + 2:end));
      else
        f = m{i}(2:end);
        if (isfield (sym, f))
--- 1689,1695 ----
    for i = length (s) : -1 : 1
      ## special case for "\0"  and replace with "{/Symbol \306}'
      if (strncmp (m{i}, '\0', 2))
!       str = strcat (str(1:s(i) - 1), '{/Symbol \306}', str(s(i) + 2:end));
      else
        f = m{i}(2:end);
        if (isfield (sym, f))
***************
*** 1856,1862 ****
    sym.Delta = '{/Symbol D}';
    sym.Phi = '{/Symbol F}';
    sym.Gamma = '/Symbol G}';
!   sym.vartheta = '{\Symbol J}';
    sym.Lambda = '{/Symbol L}';
    sym.Pi = '{/Symbol P}';
    sym.Theta = '{/Symbol Q}';
--- 1879,1885 ----
    sym.Delta = '{/Symbol D}';
    sym.Phi = '{/Symbol F}';
    sym.Gamma = '/Symbol G}';
!   sym.vartheta = '{/Symbol J}';
    sym.Lambda = '{/Symbol L}';
    sym.Pi = '{/Symbol P}';
    sym.Theta = '{/Symbol Q}';
*** ./scripts/plot/zlabel.m.orig27      2007-11-26 18:17:43.351054799 +0100
--- ./scripts/plot/zlabel.m     2007-11-26 18:20:04.359924895 +0100
***************
*** 19,24 ****
--- 19,25 ----
  
  ## -*- texinfo -*-
  ## @deftypefn {Function File} {} zlabel (@var{string})
+ ## @deftypefnx {Function File} {} zlabel (@var{h}, @var{string})
  ## See xlabel.
  ## @end deftypefn
  
***************
*** 26,39 ****
  
  function h = zlabel (varargin)
  
!   if (rem (nargin, 2) == 1)
!     if (nargout > 0)
!       h = __axis_label__ ("zlabel", varargin{:});
!     else
!       __axis_label__ ("zlabel", varargin{:});
      endif
    else
!     print_usage ();
    endif
  
  endfunction
--- 27,56 ----
  
  function h = zlabel (varargin)
  
!   if (isscalar (varargin{1}) && ishandle (varargin{1}))
!     ax = varargin {1};
!     if (! strcmp (get (ax, "type"), "axes"))
!       error ("zlabel: expecting first argument to be an axes object");
      endif
+     if (rem (nargin, 2) == 1)
+       print_usage ();
+     endif
+     oldh = gca ();
+     unwind_protect
+       axes (ax);
+       tmp = __axis_label__ ("zlabel", varargin{2:end});
+     unwind_protect_cleanup
+       axes (oldh);
+     end_unwind_protect
    else
!     if (rem (nargin, 2) != 1)
!       print_usage ();
!     endif
!     tmp = __axis_label__ ("zlabel", varargin{2:end});
!   endif
! 
!   if (nargout > 0)
!     h = tmp;
    endif
  
  endfunction
*** ./src/graphics.cc.orig27    2007-11-26 17:00:05.041913462 +0100
--- ./src/graphics.cc   2007-11-26 16:51:51.874929808 +0100
***************
*** 1101,1106 ****
--- 1101,1109 ----
      xticklabelmode ("auto"),
      yticklabelmode ("auto"),
      zticklabelmode ("auto"),
+     xcolor (),
+     ycolor (),
+     zcolor (),
      xscale ("linear"),
      yscale ("linear"),
      zscale ("linear"),
***************
*** 1290,1295 ****
--- 1293,1304 ----
      set_yticklabelmode (val);
    else if (name.compare ("zticklabelmode"))
      set_zticklabelmode (val);
+   else if (name.compare ("xcolor"))
+     set_xcolor (val);
+   else if (name.compare ("ycolor"))
+     set_ycolor (val);
+   else if (name.compare ("zcolor"))
+     set_zcolor (val);
    else if (name.compare ("xscale"))
      set_xscale (val);
    else if (name.compare ("yscale"))
***************
*** 1375,1380 ****
--- 1384,1392 ----
    xticklabelmode = "auto";
    yticklabelmode = "auto";
    zticklabelmode = "auto";
+   xcolor = color_property ("black");
+   ycolor = color_property ("black");
+   zcolor = color_property ("black");
    xscale = "linear";
    yscale = "linear";
    zscale = "linear";
***************
*** 1495,1500 ****
--- 1507,1515 ----
    m.assign ("xticklabelmode", xticklabelmode);
    m.assign ("yticklabelmode", yticklabelmode);
    m.assign ("zticklabelmode", zticklabelmode);
+   m.assign ("xcolor", xcolor);
+   m.assign ("ycolor", ycolor);
+   m.assign ("zcolor", zcolor);
    m.assign ("xscale", xscale);
    m.assign ("yscale", yscale);
    m.assign ("zscale", zscale);
***************
*** 1603,1608 ****
--- 1618,1629 ----
      retval = yticklabelmode;
    else if (name.compare ("zticklabelmode"))
      retval = zticklabelmode;
+   else if (name.compare ("xcolor"))
+     retval = xcolor;
+   else if (name.compare ("ycolor"))
+     retval = ycolor;
+   else if (name.compare ("zcolor"))
+     retval = zcolor;
    else if (name.compare ("xscale"))
      retval = xscale;
    else if (name.compare ("yscale"))
***************
*** 1713,1718 ****
--- 1734,1742 ----
    m["xticklabelmode"] = "auto";
    m["yticklabelmode"] = "auto";
    m["zticklabelmode"] = "auto";
+   m["xcolor"] = color_property("black");
+   m["ycolor"] = color_property("black");
+   m["zcolor"] = color_property("black");
    m["xscale"] = "linear";
    m["yscale"] = "linear";
    m["zscale"] = "linear";
*** ./src/graphics.h.in.orig27  2007-11-26 17:00:11.288596516 +0100
--- ./src/graphics.h.in 2007-11-26 16:52:32.295879898 +0100
***************
*** 1187,1192 ****
--- 1187,1195 ----
        octave_value xticklabelmode
        octave_value yticklabelmode
        octave_value zticklabelmode
+       color_property xcolor
+       color_property ycolor
+       color_property zcolor
        octave_value xscale
        octave_value yscale
        octave_value zscale
2007-11-26  David Bateman  <address@hidden>

        * plot/plotyy.m: New function
        * plot/Makefile.in (SOURCES): Add it here.
        * plot/__go_draw_axes__.m: Force axis margins for plotyy. Set text
        color for {x|y|z}label and {x|y|z}tics. Also force the label of 
        {x|y}label to respect the axis position.
        * plot/xlabel.m, plot/ylabel.m, plot/zlabel.m: Accept an axis
        handle as the first argument.
        
2007-11-26  David Bateman  <address@hidden>

        * graphics.cc (class axes): Add the {x|y|z}color color property.
        * graphics.h.in (class axes): ditto.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]