bugGNU Octave - Bugs: bug #49490, Display of images for axes...


bug #49490: Display of images for axes partially outside a figure

Submitted by:  Guillaume <gyom>
Submitted on:  Mon 31 Oct 2016 04:44:16 PM UTC  
Category:  Plotting Severity:  3 - Normal
Priority:  3 - Low Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Guillaume Open/Closed:  Closed
Release:  dev Operating System:  GNU/Linux

Add a New Comment (Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


( Jump to the original submission)

Sun 04 Nov 2018 07:45:58 PM UTC, comment #10: 

Thanks, I pushed the patch here:


Closing report and hoping to not open it again.

Pantxo Diribarne <pantxo>
Project Member
Fri 02 Nov 2018 09:55:08 AM UTC, comment #9: 

@Pantxo: the issue I had was indeed with an image displayed with ydir=normal. I applied your patch and, so far, I haven't observed any problem when displaying images.

Guillaume <gyom>
Fri 02 Nov 2018 09:39:07 AM UTC, comment #8: 

I attached a patch that fixes the regression for me. I don't claim that I tested all combinations of axes x/ydir, image x/ydata and clipping so could someone else test?

(file #45348)

Pantxo Diribarne <pantxo>
Project Member
Fri 02 Nov 2018 08:51:19 AM UTC, comment #7: 

@Guillaume: Yes, and it is not a small mistake: I omitted to take xdir/ydir into account so any image that is not displayed with xdir=normal and ydir=reverse won't be rendered correctly (e.g. colorbars). 

Pantxo Diribarne <pantxo>
Project Member
Thu 01 Nov 2018 06:20:27 PM UTC, comment #6: 

Thanks for looking into this, Pantxo. I confirm that the example in the original submission works fine. There must be a mistake somewhere though as I now see situations where an image is not displayed while its axis being entirely within a figure. I will try to create a small example to share by tomorrow.

Guillaume <gyom>
Thu 01 Nov 2018 06:00:23 PM UTC, comment #5: 

I pushed the patch here:


Closing report as fixed since it has been confirmed to work.

Pantxo Diribarne <pantxo>
Project Member
Thu 01 Nov 2018 05:14:44 PM UTC, comment #4: 

@Rik: Ok, I'll fix this and push the patch.

Pantxo Diribarne <pantxo>
Project Member
Thu 01 Nov 2018 05:12:12 PM UTC, comment #3: 

Patch works fine.  Only comment is that line 68 went from being blank, to being blank with trailing spaces. 

Rik <rik5>
Project Administrator
Thu 01 Nov 2018 03:15:04 PM UTC, comment #2: 

I attached a patch that fixes image rendering when "clipping" = "off", it also takes care of the case when clipping is "on" but the axes limits are outside the figure limits.

I used std::numeric_limits<float>::epsilon () for the bottom left limit of the figure (instead of 0) which also fixes bug #52303 for me.

(file #45345)

Pantxo Diribarne <pantxo>
Project Member
Wed 02 Nov 2016 03:35:44 PM UTC, comment #1: 

Confirmed.  The code to modify is in libinterp/corefcn/gl-render.cc.  The function draw_image has some notes and a FIXME comment about this particular case.

    // OpenGL won't draw any of the image if its origin is outside the
    // viewport/clipping plane so we must do the clipping ourselves.

    int j0, j1, i0, i1;
    j0 = 0, j1 = w;
    i0 = 0, i1 = h;

    float im_xmin = x(0) - nor_dx/2;
    float im_xmax = x(1) + nor_dx/2;
    float im_ymin = y(0) - nor_dy/2;
    float im_ymax = y(1) + nor_dy/2;
    if (props.is_clipping ()) // clip to axes
        if (im_xmin < xmin)
          j0 += (xmin - im_xmin)/nor_dx + 1;
        if (im_xmax > xmax)
          j1 -= (im_xmax - xmax)/nor_dx;

        if (im_ymin < ymin)
          i0 += (ymin - im_ymin)/nor_dy + 1;
        if (im_ymax > ymax)
          i1 -= (im_ymax - ymax)/nor_dy;
    else // clip to viewport
        GLfloat vp[4];
        glGetFloatv (GL_VIEWPORT, vp);
        // FIXME: actually add the code to do it!

It looks like the else branch is simply unimplemented.

Rik <rik5>
Project Administrator
Mon 31 Oct 2016 04:44:16 PM UTC, original submission:  

When the position of an axis is partially outside a figure, its content is not displayed at all if it's an image:

set(gca,'position',[0 0 1 1])
% image is displayed in the entire figure
set(gca,'position',[0 0 1 1.1])
% image disappears

but is displayed fine of it's a plot:

set(gca,'position',[0 0 1 1])
% plot is displayed in the entire figure
set(gca,'position',[0 0 1 2])
% plot is still partially displayed

Guillaume <gyom>


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

Attach Files:

Attached Files
file #45348:  clip_figure3.patch added by pantxo (2KiB - text/x-patch)
file #45345:  clip_figure.patch added by pantxo (2KiB - text/x-patch)


Depends on the following items: None found

Items that depend on this one: None found


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

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.




    Follow 14 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-11-04 pantxo StatusPatch Submitted => Fixed
        Open/ClosedOpen => Closed
    2018-11-02 pantxo Attached File- => Added clip_figure3.patch, #45348
        StatusIn Progress => Patch Submitted
    2018-11-02 pantxo StatusFixed => In Progress
        Open/ClosedClosed => Open
    2018-11-01 pantxo StatusPatch Reviewed => Fixed
        Open/ClosedOpen => Closed
    2018-11-01 rik5 StatusPatch Submitted => Patch Reviewed
    2018-11-01 pantxo Attached File- => Added clip_figure.patch, #45345
        Item GroupMatlab Compatibility => Incorrect Result
        StatusConfirmed => Patch Submitted
    2016-11-02 rik5 Priority5 - Normal => 3 - Low
        StatusNone => Confirmed

    Back to the top

    Powered by Savane 3.5