plot background - excel gradient style background ?

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

plot background - excel gradient style background ?

jcrosbie
Is there away of putting an excel style gradient background?  I want to have dark blue in the middle and shad to white on the top and bottom.
Reply | Threaded
Open this post in threaded view
|

Re: plot background - excel gradient style background ?

glsnow
The short answer is "yes".

The question as answer is "what is wrong with your data that you feel
the need to hide/distort information and distract from the story of
the data?".

The hopefully thought provoking answer is "fortune(197)".

The answer to the question not asked that should have been is "No!
don't do that!".

If you have read all the above and are still determined to continue
despite warnings, then ...
The answer similar to handing a fully metal knife to someone poking
around in a plugged in toaster is "?rasterImage".

On Fri, Jun 1, 2012 at 2:26 PM, jcrosbie <[hidden email]> wrote:

> Is there away of putting an excel style gradient background?  I want to have
> dark blue in the middle and shad to white on the top and bottom.
>
> --
> View this message in context: http://r.789695.n4.nabble.com/plot-background-excel-gradient-style-background-tp4632138.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [hidden email] 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.



--
Gregory (Greg) L. Snow Ph.D.
[hidden email]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: plot background - excel gradient style background ?

jcrosbie
I'm not the one who is choosing to use gradient background. It's our company policy.  
Reply | Threaded
Open this post in threaded view
|

Re: plot background - excel gradient style background ?

glsnow
Well that answers the question as answer.  So while you are working
within the system to get your company to change the policy you can use
rasterImage to add a gradient background to the plot, then use points
or lines or other functions to put the parts of interest back on top
of the gradient (if it is not obvious how to do this then give us more
detail of the types of plots you are doing, a reproducible example is
best, and we can give more detail on how to do this).

On Tue, Jun 5, 2012 at 9:07 AM, jcrosbie <[hidden email]> wrote:

> I'm not the one who is choosing to use gradient background. It's our company
> policy.
>
> --
> View this message in context: http://r.789695.n4.nabble.com/plot-background-excel-gradient-style-background-tp4632138p4632409.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [hidden email] 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.



--
Gregory (Greg) L. Snow Ph.D.
[hidden email]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: plot background - excel gradient style background ?

jcrosbie
In reply to this post by jcrosbie
I have a number of different figures I wish to create with a gradient background. In addition to the two examples I've uploaded I need a boxplot, histogram, etc.


fig1.pngfig2.png
Reply | Threaded
Open this post in threaded view
|

Re: plot background - excel gradient style background ?

baptiste.auguie
Looking at these, and in retrospect, if I were writing a manuscript of
the pre-digital age, I would definitely add a burning mark as a
finishing touch to complete the work. Perhaps waving the parchment
above a burning candle.

With modern digital support, you can fake a similar result using e.g.
grid.raster or rasterImage, as others have said before.

library(grid)
g <- rasterGrob(blues9, width=unit(1,"npc"), height = unit(1,"npc"),
interpolate = TRUE)
# grid.draw(g)

library(ggplot2)
ggplot(mtcars, aes(factor(cyl))) + # add gradient background
   annotation_custom(g, xmin=-Inf, xmax=Inf, ymin=-Inf, ymax=Inf) +
   geom_bar() # add data layer

baptiste


On 30 June 2012 09:07, jcrosbie <[hidden email]> wrote:

> I have a number of different figures I wish to create with a gradient
> background. In addition to the two examples I've uploaded I need a boxplot,
> histogram, etc.
>
>
> http://r.789695.n4.nabble.com/file/n4634932/fig1.png fig1.png
> http://r.789695.n4.nabble.com/file/n4634932/fig2.png fig2.png
>
> --
> View this message in context: http://r.789695.n4.nabble.com/plot-background-excel-gradient-style-background-tp4632138p4634932.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: plot background - excel gradient style background ?

Jim Lemon
In reply to this post by jcrosbie
On 06/30/2012 07:07 AM, jcrosbie wrote:
> I have a number of different figures I wish to create with a gradient
> background. In addition to the two examples I've uploaded I need a boxplot,
> histogram, etc.
>
>
> http://r.789695.n4.nabble.com/file/n4634932/fig1.png fig1.png
> http://r.789695.n4.nabble.com/file/n4634932/fig2.png fig2.png
>
Hi jcrosbie,
Will this do?

library(plotrix)
plot(1:10,type="n")
xylim<-par("usr")
gradient.rect(xylim[1],xylim[3],xylim[2],xylim[4],
  c(1,0,1),c(1,0,1),c(1,1,1),gradient="y")

points(1:10)

Jim

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: plot background - excel gradient style background ?

glsnow
In reply to this post by jcrosbie
Here are examples of a histogram and a boxplot using rasterImage to
make the background:

bg <- matrix( c('#ddddff','#7777ff','#ddddff'), ncol=1 )


tmp <- hist(iris$Sepal.Width)
xylim <- par('usr')
rasterImage(bg, xylim[1], xylim[3], xylim[2], xylim[4])
plot(tmp, add=TRUE, lwd=3)



plot( Petal.Length ~ Species, data=iris )
xylim <- par('usr')
rasterImage(bg, xylim[1], xylim[3], xylim[2], xylim[4])
plot( Petal.Length ~ Species, data=iris, add=TRUE )



On Fri, Jun 29, 2012 at 3:07 PM, jcrosbie <[hidden email]> wrote:

> I have a number of different figures I wish to create with a gradient
> background. In addition to the two examples I've uploaded I need a boxplot,
> histogram, etc.
>
>
> http://r.789695.n4.nabble.com/file/n4634932/fig1.png fig1.png
> http://r.789695.n4.nabble.com/file/n4634932/fig2.png fig2.png
>
> --
> View this message in context: http://r.789695.n4.nabble.com/plot-background-excel-gradient-style-background-tp4632138p4634932.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [hidden email] 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.



--
Gregory (Greg) L. Snow Ph.D.
[hidden email]

______________________________________________
[hidden email] 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.