[R] question on axis box with asp=1
Dan.Kelley at dal.ca
Tue Oct 23 14:29:54 CEST 2007
I'm sorry that I didn't mention about using filled.contour().
The advice about using pin (and, in this case, modifying
filled.contour) is just what I needed. Thanks very much.
(I got sidetracked on the stretchable margin space idea partly
because I've been doing lots of tex lately, and I've grown to love
that idea of stretchable space.)
On Oct 23, 2007, at 9:14 AM, Prof Brian Ripley wrote:
> You need to take control. The box is plotted by box(), and that
> boxes the plot region as set up by plot.window() and given by par
> ("pin"). So try setting that early in your plot sequence. E.g.
> open a window and do
> plot commands ....
> This is one of the non-introductory things covered in 'An
> Introduction to R'.
> If you are using filled.contour(): this uses layout() internally,
> so you need to build your own version and set "pin" in the contour-
> drawing part.
> If so (and you didn't say so explicitly) it is an important factor,
> and one that sample code would have made clear.
> On Tue, 23 Oct 2007, Dan Kelley wrote:
>> Thanks very much for the reply.
>> Probably my example was poor. In my real application, I have an 8Mb
>> data file of ocean properties, that I didn't want to attach. Plus --
>> and I should have noted this -- I am using coloured filled contours,
>> so there is a colour bar at the right which uses up space and makes
>> it a bit hard for me to guess a good width/height ratio for the pdf()
>> Since I am working with representations of regions of the earth, I
>> want to get correct coastline shapes, and so I set asp according to
>> the local latitude for a region of interest. Thus, the width/height
>> ratio depends on the latitude and longitude range of the individual
>> plot that I'm making ... with this complicating factor of space used
>> for the colourbar. (Every graph is different, e.g. the overall graph
>> might be tall and thin for waters near England, and short and wide
>> for Australia.)
>> I hope that anyone reading this realizes that my request is simply
>> that, and not a complaint about R. If the answer is "there's no way
>> to do what you want, and you must adjust width and height in pdf(),
>> well that's fine and I greatly appreciate the advice. I've replied
>> to the whole R-help list (I hope that is correct protocol), in case
>> anyone later on comes across the question and wants to know how it
>> Again, Uwe, thanks for the advice.
>> Dan Kelley.
>> On 2007-10-23, at 8:36 AM, Uwe Ligges wrote:
>>> Why don't you create a device that is approximately squared if you
>>> ask to have asp=1? I do not understand why you resize anything. It
>>> simply does not make sense in that case.
>>> Uwe Ligges
>>> Dan Kelley wrote:
>>>> I've been using (and loving) R for quite a while now, but I have
>>>> to admit that something simple is still stumping me.
>>>> The question is how I can control the box within which a plot is
>>>> drawn, in cases where I'm controlling the aspect ratio with the
>>>> "asp" argument.
>>>> The problem comes up in pdf() and png() output formats, but also
>>>> with interactive windows, and so I'll express myself in terms of
>>>> the latter.
>>>> For example, if I write
>>>> and then resize the plot, the system will adjust the y axis range
>>>> outside the 3-to-4 value. I'd rather it just put whitespace
>>>> above and below the plotting frame.
>>>> My next attempt is to try
>>>> and these agreeably let me control the range of numbers on the
>>>> axis, but the frame still extends outside the desired region.
>>>> (At this point, I can explain why I care ... I'm drawing
>>>> oceanographic data, and it makes no sense to have an axis frame
>>>> that goes to the north of 90N or the south of 90S.)
>>>> Is there a way that I can, perhaps, make the upper and lower
>>>> margins be "stretchable", as one would say in the TeX world?
>>>> That would seem to be a clean solution to my problem.
>>>> Of course, the problem arises also when I output to a file. I
>>>> find myself doing trial after trial, to get the width and height
>>>> just right to prevent R from using axes that I do not desire.
>>>> PS. I apologize for the length of this email; I'm just trying to
>>>> be clear, and also to show that I have at least done a little
>>>> research into the lovely R system.
> Brian D. Ripley, ripley at stats.ox.ac.uk
> Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
> University of Oxford, Tel: +44 1865 272861 (self)
> 1 South Parks Road, +44 1865 272866 (PA)
> Oxford OX1 3TG, UK Fax: +44 1865 272595
Dan E. Kelley, Associate Professor phone:(902)494-1694
Oceanography Department, Dalhousie University fax:(902)494-2885
Halifax, Nova Scotia mailto:Dan.Kelley at Dal.CA
Canada B3H 4J1 http://oceanography.dal.ca/ocean_C699.html
More information about the R-help