help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: plot & print


From: Ben Abbott
Subject: Re: plot & print
Date: Sat, 14 Nov 2009 14:38:49 -0500

On Nov 14, 2009, at 1:44 PM, Alain Content wrote:

> 
> On 14 nov. 2009, at 19:10, Ben Abbott wrote:
> 
>> 
>> On Nov 14, 2009, at 3:52 AM, Alain Content wrote:
>> 
>>> This is most likely a very stupid beginner's question, but still :
>>> 
>>> I use octave to generate geometrical objects, and need accurate control of 
>>> their size in pixels. 
>>> The way I do that is to plot a figure and then print it.
>>> For instance, to generate, say, a 500 pixel square : 
>>>     plot ([-1,-1,1,1,-1], [-1,1,1,-1,-1])  # a square
>>>     print ("-dpng", "-S500,500", "sq.png")  # generate file
>>> 
>>> However, this method generates margins around the objects, and I can't find 
>>> how to control the size of those margins (or suppress them).
>>> Alternatively, could one tell me how these margins are sized ?
>>> 
>>> Thanks in advance, 
>>> Alain
>> 
>> The graphics backend has had a lot of changes recently. If you are running 
>> version 3.2.x then you can have the axis box fill the figure by ...
>> 
>>      plot ([-1,-1,1,1,-1], [-1,1,1,-1,-1])  # a square
>>      set (gca, "position", [0 0 1 1])
>>      print ("-dpng", "-S500,500", "sq.png")  # generate file
>> 
>> If you are running 3.0.x, I don't know how to do what you want.
>> 
>> Ben
> 
> I use 3.2.3. Brilliant !
> 
> Two comments though : 
> 
> 1. Shouldn't the Manual say (p 249)
>       position                 A vector specifying the position of the plot, 
> **including** titles, axes and legend.
> (note that I am neither a native English speaker nor a native computer 
> speaker ;)
>  
> 2. I believe there is a 1 pixel bug. Here is what I did 
> 
>       axis( [-1 1 -1 1])
>       hold on
>       set (gca, "position", [0 0 1 1])
>       plot ([-1/2,-1/2,1/2,1/2,-1/2], [-1/2,1/2,1/2,-1/2,-1/2])  # a square
>       print("-S1000,1000", "e1.png") # the square should be 500 x 500
>       print("-S20,20", "e1.png") # width/height difference made more visible
> 
> Not crucial, obviously. 
> And thanks for the help,
> Alain

The manual has been getting quite a bit of work recently, but can always use 
more work. However, in this instance the "position" property does *not* include 
the titles, ticklabels, or axis labels. Thus the language "A vector specifying 
the position of the plot, excluding titles, axes and legend." is a proper 
description of what the axes "position" is intended to represent.

Regarding the pixel bug. Octave uses gnuplot as its backend. The way you are 
using it, the intent is to produce nice vector plots.

For good control over bitmap images, please review the commands below.

 image_viewer  imfinfo       imread        imwrite       image         imagesc  
     impulse       imshow        

I'm not vary familiar with the image capabilities of Octave. However, there are 
others who are.  So please follow up with more questions.

Ben


reply via email to

[Prev in Thread] Current Thread [Next in Thread]