Bug in print() function?

Ben Abbott bpabbott at mac.com
Tue Mar 31 06:52:24 CDT 2009


(moved to maintainers list)

On Mar 31, 2009, at 7:29 AM, José Luis García Pallero wrote:
>
> El 31 de marzo de 2009 13:14, Ben Abbott <bpabbott at mac.com> escribió:
>>
>> On Mar 31, 2009, at 3:08 AM, José Luis García Pallero wrote:
>>>
>>> Hi,
>>> I have one problem when I try to use the function print in Octave  
>>> 3.1.54 and 3.1.55. I create a plot composed of 3 subplots and I  
>>> try to generate a *.ps file with print() function. In Octave 3.0.3  
>>> compiled for me and 3.0.4 from Debian official repositories all  
>>> runs OK and the plot is created without errors. But with versions  
>>> 3.1.54 and 3.1.55 compiled for me the plot created hs some errors:
>>>
>>> 1. The plot is not extended the full paper
>>> 2. The titles of the subplots are mixed in the upper subplots
>>>
>>> The code of my test script is:
>>>
>>> subplot(3,1,1);
>>> plot(randn(3));
>>> title('Title for the first plot');
>>> subplot(3,1,2);
>>> plot(randn(3));
>>> title('Title for the second plot');
>>> subplot(3,1,3);
>>> imagesc(randn(10));
>>> tit = sprintf('First line\nSecond line\nThird line');
>>> title(tit);
>>> print('testplot.ps','-dpsc','-F:8');
>>>
>>> Attached I send the example plots (converted to pdf for reduce the  
>>> size, but the original are *.ps)
>>>
>>> Someone has the same problem?
>>>
>>> Thanks
>>
>> #1 is intended. The current sources respect the figure properties,  
>> papersize, papertype, paperpostion properties, etc.
>>
>>        figure (1)
>>        clf
>>        plot (randn (50, 1))
>>        set (gcf, "paperunits", "inches"); # the default is "inches"
>>        paper_size = [8.5, 11.0];
>>        set (gcf, "papersize", paper_size)
>>        set (gcf, "papertype", "usletter")
>>        set (gcf, "paperposition", [0.5, 0.5, paper_size-1.0])
>>        print (gcf, strcat ("figtest.ps"), "-dpsc")
>>
>> While listeners still need to be included to simplify specifying  
>> these properties.
>>
>> Regarding #2, gnuplot position's the tick-labels, axis-labels, and  
>> title in a more liberal manner than does Matlab. However, the  
>> subplot does position the axes in a compatible manner. This results  
>> in problem with your titles. This problem is also improved by  
>> setting the paperposition property so that the figure fills the  
>> full page.
>>
>> Ben
>
> Sorry, but I don't understand exactly your answer. Exist any problem  
> with the behaviour of print command in 3.0.x series of Octave? I  
> think that this version works OK, but I feel strange with the 3.1.5x  
> behaviour.

These changes have been added to the current sources (3.1.x, but not  
not 3.0.x). The intent was to introduce compatibility with Matlab.

Most of the difference between 3.0.x and 3.1.x is eliminated by  
setting the paperposition to fill papersize. For postscript output,  
gnuplot places a 50pt border around the image. Thus, to avoid  
clipping ...

        figure (1)
        clf
        plot (randn (50, 1))
        set (gcf, "paperunits", "inches"); # the default is "inches"
        paper_size = [8.5, 11.0];
        set (gcf, "papersize", paper_size)
        set (gcf, "papertype", "usletter")
        set (gcf, "paperposition", [50/72, 50/72, paper_size-100/72])
        print (gcf, strcat ("figtest.ps"), "-dpsc")

This is still more complicated than it should be. Significant  
improvements would result if; (1) Listeners for the figure paper  
properties, and (2) Listeners for units conversion were added. I have  
a m-file that handles each of these tasks, but am under the impression  
that this needs to be done in c++ for a proper solution (the listeners  
should be added with the axes and figure are initialized).

Ben





More information about the Octave-maintainers mailing list