Skip to content

Conditional density plot in lattice

3 messages · Dieter Menne, Deepayan Sarkar

#
On Thu, Jan 21, 2010 at 9:05 AM, Dieter Menne
<dieter.menne at menne-biomed.de> wrote:
With a restructuring of the data:

df1 = data.frame(x=0:n, y1=((0:n)/n)^2, y2=1-((0:n)/n)^2, age="young")
df2 = data.frame(x=0:n, y1=((0:n)/n)^3, y2=1-((0:n)/n)^3, age="old")
df = rbind(df1, df2)

xyplot((y1+y2) + y1 ~ x | age, data=df, type = "l")

xyplot((y1+y2) + y1 ~ x | age, data=df, type = "l",
       scales = list(axs = "i"),
       panel = panel.superpose,
       panel.groups = function(x, y, fill, ...) {
           panel.polygon(c(min(x), x, max(x)), c(0, y, 0), fill = fill)
       })

-Deepayan
#
Deepayan Sarkar wrote:
Thanks, Deepayan. I noted, that the color of the bands is determined by
"superpose.symbol". Is that by design or typo?

Dieter
6 days later
#
On Fri, Jan 22, 2010 at 2:08 AM, Dieter Menne
<dieter.menne at menne-biomed.de> wrote:
By design, in the sense that the default 'fill' for panel.superpose is
taken from superpose.symbol$fill, which makes sense because the
default is to plot symbols.

You could supply a top-level vector 'fill' instead (which could be
trellis.par.get("superpose.poygon")$fill).

-Deepayan