Skip to content

plot and bg

11 messages · Olivier MARTIN, Jim Lemon, Martin Maechler +6 more

#
Hi all,

I would like to plot some points and define the bg color of my graphics.
But the bg parameter set is defined for the. whole graphic.
In fact, i would like to use something like :

box(bg=gray(0.9)).

So, the background  concerns only the plot region  and not the main 
title, the x title and the y title.

The option col for the function box() concerns the contour and there is 
no option for the background.

Regards,
#
Olivier Martin wrote:

            
This may not be the easiest way, but...
Jim
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#

        
Jim> Olivier Martin wrote:
>> Hi all,
    >> 
    >> I would like to plot some points and define the bg color
    >> of my graphics.  But the bg parameter set is defined for
    >> the. whole graphic.  In fact, i would like to use
    >> something like :
    >> 
    >> box(bg=gray(0.9)).
    >> 
    >> So, the background concerns only the plot region and not
    >> the main title, the x title and the y title.
    >> 

    Jim> This may not be the easiest way, but...

    >> plot(1:5,type="n")
    >> pd<-par("usr")
    >> rect(pd[1],pd[3],pd[2],pd[4],col="Gray")
    >> par(new=T)
    >> plot(1:5)

The easiest way most probably being something like

plot(1:10, panel.first = {U <- par("usr")
                     rect(U[1],U[3],U[2],U[4],col="cornsilk", border="black")},
     main = "Extra background for plot()")

------
Martin Maechler <maechler at stat.math.ethz.ch>	http://stat.ethz.ch/~maechler/
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
I'm working with the R-version 1.4.1.
I've written a function whcih produces 4 plots.
I would like to create 4 different windows, each of one with one plot.
Now, all the 4 plots are created in the windows and only the last one
remains.


How can solve this problem?

Regards,
edg
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
par(mfrow=c(2,2))

----- Original Message -----
From: "Enrico De Giorgi" <degiorgi at math.ethz.ch>
To: "r-help" <r-help at stat.math.ethz.ch>
Sent: Tuesday, August 20, 2002 3:28 PM
Subject: [R] Multi-plot
graphics.
-.-.-
http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.
_._
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
Enrico De Giorgi wrote:
Start a new device before generating the next plot with:

 x11()     # on Linux / Unix and
 windows() # on windows

Uwe Ligges
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
Create a new graphics window between plots.
  You don't say what operating system you're using: for Unix, x11() is the 
command to create a new window; for Windows, I believe it's windows() (see 
?Devices).
  Then see ?dev.cur() for information on how you can list, switch between 
graphics windows, etc.

  Q to gurus: is there a simple way to get the command for the default
graphics driver, something like options()$createdevice [options$device is
useful but "X11" can't quite be turned into x11() without some hacking,
and I don't know if that hack would work generally].  You can always write
a little bit of conditional code, but I'm just wondering if there's a
simple one-liner ...

  Ben Bolker
On Tue, 20 Aug 2002, Enrico De Giorgi wrote:

            

  
    
#
On Tue, 20 Aug 2002, Ben Bolker wrote:

            
eval(get(getOption("device"))())

is essentially what the internal code does.  I've written that several
times before, and will see if I can find a place to put it in the
online docs.  (Ben: Suggestions welcome as to where.)
#
On Tue, 20 Aug 2002 ripley at stats.ox.ac.uk wrote:

            
How about ?Devices  ?  (I think that's the first place I would look ...)  
And/or ?options, under "device"  (the case difference between "X11" and 
x11() [which I now realize is an alias for X11(), but is how I usually 
invoke it] also confused me).
3 days later
#
If it helps you

x<-runif(100,10,20)
y<-2*x+rnorm(length(x),0,1)
xticks<-pretty(x)
yticks<-pretty(y)

par(bg="gray")
coord <- par("usr")
plot(x, type="n",axes=FALSE,ann=FALSE,xlim=range(xticks),ylim=range(yticks))
rect(coord[1],coord[3],coord [2],coord [4],col="yellow",border="navy")

points(x,y,pch=20,cex=1.5,col="red")
axis(1, col.axis="navy")
axis(2, col.axis="navy")

Best, isaia
Olivier Martin wrote:

            

  
    
#
You may use

windows(width=7,height=5)   ## width & height in inches
plot(1:10,col="red")        ## 1st plot
windows(width=7,height=5)   ## width & height in inches
plot(10:1,col="navy")       ## 2nd plot
and so on...

(windows(),X11() or macintosh() depending on the platform)

Best, isaia.
Enrico De Giorgi wrote: