bugGNU Octave - Bugs: bug #51049, hgload figure and contents are not...

 
 

bug #51049: hgload figure and contents are not sized correctly

Submitted by:  Marc Dirix <dirixmjm>
Submitted on:  Wed 17 May 2017 08:48:02 AM UTC  
 
Category: Octave FunctionSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Incorrect Result
Status: DuplicateAssigned to: None
Originator Name: Marc DirixOpen/Closed: Closed
Release: 4.2.1Operating System: Microsoft Windows

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 Jump to the original submission)

Thu 18 May 2017 06:47:08 PM UTC, comment #17:

It seems like all issues here are described adequately in other bug reports. See bug #45833, bug #47337, and bug #48067.

Mike Miller <mtmiller>
Project Administrator
Thu 18 May 2017 01:04:45 PM UTC, comment #16:

I know. The original topic was different.

Marc Dirix <dirixmjm>
Thu 18 May 2017 01:01:08 PM UTC, comment #15:

I did not realize this is on Windows.
There is a bug report for this:

https://savannah.gnu.org/bugs/?47337

Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Thu 18 May 2017 12:51:41 PM UTC, comment #14:

I presume it is the one bundled with Octave 4.2.1 for windows.
How can I check this?

Marc Dirix <dirixmjm>
Thu 18 May 2017 12:47:23 PM UTC, comment #13:

What is your gl2ps version?
You should get at least 1.3.9
The current version is 1.4.0

Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Thu 18 May 2017 09:21:22 AM UTC, comment #12:

using the propesed line "graphics_toolkit fltk" the figure opens with correct scaling.

fltk, however, has other problems. Not in the least, using print with fltk crashes octave. With output in the command window:
GL2PS warning: Unknown token in buffer
GL2PS warning: Unknown token in buffer
GL2PS warning: Unknown token in buffer
GL2PS warning: Unknown token in buffer
GL2PS warning: Unknown token in buffer
(But that is for another bug report).

Marc Dirix <dirixmjm>
Wed 17 May 2017 11:35:38 PM UTC, comment #11:

This might be the same as bug #48067.

Can you try your script after "close all; graphics_toolkit fltk" and see whether the problem occurs?

Mike Miller <mtmiller>
Project Administrator
Wed 17 May 2017 08:11:12 PM UTC, comment #10:

You are right, slowly resizing the figure window fixes it.
It seems after loading that the position vector is not set correctly:

>> hgload ("plot_to_continue.txt")
>> get(gcf,'position')

ans =

300 202 560 417

(now slowly resizing with the mouse after which the axis get the proper size)

>> get(gcf,'position')

ans =

200 102 1200 798

Marc Dirix <dirixmjm>
Wed 17 May 2017 07:05:21 PM UTC, comment #9:

Your example works fine for me.

It looks like the figure is only rendering the axes area too small. Does calling "drawnow" fix it? Does resizing the figure window slowly with the mouse fix it? Does setting the "position" property of the figure to resize it fix it?

All of these suggestions should be done in the command window after the TestPlot script returns to the command prompt. If any of these fix the issue, then I believe there have been several other open bug reports about resizing graphics not taking effect immediately, especially when done in a script.

Mike Miller <mtmiller>
Project Administrator
Wed 17 May 2017 06:40:43 PM UTC, comment #8:

sure. please find a short exampled attached.

to be clear, Kai's example is also working for me. So, most probably there is something in my code that changes the behaviour.

(file #40724)

Marc Dirix <dirixmjm>
Wed 17 May 2017 03:57:37 PM UTC, comment #7:

Can you post a minimal example that demonstrates the problem with the remaining scaling issue? It might help to also include a screenshot of the figure before and after, in case it can't be reproduced by me or others. Kai's simple example works fine for me.

Mike Miller <mtmiller>
Project Administrator
Wed 17 May 2017 02:26:28 PM UTC, comment #6:

Mike - yes that may very well be the problem. I use some classes to hold data and generate plots from them. Maybe they are referenced from inside the figure somewhere.

Marc Dirix <dirixmjm>
Wed 17 May 2017 02:22:16 PM UTC, comment #5:

Kai - I think it's the difference between wanting to save the figure properties to be reloaded, which is what hgsave and hgload do, versus saving the image of the figure to be used in a document or presentation. The .fig extension is what Matlab uses for a .mat file that contains figure properties, I think, not the same as the XFig graphics format.

Marc - yes, hgsave and hgload probably have some issues and areas that could be improved.

The specific error message referred to here means that the save() function is being called on an object, which Octave does not yet support. Do you have an object saved somewhere in your figure properties, maybe as a custom property or a callback or something? Can you give an example of one of the more complex figures that causes this error?

Otherwise we can probably close this as a duplicate of bug #45833.

Mike Miller <mtmiller>
Project Administrator
Wed 17 May 2017 02:19:48 PM UTC, comment #4:

"fig" is the extension for saved MATLAB figures.

Interestingly your last code works without any problem.

If I adapt that to my plots, there is only a scaling issue left while loading the graph.

Marc Dirix <dirixmjm>
Wed 17 May 2017 01:50:40 PM UTC, comment #3:

Octave also provides the `saveas` function [1], doesn't it work for you either?

Sorry, I was really no expert regarding 'fig' graphics. By 'fig' you mean XFig [2] (something like a SVG [3])? I never worked with that format. Would all your problems been gone, if you chose, say 'png', instead?

Back to the `hgload/hgsave` problem. Would storing as text:

also mess up your continued plot? And throw the error of comment #2?

[1]: https://www.gnu.org/software/octave/doc/interpreter/Printing-and-Saving-Plots.html#XREFsaveas
[2]: https://en.wikipedia.org/wiki/Xfig
[3]: https://en.wikipedia.org/wiki/Scalable_Vector_Graphics

Kai Torben Ohlhus <siko1056>
Project Member
Wed 17 May 2017 01:29:17 PM UTC, comment #2:

I want to save and load figures for further processing.

In MATLAB I use saveas, using which I am able to reopen in the figure editor afterwards:
saveas(figHandle,filename,'fig')

your example using hgsave / hgload seems to work, but
1. the saved and loaded figure are not equal. The axis is completely messed up after loading.
2. if I use one of the more complex figures that I have created (figure attached) I get the error I mentioned:
Error: octave_base_value::save_binary(): wrong type argument 'object'

(file #40722)

Marc Dirix <dirixmjm>
Wed 17 May 2017 12:59:11 PM UTC, comment #1:

Are you sure, that you understand the `hgsave` function:

"When producing graphics for final publication use print or saveas. When it is important to be able to continue to edit a figure as an Octave object, use hgsave/hgload."

https://www.gnu.org/software/octave/doc/interpreter/Printing-and-Saving-Plots.html#XREFhgsave

I get the impression you want to call

instead. Anyway, both functions `hgload/hgsave` should work like with the following example:

Is that working for you?

Kai Torben Ohlhus <siko1056>
Project Member
Wed 17 May 2017 08:48:02 AM UTC, original submission:

I'm unable to save figures in octave using hgsave. Although an error is return, a file is created. The file however cannot be loaded through hgload.

> hgsave('File.fig')

Error: octave_base_value::save_binary(): wrong type argument 'object'

Marc Dirix <dirixmjm>

 

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

Attach File(s):
   
   
Comment:
   

Attached Files
file #40724:  hgsave.zip added by dirixmjm (73KiB - application/octet-stream)
file #40722:  Efficiency.png added by dirixmjm (107KiB - image/png)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by dasergatskov (Posted a comment)
  • -unavailable- added by mtmiller (Posted a comment)
  • -unavailable- added by siko1056 (Posted a comment)
  • -unavailable- added by dirixmjm (Submitted the item)
  •  

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

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 7 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 18 May 2017 06:47:08 PM UTCmtmillerStatusNeed Info=>Duplicate
      Open/ClosedOpen=>Closed
    Wed 17 May 2017 11:35:38 PM UTCmtmillerItem GroupRegression=>Incorrect Result
      Summaryhgsave is not working=>hgload figure and contents are not sized correctly
    Wed 17 May 2017 06:40:43 PM UTCdirixmjmAttached File-=>Added hgsave.zip, #40724
    Wed 17 May 2017 01:29:17 PM UTCdirixmjmAttached File-=>Added Efficiency.png, #40722
    Wed 17 May 2017 12:59:11 PM UTCsiko1056StatusNone=>Need Info

    Back to the top


    Powered by Savane 3.1-cleanup1