help-octave
[Top][All Lists]
Advanced

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

Re: plot & print


From: Alain Content
Subject: Re: plot & print
Date: Sat, 14 Nov 2009 19:44:54 +0100


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 mademore visible

Not crucial, obviously. 
And thanks for the help,
Alain



reply via email to

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