[R] Fwd: Re: Graph color

baptiste auguie baptiste.auguie at googlemail.com
Tue Jan 26 20:54:05 CET 2010


Hi,

Try this,

x <- seq(0, 10, len = 100)
y <- jitter(sin(x), 1000)

old.par <- par()
par(bg=grey(0.5))

plot(x, y, new = TRUE, t = "n")
lims <- par("usr")

plot(x, y, col = 1,
  panel.first = {
    rect(lims[1], lims[3], lims[2], lims[4],
      col = "lightblue") })

HTH,

baptiste

2010/1/26  <narillosdesantos at gmail.com>:
> No mate,
>
> Sorry first of all about my indefinition (I´m Spanish, I´m improving
> everyday but a long road to the perfection). Sorry pleae.
>
> Second, also it is diffcoult sometimes to express what we try (sorry and
> many thanks just for reading of course for helping).
>
> Imagine you plot
>
> X=[2 4 6 8] front a Y=[6 5 8 7]
>
> When you plot it by default all is white what I want is to use
> par(br="gray") to make the graph gray but I want that the area (the
> imaginary square defined by the axis) not to be gray I want to deffine its
> colour by ie lightblue.
>
> So the image will be a square image outside gray and on the axis area (not
> the dots, points or bar plots) the area in lightblue.
>
> I don´t now if I have expressed well if not latter I will send an example,
> ok?
>
> Many thanks
>
> ---------- Mensaje reenviado ----------
> De: "Kyle." <ambertk at gmail.com>
> Fecha:
> Asunto: Re: [R] Graph color
> Para: Jose Narillos de Santos <narillosdesantos at gmail.com>
> CC: r-help at r-project.org
>
>
>> If I understand what you want correctly, you'll probably want to use
>> the "col" argument in whatever base graphics function you're using,
>> rather than changing something in the graphical parameters. For example,
>> if I wanted to add red points to an existing plot, I would use something
>> like
>
>
>
>
>
>> points(c(1:10), col="red")
>
>
>> Or, if I wanted to generate a barplot using a shading color other than
>> gray,
>
>
>> barplot(c(1:10), col="steelblue")
>
>
>
>
>
>
>> Does that answer your question?
>
>
>
>
>> Kyle H. Ambert
>> Fellow, National Library of Medicine
>> Department of Medical Informatics & Clinical Epidemiology
>
>
>
>
>> Oregon Health & Science University
>
>
>
>
>
>> On Tue, Jan 26, 2010 at 6:44 AM, Jose Narillos de Santos
>> narillosdesantos at gmail.com> wrote:
>
>
>
>
>> Hi all I want to apply different colors on a simple plot:
>
>
>
>
>
>> If I type par(br="gray") before a plot it puts all the image in gray but
>
>
>> (imagine I run a simple plot) want to let the centrall box (where the dots
>
>
>> are plotted) in white or image in lightblue.
>
>
>
>
>
>> Can anyone guide me to apply this second step (make the box where the
>> series
>
>
>> are plotted in different colours).
>
>
>
>
>
>> Thanks in advance.
>
>
>
>
>
>> [[alternative HTML version deleted]]
>
>
>
>
>
>> ______________________________________________
>
>
>> R-help at r-project.org mailing list
>
>
>> https://stat.ethz.ch/mailman/listinfo/r-help
>
>
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>
>
>> and provide commented, minimal, self-contained, reproducible code.
>
>
>
>
>
>
>
>
>
>        [[alternative HTML version deleted]]
>
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>



More information about the R-help mailing list