octave-maintainers
[Top][All Lists]
Advanced

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

Re: plotyy problems and change proposal


From: David Bateman
Subject: Re: plotyy problems and change proposal
Date: Mon, 03 Dec 2007 11:21:27 +0100
User-agent: Thunderbird 1.5.0.7 (X11/20060921)

Michael Goffioul wrote:
> On 12/2/07, David Bateman <address@hidden> wrote:
>   
>> What I meant is that there is nothing to stop you changing the
>> properties of one of the axis objects and that without listeners there
>> is no way to get these changes automatically reflected in the second set
>> of axis. In fact its probably better for the gnuplot code to calculate
>> the size of the axis automatically for first axis and use that to force
>> the size of the second axis..
>>     
>
> You can also screw up the plot in Matlab:
>
> h = plotyy(1:10, rand(1,10), 1:10, rand(1,10))
> set(h(1), 'position', [0.5 0.5 0.4 0.4])
>
> There's no listener on the position property. However, both axes are given
> the same position in normalized units (not the outerposition). This means
> that when resizing the figure window, the axes will still be aligned; no
> listener is needed.
>
>   
>> Alright, then what about the attached. Does this do what you want?
>>     
>
> This looks good. Although I would avoid hardcoding twice the axes position
> and use something like set(ax(2), 'position', get(ax(1), 'position')).
>
> Michael.
>
>   
Ok, then use this instead.

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/plotyy.m.orig41      2007-12-02 21:05:09.652248667 +0100
--- ./scripts/plot/plotyy.m     2007-12-03 11:20:18.924753904 +0100
***************
*** 95,101 ****
    h1 = feval (fun1, x1, y1);
  
    set (ax(1), "ycolor", getcolor (h1(1)));
!   set (ax(1), "position", get (ax(1), "outerposition"));
    set (ax(1), "xlim", xlim);
  
    cf = gcf ();
--- 95,102 ----
    h1 = feval (fun1, x1, y1);
  
    set (ax(1), "ycolor", getcolor (h1(1)));
!   set (ax(1), "position", [0.11 0.13 0.78 0.73]);
!   set (ax(1), "activepositionproperty", "position");
    set (ax(1), "xlim", xlim);
  
    cf = gcf ();
***************
*** 107,114 ****
    h2 = feval (fun2, x2, y2);
    set (ax(2), "yaxislocation", "right");
    set (ax(2), "ycolor", getcolor (h2(1)));
!   set (ax(2), "position", get (ax(1), "outerposition"));
    set (ax(2), "xlim", xlim);
  endfunction
  
  function color = getcolor (ax)
--- 108,117 ----
    h2 = feval (fun2, x2, y2);
    set (ax(2), "yaxislocation", "right");
    set (ax(2), "ycolor", getcolor (h2(1)));
!   set (ax(2), "position", get (ax(1), "position"));
!   set (ax(2), "activepositionproperty", "position");
    set (ax(2), "xlim", xlim);
+   set (ax(2), "color", "none");
  endfunction
  
  function color = getcolor (ax)
*** ./scripts/plot/__go_draw_axes__.m.orig41    2007-12-02 21:04:00.021859809 
+0100
--- ./scripts/plot/__go_draw_axes__.m   2007-12-02 22:36:33.310857488 +0100
***************
*** 33,50 ****
  
      ## Set axis properties here?
      pos = [0, 0, 1, 1];
!     if (! isempty (axis_obj.outerposition))
!       pos = axis_obj.outerposition;
!     endif
! 
!     ymirror = true;
!     if (! isempty (axis_obj.position))
!       pos = axis_obj.position;
!       fprintf (plot_stream, "set tmargin 3;\n");
!       fprintf (plot_stream, "set bmargin 3;\n");
!       fprintf (plot_stream, "set lmargin 10;\n");
!       fprintf (plot_stream, "set rmargin 10;\n");
        ymirror = false;
      endif
  
      if (! strcmp (axis_obj.__colorbar__, "none"))
--- 33,52 ----
  
      ## Set axis properties here?
      pos = [0, 0, 1, 1];
!     if (strcmp (axis_obj.activepositionproperty, "outerposition"))
!       ymirror = true;
!       if (! isempty (axis_obj.outerposition))
!       pos = axis_obj.outerposition;
!       endif
!     else
        ymirror = false;
+       if (! isempty (axis_obj.position))
+       pos = axis_obj.position;
+       fprintf (plot_stream, "set tmargin 0;\n");
+       fprintf (plot_stream, "set bmargin 0;\n");
+       fprintf (plot_stream, "set lmargin 0;\n");
+       fprintf (plot_stream, "set rmargin 0;\n");
+       endif
      endif
  
      if (! strcmp (axis_obj.__colorbar__, "none"))
*** ./src/graphics.h.in.orig41  2007-12-02 20:45:20.220934450 +0100
--- ./src/graphics.h.in 2007-12-02 22:12:51.736582571 +0100
***************
*** 1376,1381 ****
--- 1376,1382 ----
        octave_value xticklabelmode
        octave_value yticklabelmode
        octave_value zticklabelmode
+       color_property color a
        color_property xcolor
        color_property ycolor
        color_property zcolor
***************
*** 1391,1396 ****
--- 1392,1398 ----
        octave_value visible
        octave_value nextplot
        octave_value outerposition
+       radio_property activepositionproperty a
        radio_property __colorbar__ a
     END_PROPERTIES
  
*** ./src/graphics.cc.orig41    2007-12-02 20:45:10.941415700 +0100
--- ./src/graphics.cc   2007-12-02 22:26:02.306582365 +0100
***************
*** 1114,1119 ****
--- 1114,1120 ----
      xticklabelmode ("auto"),
      yticklabelmode ("auto"),
      zticklabelmode ("auto"),
+     color (color_values(0, 0, 0), radio_values ("flat|none|interp")),
      xcolor (),
      ycolor (),
      zcolor (),
***************
*** 1129,1134 ****
--- 1130,1136 ----
      visible ("on"),
      nextplot ("replace"),
      outerposition (),
+     activepositionproperty (radio_values ("{outerposition}|position")),
      __colorbar__ (radio_values 
("{none}|north|south|east|west|northoutside|southoutside|eastoutside|westoutside"))
  {
    Matrix tlim (1, 2, 0.0);
***************
*** 1306,1311 ****
--- 1308,1315 ----
      set_yticklabelmode (val);
    else if (name.compare ("zticklabelmode"))
      set_zticklabelmode (val);
+   else if (name.compare ("color"))
+     set_color (val);
    else if (name.compare ("xcolor"))
      set_xcolor (val);
    else if (name.compare ("ycolor"))
***************
*** 1336,1341 ****
--- 1340,1347 ----
      set_nextplot (val);
    else if (name.compare ("outerposition"))
      set_outerposition (val);
+   else if (name.compare ("activepositionproperty"))
+     set_activepositionproperty (val);
    else if (name.compare ("__colorbar__"))
      set___colorbar__ (val);
    else
***************
*** 1397,1402 ****
--- 1403,1409 ----
    xticklabelmode = "auto";
    yticklabelmode = "auto";
    zticklabelmode = "auto";
+   color = color_property (color_values (0, 0, 0), 
radio_values("flat|none|interp"));
    xcolor = color_property ("black");
    ycolor = color_property ("black");
    zcolor = color_property ("black");
***************
*** 1427,1432 ****
--- 1434,1440 ----
        outerposition = touterposition;
      }
  
+   activepositionproperty = radio_property (radio_values 
("{outerposition}|position"));
    __colorbar__  = radio_property (radio_values 
("{none}|north|south|east|west|northoutside|southoutside|eastoutside|westoutside"));
  
    delete_children ();
***************
*** 1520,1525 ****
--- 1528,1534 ----
    m.assign ("xticklabelmode", xticklabelmode);
    m.assign ("yticklabelmode", yticklabelmode);
    m.assign ("zticklabelmode", zticklabelmode);
+   m.assign ("color", color);
    m.assign ("xcolor", xcolor);
    m.assign ("ycolor", ycolor);
    m.assign ("zcolor", zcolor);
***************
*** 1535,1540 ****
--- 1544,1550 ----
    m.assign ("visible", visible);
    m.assign ("nextplot", nextplot);
    m.assign ("outerposition", outerposition);
+   m.assign ("activepositionproperty", activepositionproperty);
    m.assign ("__colorbar__", __colorbar__);
  
    return m;
***************
*** 1631,1636 ****
--- 1641,1648 ----
      retval = yticklabelmode;
    else if (name.compare ("zticklabelmode"))
      retval = zticklabelmode;
+   else if (name.compare ("color"))
+     retval = color;
    else if (name.compare ("xcolor"))
      retval = xcolor;
    else if (name.compare ("ycolor"))
***************
*** 1661,1666 ****
--- 1673,1680 ----
      retval = nextplot;
    else if (name.compare ("outerposition"))
      retval = outerposition;
+   else if (name.compare ("activepositionproperty"))
+     retval = activepositionproperty;
    else if (name.compare ("__colorbar__"))
      retval = __colorbar__;
    else
***************
*** 1747,1752 ****
--- 1761,1767 ----
    m["xticklabelmode"] = "auto";
    m["yticklabelmode"] = "auto";
    m["zticklabelmode"] = "auto";
+   m["color"] = color_property (color_values (0, 0, 0), 
radio_values("flat|none|interp"));
    m["xcolor"] = color_property ("black");
    m["ycolor"] = color_property ("black");
    m["zcolor"] = color_property ("black");
***************
*** 1772,1777 ****
--- 1787,1793 ----
    touterposition(3) = 1;
  
    m["outerposition"] = touterposition;
+   m["activepositionproperty"] =  radio_property (radio_values 
("{outerposition}|position"));
    m["__colorbar__"] = radio_property (radio_values 
("{none}|north|south|east|west|northoutside|southoutside|eastoutside|westoutside"));
  
    return m;
2007-12-02  David Bateman  <address@hidden>

        * plot/plotyy.m: Use activepositionproperty property of axes
        object. Set second axis color to "none".
        * plot/__go_draw_axes__.m: Respect the activepositionproperty
        property of the axis objects.

2007-12-02  David Bateman  <address@hidden>

        * graphics.cc (class axes): Add color and activepositionproperty
        properties to axis objects.
        * graphics.h.in (class axes): ditto.

reply via email to

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