bugGNU Octave - Bugs: bug #62511, Use subplot() and image() will...

 
 

bug #62511: Use subplot() and image() will draw upside down image

Submitter:  Glite <linuxbckp>
Submitted:  Mon 23 May 2022 03:40:13 PM UTC
   
 
Category:  Plotting Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Invalid / Not an Octave Bug Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * 6.4.0 Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 24 May 2022 03:54:53 AM UTC, comment #5: 

Matlab documentation is clear that when image is called with "cdata" property, i.e., low-level call, then the "ydir" property is not changed.  See https://www.mathworks.com/help/matlab/ref/image.html.

Also tested in Matlab,


figure;
image (axes (), 'cdata', get (0, "defaultimagecdata"));


and axes "ydir" property is "normal" and image is reversed.

If you want to call the high-level form of image() then just supply the axes handle and the color data like so


image(a, imread('open_file_with_presentation.svg')





Rik <rik5>
Group administrator
Tue 24 May 2022 03:49:24 AM UTC, comment #4: 

In axes returned by subplot(), we can addlistener() to createfcn and dellistener() to deletefcn. It is workable.

Glite <linuxbckp>
Tue 24 May 2022 03:31:38 AM UTC, comment #3: 

In this way we can keep image() doc unchanged(do not inverse axes by itself when called by subplot()) and keep the drawing behavior the same to Matlab.

Glite <linuxbckp>
Tue 24 May 2022 03:24:25 AM UTC, comment #2: 

At this situation in Matlab, the y-axis is automatically inversed, so it's still a bug and should be fixed.
So I suggest subplot() should do inverse opreation with image().

Glite <linuxbckp>
Mon 23 May 2022 07:30:08 PM UTC, comment #1: 

This is not specific to axes created using subplot, e.g., AFAICS both of the images produced by the standalone script below are reversed


figure;
image (axes (), 'cdata', get (0, "defaultimagecdata"));
figure;
image (subplot (1,2,1), 'cdata', get (0, "defaultimagecdata"));


This is due to how the `image` function is called. With only property/value arguments (as here ... well, except the first axes handle argument) the "low level" behavior is chosen, so that among others the parent axes "ydir" property is untouched and kept "normal" instead of "reversed" with the "high level" calling form. See the documentation for image:


... When the only inputs to 'image' are property/value pairs the Low-Level form is used which creates a new instance of an image object and inserts it in the current axes.


Marking the status as "invalid", but the documentation could probably be enhanced. Do you have suggestions?

Pantxo Diribarne <pantxo>
Group Member
Mon 23 May 2022 03:40:13 PM UTC, original submission:  

Use subplot() ,then use image() to draw a image, the result is upside down.

Here is my code:

>> image(a, 'cdata', imread('open_file_with_presentation.svg'))
>> figure;
>> a=subplot(2, 3, 1);
>> image(a, 'cdata', imread('open_file_with_presentation.svg'))


The upside down effect is shown as this attach png file.

Glite <linuxbckp>

 

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

Attach Files:
   
   
Comment:
   

Attached Files

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by pantxo (Posted a comment)
  • -email is unavailable- added by linuxbckp (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 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-05-24 rik5 Open/ClosedOpen Closed
    2022-05-23 pantxo StatusNone Invalid / Not an Octave Bug
    2022-05-23 linuxbckp Attached File- Added ksnip_20220523-233002.png, #53244

    Back to the top

    Powered by Savane 3.13-bb6a.
    Corresponding source code