bugGNU Octave - Bugs: bug #47765, legend text covers the line and...

 
 

bug #47765: legend text covers the line and marker.

Submitter:  Guan <xyzhaoguan>
Submitted:  Fri 22 Apr 2016 10:48:32 PM UTC
   
 
Category:  Plotting with OpenGL Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * 4.0.2 Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Mon 25 Apr 2016 04:43:22 PM UTC, comment #10: 

Thanks Rik.

Pantxo Diribarne <pantxo>
Group Member
Mon 25 Apr 2016 03:11:38 PM UTC, comment #9: 

I found another instance where a double-click in FLTK would trigger an autoscale.  I fixed that too and checked all three changes in under Pantxo's name (since he did the original work) on the stable branch (http://hg.savannah.gnu.org/hgweb/octave/rev/9191c24fb329).  This will be part of the next bug fix release (4.0.3) or more likely Octave will move to 4.2.0.

Rik <rik5>
Group administrator
Sun 24 Apr 2016 06:54:27 PM UTC, comment #8: 

Thanks Rik for pointing me to fltk. I attached a new patch.

(file #36990)

Pantxo Diribarne <pantxo>
Group Member
Sun 24 Apr 2016 06:03:35 PM UTC, comment #7: 

@Pantxo: The patch works fine for Qt.  Could you also update the selection routine in _init_fltk_.cc?  We don't want this to work for some toolkits and fail for others.

The relevant routine is in _init_fltk_.cc.


  void set_axes_currentpoint (graphics_object ax, int px, int py)
  {
    if (ax.valid_object () && ax.isa ("axes"))
      {
        axes::properties& ap =
          dynamic_cast<axes::properties&> (ax.get_properties ());

        Matrix x_zlim = ap.get_transform_zlim ();
        Matrix pos (2, 3, 0.0);

        // front point (nearest to the viewer)
        ColumnVector tmp = ap.get_transform ().untransform (px, py, x_zlim(0));
        pos(0,0) = tmp(0);
        pos(0,1) = tmp(1);
        pos(0,2) = tmp(2);

        // back point (furthest from the viewer)
        tmp = ap.get_transform ().untransform (px, py, x_zlim(1));
        pos(1,0) = tmp(0);
        pos(1,1) = tmp(1);
        pos(1,2) = tmp(2);

        ap.set_currentpoint (pos);
        fp.set_currentaxes (ap.get___myhandle__ ().value ());
      }
  }



Rik <rik5>
Group administrator
Sun 24 Apr 2016 08:04:24 AM UTC, comment #6: 

I attached a patch implementing the snippet from comment #5.

(file #36984)

Pantxo Diribarne <pantxo>
Group Member
Sat 23 Apr 2016 11:59:22 PM UTC, comment #5: 

Autoscaling is not the only problem. What if you try "plot (1:10)" after clicking the legend, you probably don't want the next plot to be drawn there.

I think we should only prevent the selection from changing a legend/colorbar into the currentaxes. This happens in canvasMousePressEvent, something like:


...
if (axesObj)
  {
    if (axesObj.get_properties ().handlevisibility_is ("on") &&
        axesObj.get ("tag").string_value () != "legend" &&
        axesObj.get ("tag").string_value () != "colorbar")
      Utils::properties<figure> (figObj)
        .set_currentaxes (axesObj.get_handle ().as_octave_value ());
    if (! currentObj)
      currentObj = axesObj;
  }
...


Pantxo Diribarne <pantxo>
Group Member
Sat 23 Apr 2016 05:03:47 PM UTC, comment #4: 

Confirmed.  I agree with Pantxo's analysis as well.

I'm not sure whether the easiest solution would be to prevent a legend axes object from ever getting selected, or whether we need to disable autoscaling when the axes object is a legend.

For the second choice, the code is in libgui/graphics/Canvas.cc.


void
Canvas::canvasAutoAxes (const graphics_handle& handle)
{
  gh_manager::auto_lock lock;

  graphics_object go = gh_manager::get_object (handle);

  if (go.valid_object ())
    {
      figure::properties& fp = Utils::properties<figure> (go);

      graphics_handle ah = fp.get_currentaxes ();

      graphics_object ax = gh_manager::get_object (ah);

      if (ax.valid_object ())
        {
          axes::properties& ap = Utils::properties<axes> (ax);

          autoscale_axes (ap);

          redraw (true);
        }
    }
}


After getting the currentaxes into the variable ah, we could check that it doesn't have the legend property before continuing.

Rik <rik5>
Group administrator
Sat 23 Apr 2016 09:24:02 AM UTC, comment #3: 

I can confirm this with Qt toolkit.
I think the whole problem lies in autoscaling legend objects. The object selection mechanism is not well behaved here: when clicking on a legend, the currentobject property of the figure should be changed to reflect the fact that the legend has been selected (this works well), but a legend should never become the currentaxes.


plot (1:10)
hl = legend ("toto")
## Now click on the legend boundary
get (gcf, "currentobject") == hl
#-> 1 (so far so good)
get (gcf, "currentaxes") == hl
#-> 1 (this should not happen)


Pantxo Diribarne <pantxo>
Group Member
Sat 23 Apr 2016 12:06:46 AM UTC, comment #2: 

Before print to pdf, please click the legend and click "Autoscale", you will see the difference.

Let's make it more clear with the following code:

plot(a,b,'o-.')
legend('test')

The line style (dotted dash line) is not shown clearly with original plot. After selecting the legend and "Autoscale", the line and marker are shown correctly.

It also depends on the figure size, and font size. When the figure size is large and font size is small, this problem is not very obvious. But you still can see the difference when after clicking "Autoscale".

Guan <xyzhaoguan>
Fri 22 Apr 2016 11:19:19 PM UTC, comment #1: 

This works for me.  I used the following code with 4.0.2 on Kubuntu 15.10


a=(1:0.4:10)
b=(1:23)
plot(a,b)
legend('test')
print test3.pdf


Also, what does


graphics_toolkit


return?  It should be qt.



(file #36983)

Rik <rik5>
Group administrator
Fri 22 Apr 2016 10:48:32 PM UTC, original submission:  

The legend texts always cover the legend lines.

a=(1:0.4:10)
b=(1:23)
plot(a,b)
legend('test')

This code generates test1.pdf.
After I click the legend and then click the "Autoscale" button in Figure 1. I got test2.pdf.

It seems the staring position of the text need to be adjusted and the size of legend box needs to be adjusted accordingly.

I tested 4.02 under windows 7, and 4.0.0 under ubuntu.

Guan <xyzhaoguan>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #36990:  legend_ax3.patch added by pantxo (2KiB - text/x-diff)
file #36984:  legend_ax.patch added by pantxo (1KiB - text/x-diff)
file #36983:  test3.pdf added by rik5 (3KiB - application/pdf)
file #36981:  test1.pdf added by xyzhaoguan (3KiB - application/pdf)
file #36982:  test2.pdf added by xyzhaoguan (3KiB - application/pdf)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by pantxo (Posted a comment)
  • -email is unavailable- added by rik5 (Updated the item)
  • -email is unavailable- added by xyzhaoguan (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 12 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-04-25 rik5 StatusPatch Submitted Fixed
        Open/ClosedOpen Closed
    2016-04-24 pantxo Attached File- Added legend_ax3.patch, #36990
    2016-04-24 pantxo Attached File- Added legend_ax.patch, #36984
        StatusConfirmed Patch Submitted
    2016-04-23 pantxo CategoryPlotting Plotting with OpenGL
        Item GroupOther Incorrect Result
        StatusWorks For Me Confirmed
    2016-04-22 rik5 Attached File- Added test3.pdf, #36983
        StatusNone Works For Me
    2016-04-22 xyzhaoguan Attached File- Added test1.pdf, #36981
        Attached File- Added test2.pdf, #36982

    Back to the top

    Powered by Savane 3.13-3230.
    Corresponding source code