[R] lattice xyplot with bty="l"
László Sándor
sandorl at gmail.com
Mon Jul 5 13:12:27 CEST 2010
Hi all,
Back in 2007, Deepayan and Patrick had an exchange about how to modify
axes for lattice plots (pasted below). I need something similar, but I
also need to produce ticks on the axes. Deepayan quickly coded up
substitute gridlines because they needed to make the default box
transparent. The code works, but it lacks the ticks, and I could not
google up how to add them.
(I would be taken aback if you could even help me but this option into
a theme for the latticeExtra package -- the grid options there do not
seem to allow left and bottom axes at the same time. Not even
asTheEconomist command, though I thought I have seen plot with
"bty="l" " in The Economist...)
I understand that panels in lattice were not intended for such use
originally, but for many advanced features of the lattice package, my
team wants to use this. The specific goal would be to produce graphs
in R like those here:
http://obs.rc.fas.harvard.edu/chetty/denmark_adjcost_slides.pdf .
Any help would be greatly appreciated.
Thank you very much,
Laszlo
László Sándor
graduate student
Department of Economics
Harvard University
"Deepayan Sarkar" <[EMAIL PROTECTED]> writes:
> On 9/4/07, Patrick Drechsler <[EMAIL PROTECTED]> wrote:
>>
>> what is the correct way of removing the "top" and "right" axes
>> completely from a lattice xyplot? I would like to have a plot similar
>> to using the bty="l" option for traditional plots.
>
> There is no direct analog (and I think it would be weird in a
> multipanel plot).
I agree that this is not very useful for multipanel plots.
> Combining a few different features, you can do:
>
> library(grid)
>
> xyplot(1:10 ~ 1:10, scales = list(col = "black", tck = c(1, 0)),
> par.settings = list(axis.line = list(col = "transparent")),
> axis = function(side, ...) {
> if (side == "left")
> grid.lines(x = c(0, 0), y = c(0, 1),
> default.units = "npc")
> else if (side == "bottom")
> grid.lines(x = c(0, 1), y = c(0, 0),
> default.units = "npc")
> axis.default(side = side, ...)
> })
>
> -Deepayan
Thank you very much Deepayan, this is exactly what I was looking for!
Cheers,
Patrick
More information about the R-help
mailing list