Skip to content
Prev 365960 / 398502 Next

[FORGED] help with gradient boxplot

Hi, Paul,
Thank you very much for your reply. I tried your sample code, but did not get gradient filling (still empty box). And many warnings:1: In checkAttrs(attrs, eltName) :
? Removing non-SVG attribute name(s): fill, fill-opacity
2: In checkAttrs(attrs, eltName) :
? Removing non-SVG attribute name(s): fill, fill-opacity
3: In checkAttrs(attrs, eltName) :
? Removing non-SVG attribute name(s): fill, fill-opacity
4: In checkAttrs(attrs, eltName) :
? Removing non-SVG attribute name(s): fill, fill-opacity
5: In checkAttrs(attrs, eltName) :
...

I saw the figure in an article, and so I don't have to script. I am actually trying to generate the similar figure for my own data. 

Any other thoughts?
Thanks.
Ace
On Tuesday, December 6, 2016 7:43 PM, Paul Murrell <paul at stat.auckland.ac.nz> wrote:
Hi

'gridSVG' might be one way to get this.? For example ...

library(lattice)
# Draw boxplot (with a package that sits on top of 'grid')
bwplot(voice.part ~ height, data=singer, xlab="Height (inches)",
? ? ? ? horizontal=FALSE)

library(grid)
grid.ls()
# Looks like boxes are called <blah>bwplot.box.polygon<blah>

library(gridSVG)
# Define linear gradient
fill <- linearGradient(c("blue", "red"),
? ? ? ? ? ? ? ? ? ? ? ? x0=.5, x1=.5,
? ? ? ? ? ? ? ? ? ? ? ? gradientUnits="coords")
# Register gradient now so it applies to the whole page
registerGradientFill("br", fill)
# Fill each box with gradient
grid.gradientFill("bwplot.box.polygon", label=rep("br", 17), grep=TRUE,
? ? ? ? ? ? ? ? ? group=FALSE)
# Generate SVG version "Rplots.svg"
# (where the gradient will actually be visible)
grid.export()

Does that help ?

Paul
On 07/12/16 09:14, Fix Ace wrote: