Grokbase Groups R r-help March 2002
FAQ
Hello All,

I've created a view stacked barplots where some of the bars should
contain a pattern such as stripes. Adjacent bars of the same stack
should have the same colour but a different finnling pattern. Is R able
to do that?

Anyway, it's not the end of the world if not, a workaround would be to
export the plot in fig format and then using xfig to make the bar
filling striped, dotted etc ...

thanks for comments,

Arne

--
Arne Mueller
Biomolecular Modelling Laboratory
Imperial Cancer Research Fund
44 Lincoln's Inn Fields
London WC2A 3PX, U.K.
phone : +44-(0)207 2693405 | fax :+44-(0)207-269-3534
email : a.mueller at icrf.icnet.uk | http://www.bmm.icnet.uk

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

Search Discussions

  • Paul Murrell at Mar 13, 2002 at 2:16 am
    Hi

    I've created a view stacked barplots where some of the bars should
    contain a pattern such as stripes. Adjacent bars of the same stack
    should have the same colour but a different finnling pattern. Is R able
    to do that?

    Anyway, it's not the end of the world if not, a workaround would be to
    export the plot in fig format and then using xfig to make the bar
    filling striped, dotted etc ...

    Take a look at the last example of example(barplot) -- is this the sort of
    thing you want to do?

    Paul


    -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
    r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
    Send "info", "help", or "[un]subscribe"
    (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
    _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
  • Arne Mueller at Mar 13, 2002 at 4:08 am
    Hi,

    yes, that's sort of what I was looking for. But I've to mix filled bars
    with striped bars in a stacked barplot. I could just set the density for
    the completely filled bars to something realy high (1000) but it's realy
    slow to draw. Is there a way to mix stiped bars and filled pars in the
    same plot?

    I've done something like this:

    barplot(m, beside = FALSE, horiz = TRUE, density = c(-1,10,-1,10,-1,10),
    xlab = "fraction of genome",
    col = cols, xlim = c(0,100), axes = FALSE)

    thanks a lot,

    Arne

    On Wed, 13 Mar 2002, Paul Murrell wrote:

    Hi

    I've created a view stacked barplots where some of the bars should
    contain a pattern such as stripes. Adjacent bars of the same stack
    should have the same colour but a different finnling pattern. Is R able
    to do that?

    Anyway, it's not the end of the world if not, a workaround would be to
    export the plot in fig format and then using xfig to make the bar
    filling striped, dotted etc ...

    Take a look at the last example of example(barplot) -- is this the sort of
    thing you want to do?

    Paul

    -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
    r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
    Send "info", "help", or "[un]subscribe"
    (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
    _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
  • Paul Murrell at Mar 13, 2002 at 7:27 pm
    Hi

    yes, that's sort of what I was looking for. But I've to mix filled bars
    with striped bars in a stacked barplot. I could just set the density for
    the completely filled bars to something realy high (1000) but it's realy
    slow to draw. Is there a way to mix stiped bars and filled pars in the
    same plot?

    There may be a better way, but does the following do the sort of thing you
    want ...?

    m <- matrix(runif(30), ncol=5)
    barplot(m, besideúLSE, col=rep(c("white", "light green", "pink"), 2),
    border=rep(c("white", "red"), 3), horiz=TRUE,
    xlim=c(0, 6), axesúLSE)
    par(new=TRUE)
    barplot(m, besideúLSE, col="blue",
    density=rep(c(10, 5, -1), 2),
    angle=rep(c(45, -45, 0), 2), horiz=TRUE,
    xlim=c(0, 6))

    Paul


    -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
    r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
    Send "info", "help", or "[un]subscribe"
    (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
    _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
  • Arne Mueller at Mar 13, 2002 at 8:17 pm

    Paul Murrell wrote:
    Hi
    yes, that's sort of what I was looking for. But I've to mix filled bars
    with striped bars in a stacked barplot. I could just set the density for
    the completely filled bars to something realy high (1000) but it's realy
    slow to draw. Is there a way to mix stiped bars and filled pars in the
    same plot?
    There may be a better way, but does the following do the sort of thing you
    want ...?

    m <- matrix(runif(30), ncol=5)
    barplot(m, besideúLSE, col=rep(c("white", "light green", "pink"), 2),
    border=rep(c("white", "red"), 3), horiz=TRUE,
    xlim=c(0, 6), axesúLSE)
    par(new=TRUE)
    barplot(m, besideúLSE, col="blue",
    density=rep(c(10, 5, -1), 2),
    angle=rep(c(45, -45, 0), 2), horiz=TRUE,
    xlim=c(0, 6))

    Paul

    Hello,

    As far as I can see the above code plots two graphs, one with filled and
    one striped. I'd like to have filled and striped bars within the same
    stacked dataset of the same plot (e.g filled red bar, then striped red
    bar on top of the fileld red bar).

    But maybe I can alter your code so that I construct the plot bar by bar
    setting par(new = FALSE) (re-using the same plotting window). I'd have
    to recalculate the x-positions for all the bars that have to be on-top
    of the previous bars whenever I call barplot.

    thanks for the suggestion,

    Arne
    -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
    r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
    Send "info", "help", or "[un]subscribe"
    (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
    _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
  • Paul Murrell at Mar 13, 2002 at 8:53 pm
    Hi

    yes, that's sort of what I was looking for. But I've to mix filled
    bars
    with striped bars in a stacked barplot. I could just set the density
    for
    the completely filled bars to something realy high (1000) but it's
    realy
    slow to draw. Is there a way to mix stiped bars and filled pars in the
    same plot?
    There may be a better way, but does the following do the sort of thing
    you
    want ...?

    m <- matrix(runif(30), ncol=5)
    barplot(m, besideúLSE, col=rep(c("white", "light green", "pink"), 2),
    border=rep(c("white", "red"), 3), horiz=TRUE,
    xlim=c(0, 6), axesúLSE)
    par(new=TRUE)
    barplot(m, besideúLSE, col="blue",
    density=rep(c(10, 5, -1), 2),
    angle=rep(c(45, -45, 0), 2), horiz=TRUE,
    xlim=c(0, 6))

    Paul

    Hello,

    As far as I can see the above code plots two graphs, one with filled and
    one striped. I'd like to have filled and striped bars within the same
    stacked dataset of the same plot (e.g filled red bar, then striped red
    bar on top of the fileld red bar).

    But maybe I can alter your code so that I construct the plot bar by bar
    setting par(new = FALSE) (re-using the same plotting window). I'd have
    to recalculate the x-positions for all the bars that have to be on-top
    of the previous bars whenever I call barplot.

    The code should work as-is. It's not very intuitive, but par(new=TRUE)
    actually means re-use the same plotting window. And because the same data
    is being plotted both times, the bars are drawn in exactly the same location
    so there is no need for any recalculation of x-positions.

    Paul


    -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
    r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
    Send "info", "help", or "[un]subscribe"
    (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
    _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
  • Arne Mueller at Mar 14, 2002 at 2:01 am

    Arne Mueller wrote:
    Paul Murrell wrote:
    Hi
    yes, that's sort of what I was looking for. But I've to mix filled bars
    with striped bars in a stacked barplot. I could just set the density for
    the completely filled bars to something realy high (1000) but it's realy
    slow to draw. Is there a way to mix stiped bars and filled pars in the
    same plot?
    There may be a better way, but does the following do the sort of thing you
    want ...?

    m <- matrix(runif(30), ncol=5)
    barplot(m, besideúLSE, col=rep(c("white", "light green", "pink"), 2),
    border=rep(c("white", "red"), 3), horiz=TRUE,
    xlim=c(0, 6), axesúLSE)
    par(new=TRUE)
    barplot(m, besideúLSE, col="blue",
    density=rep(c(10, 5, -1), 2),
    angle=rep(c(45, -45, 0), 2), horiz=TRUE,
    xlim=c(0, 6))

    Paul
    Hi,

    I'd also like to have the filled boxes in the legend to be striped. The
    legend function has a 'density' attribute, but unfortunately this does't
    seem to do anything

    following the above example

    legend(3.4, 5, c('Axx','Bxx','Cxx','Dxx'), fill = c('red', 'blue',
    'green', 'orange'))

    is the same as

    legend(3.4, 5, c('Axx','Bxx','Cxx','Dxx'), density, fill = c('red',
    'blue', 'green', 'orange'),
    density=c(10,-1,20, 200))

    In the above example R warns that 'border' is not used yet. Does that
    change soon? Basically I'd like the border of each bar to be black
    rather than the fill color.

    However, isn't it a logic step to implement the density attribute of the
    barplot in a way that one can mix filled bars with stiped bars? E.g

    barplot(..., besides = FALSE, horiz = TRUE, col = c('red', 'blue',
    'green', 'orange'),
    density = c(-1,0,-1,10))

    where a density value of 0 means no density AND no filling (empty, just
    border), a negative value means complete filling with no stipes and a
    positve value means actually stiping with that density valie.

    regards,

    Arne
    -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
    r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
    Send "info", "help", or "[un]subscribe"
    (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
    _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
  • Paul Murrell at Mar 14, 2002 at 7:59 pm
    Hi


    <snip>
    I'd also like to have the filled boxes in the legend to be striped. The
    legend function has a 'density' attribute, but unfortunately this does't
    seem to do anything

    following the above example

    legend(3.4, 5, c('Axx','Bxx','Cxx','Dxx'), fill = c('red', 'blue',
    'green', 'orange'))

    is the same as

    legend(3.4, 5, c('Axx','Bxx','Cxx','Dxx'), density, fill = c('red',
    'blue', 'green', 'orange'),
    density=c(10,-1,20, 200))

    This appears to be a bug. Can you file a bug report for this please?

    In the above example R warns that 'border' is not used yet. Does that
    change soon? Basically I'd like the border of each bar to be black
    rather than the fill color.

    I'm not sure when this might get implemented properly -- in the meantime,
    here's a small extension of the example that will "cheat" to give the effect
    I think you want ...

    m <- matrix(runif(30), ncol=5)
    barplot(m, besideúLSE, col=rep(c("white", "light green", "pink"), 2),
    horiz=TRUE,
    xlim=c(0, 6), axesúLSE)
    par(new=TRUE)
    barplot(m, besideúLSE, col="blue",
    density=rep(c(10, 5, -1), 2),
    angle=rep(c(45, -45, 0), 2), horiz=TRUE,
    xlim=c(0, 6))
    par(new=TRUE)
    barplot(m, besideúLSE, col="black", density=-1,
    horiz=TRUE,
    xlim=c(0, 6))

    However, isn't it a logic step to implement the density attribute of the
    barplot in a way that one can mix filled bars with stiped bars? E.g

    barplot(..., besides = FALSE, horiz = TRUE, col = c('red', 'blue',
    'green', 'orange'),
    density = c(-1,0,-1,10))

    where a density value of 0 means no density AND no filling (empty, just
    border), a negative value means complete filling with no stipes and a
    positve value means actually stiping with that density valie.

    There are a number of places in R where several graphics parameters interact
    with each other in a nasty way. Suggestions for clarifications like this
    are very welcome. But even better would be a patch for the barplot code
    that implemented the change :)

    Paul


    -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
    r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
    Send "info", "help", or "[un]subscribe"
    (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
    _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
  • Arne Mueller at Mar 15, 2002 at 4:55 pm
    Hi,

    thanks for the hint, the workaround below works fine. I'll also file a
    bug report on the density stuff in the legend call.

    regards,

    Arne

    Paul Murrell wrote:
    Hi

    <snip>
    I'd also like to have the filled boxes in the legend to be striped. The
    legend function has a 'density' attribute, but unfortunately this does't
    seem to do anything

    following the above example

    legend(3.4, 5, c('Axx','Bxx','Cxx','Dxx'), fill = c('red', 'blue',
    'green', 'orange'))

    is the same as

    legend(3.4, 5, c('Axx','Bxx','Cxx','Dxx'), density, fill = c('red',
    'blue', 'green', 'orange'),
    density=c(10,-1,20, 200))
    This appears to be a bug. Can you file a bug report for this please?
    In the above example R warns that 'border' is not used yet. Does that
    change soon? Basically I'd like the border of each bar to be black
    rather than the fill color.
    I'm not sure when this might get implemented properly -- in the meantime,
    here's a small extension of the example that will "cheat" to give the effect
    I think you want ...

    m <- matrix(runif(30), ncol=5)
    barplot(m, besideúLSE, col=rep(c("white", "light green", "pink"), 2),
    horiz=TRUE,
    xlim=c(0, 6), axesúLSE)
    par(new=TRUE)
    barplot(m, besideúLSE, col="blue",
    density=rep(c(10, 5, -1), 2),
    angle=rep(c(45, -45, 0), 2), horiz=TRUE,
    xlim=c(0, 6))
    par(new=TRUE)
    barplot(m, besideúLSE, col="black", density=-1,
    horiz=TRUE,
    xlim=c(0, 6))
    However, isn't it a logic step to implement the density attribute of the
    barplot in a way that one can mix filled bars with stiped bars? E.g

    barplot(..., besides = FALSE, horiz = TRUE, col = c('red', 'blue',
    'green', 'orange'),
    density = c(-1,0,-1,10))

    where a density value of 0 means no density AND no filling (empty, just
    border), a negative value means complete filling with no stipes and a
    positve value means actually stiping with that density valie.
    There are a number of places in R where several graphics parameters interact
    with each other in a nasty way. Suggestions for clarifications like this
    are very welcome. But even better would be a patch for the barplot code
    that implemented the change :)

    Paul
    -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
    r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
    Send "info", "help", or "[un]subscribe"
    (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
    _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupr-help @
categoriesr
postedMar 11, '02 at 2:52a
activeMar 15, '02 at 4:55p
posts9
users4
websiter-project.org
irc#r

People

Translate

site design / logo © 2017 Grokbase