ggplot2 release coming soon

241 views
Skip to first unread message

Hadley Wickham

unread,
Dec 21, 2011, 12:26:21 PM12/21/11
to ggplot2
Hi all,

We're getting very close to another release of ggplot2. I think it's
now at the point where it would be useful for more people to start
trying out the development version. The easiest way to get it is:

install.packages("devtools")
library(devtools)
dev_mode() # to avoid clobbering existing install

install_github("scales")
install_github("ggplot2")

Please read the news file for an extensive list of changes:

news(Version == "0.9.0", package = "ggplot2")

If you do discover problems, please sign up for the ggplot-dev mailing
list and discuss them there. That will help keep discussions about
the released version separate from the development version.

You can follow progress on bugs etc at
https://github.com/hadley/ggplot2/issues?milestone=1

Thanks!

Hadley

--
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/

Hadley Wickham

unread,
Dec 29, 2011, 4:04:29 PM12/29/11
to ggplot2
Hi all,

ggplot2 0.9 now passes R CMD check, so unless I discover any show
stopper bugs I'll be releasing it to CRAN in the next couple of days.

Again, it would be greatly appreciated if you tried it out with a few
of your plots - I'm trying to get better at writing automated tests,
but there's still a long way to go.

install.packages("devtools")
library(devtools)
dev_mode() # to avoid clobbering existing install

install_github("scales")
install_github("ggplot2")

You can see all the changes (and there are a lot!) by running:

news(Version == "0.9.0", package = "ggplot2")

Hadley

baptiste auguie

unread,
Dec 29, 2011, 4:26:23 PM12/29/11
to Hadley Wickham, ggplot2
Hi,

A minor thing, I can't get the news line to work for some reason,

news(Version == "0.9.0", package = "ggplot2")

Error in charToDate(x) :
character string is not in a standard unambiguous format

Also, have you considered keeping a ggplotGrob function? (recent post
in ggplot2-dev)

Thanks,

baptiste

> sessionInfo()
R version 2.14.1 RC (2011-12-20 r57945)
Platform: i386-apple-darwin9.8.0/i386 (32-bit)

locale:
[1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] ggplot2_0.9.0

loaded via a namespace (and not attached):
[1] colorspace_1.1-0 dichromat_1.2-3 digest_0.5.1 grid_2.14.1
[5] MASS_7.3-16 memoise_0.1 munsell_0.3 plyr_1.6
[9] proto_0.3-9.2 RColorBrewer_1.0-2 reshape2_1.2 scales_0.1.0
[13] stringr_0.6 tools_2.14.1

> --
> You received this message because you are subscribed to the ggplot2 mailing list.
> Please provide a reproducible example: http://gist.github.com/270442
>
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+u...@googlegroups.com
> More options: http://groups.google.com/group/ggplot2

Hadley Wickham

unread,
Dec 29, 2011, 4:39:40 PM12/29/11
to baptiste auguie, ggplot2
> news(Version == "0.9.0", package = "ggplot2")
> Error in charToDate(x) :
>  character string is not in a standard unambiguous format

Just fixed.

> Also, have you considered keeping a ggplotGrob function? (recent post
> in ggplot2-dev)

Just added.

Joran

unread,
Dec 29, 2011, 9:00:16 PM12/29/11
to ggplot2
I seem to be having trouble with the alpha function, which has been
moved to the scales package I gather.

When I run this:


df <- data.frame(
x = sample(10, 20, replace = TRUE),
y = sample(10, 20, replace = TRUE),
grp = rep(letters[1:2],length.out = 20)
)
ggplot(df, aes(xmin = x, xmax = x + 1, ymin = y, ymax = y + 2)) +
geom_rect(aes(fill = grp)) +
scale_fill_manual(values=alpha(c('red','blue'),0.5))

I get the following error:

Error in scale$palette(n) : could not find function "alpha"

If I change that to

scale_fill_manual(values=scales:::alpha(c('red','blue'),0.5))

it runs and produces the plot, but with the "full" colors rather than
the alpha-ed versions of the color. Running both

scales:::alpha("red",0.1)
scales:::alpha("red",1)

at the console seem to produce the correct output, though. My session
info:

R version 2.14.0 (2011-10-31)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] splines stats graphics grDevices utils datasets
methods base

other attached packages:
[1] sos_1.3-1 brew_1.0-6 reshape_0.8.4
plyr_1.6
[5] MASS_7.3-16 RColorBrewer_1.0-5 RSQLite_0.11.1
DBI_0.2-5
[9] ggplot2_0.9.0 devtools_0.5.1

loaded via a namespace (and not attached):
[1] colorspace_1.1-0 dichromat_1.2-3 digest_0.5.1
grid_2.14.0 memoise_0.1
[6] munsell_0.3 proto_0.3-9.2 RCurl_1.8-0
reshape2_1.2 scales_0.1.0
[11] stringr_0.6 tools_2.14.0

Joran

unread,
Dec 29, 2011, 9:21:01 PM12/29/11
to ggplot2
Ok, I think I've narrowed my problem down to scale_manual ignoring the
transparency digits when supplying hex colors. I've tried
scale_fill_manual and scale_colour_manual so far. For instance:


dat <- data.frame(x = 1:10,y = 1:10,grp = rep(letters[1:2],length.out
= 10))

ggplot(dat,aes(x = x,y = y)) +
geom_point(aes(colour = grp)) +
scale_colour_manual(values = c('#FF00001A','#0000FF1A'))

is the same as if you omitted the trailing 1A.

baptiste auguie

unread,
Dec 29, 2011, 9:29:27 PM12/29/11
to Joran, ggplot2
Hi,

Out of curiosity, is there a specific reason not to use alpha as a
setting in the layer instead?

ggplot(df, aes(xmin = x, xmax = x + 1, ymin = y, ymax = y + 2)) +

geom_rect(aes(fill = grp), alpha=0.5) +
scale_fill_manual(values=c('red','blue'))

b.

Joran

unread,
Dec 29, 2011, 10:02:25 PM12/29/11
to ggplot2
On Dec 29, 6:29 pm, baptiste auguie <baptiste.aug...@googlemail.com>
wrote:
> Hi,
>
> Out of curiosity, is there a specific reason not to use alpha as a
> setting in the layer instead?
>
> ggplot(df, aes(xmin = x, xmax = x + 1, ymin = y, ymax = y + 2)) +
> geom_rect(aes(fill = grp), alpha=0.5) +
> scale_fill_manual(values=c('red','blue'))
>

Yes, that'll work. I should have said in my first message that I do
think this is a minor issue.

I just happened to have some code with the colors passed in directly
(or using alpha()) and thought I'd mention it. But if the solution is
simply to set alpha in the geom, that's fine with me.

Felipe Carrillo

unread,
Dec 30, 2011, 1:15:58 AM12/30/11
to baptiste auguie, Joran, ggplot2
Hi Baptiste:
I have used ggExtra and gridExtra quite a lot in one of my applications and was wondering if is going to break my code
if I update to the new ggplot2 version or the above mentioned packages are compatible with the new version. 
 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish & Wildlife Service
California, USA

> To unsubscribe: email ggplot2+unsub...@googlegroups.com
> More options: http://groups.google.com/group/ggplot2


--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: http://gist.github.com/270442

To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+unsub...@googlegroups.com
More options: http://groups.google.com/group/ggplot2


baptiste auguie

unread,
Dec 30, 2011, 1:21:58 AM12/30/11
to Felipe Carrillo, ggplot2
Hi,

gridExtra should work fine, but you probably won't be able to use
ggExtra (and I've removed it from r-forge). Which functions
specifically have you been using?

baptiste

>> To unsubscribe: email ggplot2+u...@googlegroups.com


>> More options: http://groups.google.com/group/ggplot2
>
> --
> You received this message because you are subscribed to the ggplot2 mailing
> list.
> Please provide a reproducible example: http://gist.github.com/270442
>
> To post: email ggp...@googlegroups.com

Felipe Carrillo

unread,
Dec 30, 2011, 2:41:21 AM12/30/11
to baptiste auguie, ggplot2
gridExtra is what I use the most and I use ggExtra to annotate a table...annotate("table".....) below. Could the geom_table
be included in gridExtra?
 
library(gridExtra)
       library(ggplot2)
       library(ggExtra)
       dsmall <- diamonds[sample(nrow(diamonds), 100), ]
         dsmall <- rename(dsmall, c("cut" = "Cut"))
    ggplot(dsmall, aes(carat, price)) +
     annotate("table",  x=0, y=11000, table=ddply(dsmall,"Cut", summarise, Avg_price = mean(price)),
     gp=gpar(cex=1),just=c("left","bottom"),show.rownames=F,gpar.coretext = gpar(fontsize=9,
     col="lightblue",fontface="bold.italic"))  +
      geom_text(aes(x=0.4, y=16000, label="Table of Means"),colour="red") + geom_point()
>> To unsubscribe: email ggplot2+unsub...@googlegroups.com

>> More options: http://groups.google.com/group/ggplot2
>
> --
> You received this message because you are subscribed to the ggplot2 mailing
> list.
> Please provide a reproducible example: http://gist.github.com/270442
>
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+unsub...@googlegroups.com

> More options: http://groups.google.com/group/ggplot2
>
>

--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: http://gist.github.com/270442

To post: email ggp...@googlegroups.com

baptiste auguie

unread,
Dec 30, 2011, 4:49:59 AM12/30/11
to Felipe Carrillo, ggplot2
Hi,

I posted a minimal example a few days ago: https://gist.github.com/1513290

HTH,

baptiste

>>> To unsubscribe: email ggplot2+u...@googlegroups.com


>>> More options: http://groups.google.com/group/ggplot2
>>
>> --
>> You received this message because you are subscribed to the ggplot2
>> mailing
>> list.
>> Please provide a reproducible example: http://gist.github.com/270442
>>
>> To post: email ggp...@googlegroups.com

>> To unsubscribe: email ggplot2+u...@googlegroups.com


>> More options: http://groups.google.com/group/ggplot2
>>
>>
>
> --
> You received this message because you are subscribed to the ggplot2 mailing
> list.
> Please provide a reproducible example: http://gist.github.com/270442
>
> To post: email ggp...@googlegroups.com

Hadley Wickham

unread,
Dec 30, 2011, 9:01:11 AM12/30/11
to Joran, ggplot2
On Thu, Dec 29, 2011 at 8:00 PM, Joran <joran...@gmail.com> wrote:
> I seem to be having trouble with the alpha function, which has been
> moved to the scales package I gather.
>
> When I run this:
>
>
> df <- data.frame(
>  x = sample(10, 20, replace = TRUE),
>  y = sample(10, 20, replace = TRUE),
>  grp = rep(letters[1:2],length.out = 20)
> )
> ggplot(df, aes(xmin = x, xmax = x + 1, ymin = y, ymax = y + 2)) +
> geom_rect(aes(fill = grp)) +
> scale_fill_manual(values=alpha(c('red','blue'),0.5))
>
> I get the following error:
>
> Error in scale$palette(n) : could not find function "alpha"
>
> If I change that to
>
> scale_fill_manual(values=scales:::alpha(c('red','blue'),0.5))

FYI you should never use ::: and rarely use ::. Just load scales
explicitly with library(scales)

For the other issue, I've created a bug report at
https://github.com/hadley/ggplot2/issues/335

Evan Misshula

unread,
Dec 30, 2011, 11:00:32 AM12/30/11
to ggplot2
I would like to contribute in a small way by running some tests on my
plots. Hadley's comment below seems to tell one how to install the
new ggplot but I am not sure how to revert back to the old one. If
there is a link (it does not have to be specific to ggplot) on how to
revert from dev_mode(), it would be much appreciated. I tried
?dev_mode().

Thanks,
Evan Misshula
Grad Student, PhD program in Criminal Justice CUNY John Jay

> --
> You received this message because you are subscribed to the ggplot2 mailing list.
> Please provide a reproducible example: http://gist.github.com/270442
>
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+u...@googlegroups.com
> More options: http://groups.google.com/group/ggplot2

--
Evan Misshula
Doctoral Student (Criminal Justice)
CUNY John Jay
"Let us reform our schools, and we shall find little reform needed in
our prisons."
       John Ruskin, Unto This Last, essay 2 (1862)
       English critic, essayist, & reformer (1819 - 1900)

"Instruction does much, but encouragement does everything." Johann
Wolfgang Von Goethe
www.snrg-nyc.org

Felipe Carrillo

unread,
Dec 30, 2011, 12:16:39 PM12/30/11
to baptiste auguie, ggplot2
I get the following error after running the "custom" geom with version 8.9.
 
>   library(gridExtra)
>   g <- tableGrob(head(iris[1:3,]))
>   d <- qplot(1,1, geom="blank")
>   d + annotate("custom", x=1, y=1, grob=g)
Error in with(coord_transform(coordinates, data, scales), { :
  could not find function "coord_transform"

>>> To unsubscribe: email ggplot2+unsub...@googlegroups.com

>>> More options: http://groups.google.com/group/ggplot2
>>
>> --
>> You received this message because you are subscribed to the ggplot2
>> mailing
>> list.
>> Please provide a reproducible example: http://gist.github.com/270442
>>
>> To post: email ggp...@googlegroups.com
>> To unsubscribe: email ggplot2+unsub...@googlegroups.com

>> More options: http://groups.google.com/group/ggplot2
>>
>>
>
> --
> You received this message because you are subscribed to the ggplot2 mailing
> list.
> Please provide a reproducible example: http://gist.github.com/270442
>
> To post: email ggp...@googlegroups.com

Hadley Wickham

unread,
Dec 30, 2011, 12:32:26 PM12/30/11
to Evan Misshula, ggplot2
> I would like to contribute in a small way by running some tests on my
> plots.  Hadley's comment below seems to tell one how to install the
> new ggplot but I am not sure how to revert back to the old one.  If
> there is a link (it does not have to be specific to ggplot) on how to
> revert from dev_mode(), it would be much appreciated. I tried
> ?dev_mode().

Just start a fresh R session.

Felipe Carrillo

unread,
Dec 30, 2011, 12:40:27 PM12/30/11
to Felipe Carrillo, baptiste auguie, ggplot2
I actually ran it on dev_mode() and get the same error message. Not sure about the source of coord_transform.
 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish & Wildlife Service
California, USA

baptiste auguie

unread,
Dec 30, 2011, 3:30:14 PM12/30/11
to Felipe Carrillo, ggplot2
I don't know, that example should work with dev_mode (but not with
ggplot2 8.9). Here's my sessionInfo,

sessionInfo()
R version 2.14.1 RC (2011-12-20 r57945)
Platform: i386-apple-darwin9.8.0/i386 (32-bit)

locale:
[1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8

attached base packages:
[1] grid stats graphics grDevices utils datasets
methods base

other attached packages:
[1] ggplot2_0.9.0 gridExtra_0.7.1 proto_0.3-9.2 devtools_0.5.1

loaded via a namespace (and not attached):

[1] colorspace_1.1-0 dichromat_1.2-3 digest_0.5.1 MASS_7.3-16
[5] memoise_0.1 munsell_0.3 plyr_1.6 RColorBrewer_1.0-2
[9] RCurl_1.8-0 reshape2_1.2 scales_0.1.0 stringr_0.6
[13] tools_2.14.1

baptiste

Dennis Murphy

unread,
Dec 30, 2011, 3:31:15 PM12/30/11
to Felipe Carrillo, baptiste auguie, ggplot2
Hi Felipe:

I don't get the same error message you reported in 0.9.0:

> g <- tableGrob(head(iris[1:3,]))
> d <- qplot(1,1, geom="blank")
> d + annotate("custom", x=1, y=1, grob=g)

Error: No geom called custom

See ?annotate in 0.9.0. The first argument of annotate() is geom, so
it's expecting the quoted name of an existing geom. Since there is no
geom_custom(), an error is thrown. What were you trying to annotate?
It's entirely possible that there is another way to do it.

Since this problem arose in 0.8.9, it wasn't caused by the changes in
the development version, although it clearly persists there.

Dennis

PS: You really should start a new thread for these things rather than
changing the direction of an existing one.

> sessionInfo()
R version 2.14.1 (2011-12-22)
Platform: x86_64-pc-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages:
[1] grid stats graphics grDevices utils datasets methods
[8] base

other attached packages:
[1] gridExtra_0.8.5 ggplot2_0.9.0 devtools_0.5.1

loaded via a namespace (and not attached):

[1] colorspace_1.1-0 dichromat_1.2-3 digest_0.5.1 MASS_7.3-16

[5] memoise_0.1 munsell_0.3 plyr_1.6 proto_0.3-9.2
[9] RColorBrewer_1.0-5 RCurl_1.8-0.1 reshape2_1.2 scales_0.1.0
[13] stringr_0.6 tools_2.14.1

Felipe Carrillo

unread,
Dec 30, 2011, 4:01:27 PM12/30/11
to Dennis Murphy, baptiste auguie, ggplot2
Dennis:
Sorry, didn't realize where I changed the direction of the thread.
Below is the "custom" geom. If you wouldn't  mind running it.
 
library(proto)
library(grid)
geom_custom <- function (mapping = NULL, data = NULL, stat = "identity",                        
position = "identity", show_guide = FALSE, ...) {  
GeomCustom$new(mapping = mapping, data = data, stat = stat,                
position = position, show_guide = show_guide, ...)
}
GeomCustom <- proto(ggplot2:::Geom, {   
objname <- "custom"
new <- function(., data = NULL, mapping = NULL, grob =NULL, ...) {   
.super$new(., data = data, mapping = mapping, grob=grob, inherit.aes = FALSE, ...) 
}
draw <- function(., data, scales, coordinates, grob, just=c("centre", "centre"), ...) {
  with(coord_transform(coordinates, data, scales), {
  width <- grobWidth(grob)      
  height <- grobHeight(grob)      
  grob <- editGrob(grob, vp=viewport(x = x, y = y,                         
  width=width, height=height, just = just), ...)      
  ggname(.$my_name(), grob) 
  })
  }
 
  default_aes <- function(.)  
  aes(x=0.5, y=0.5) 
  default_stat <- function(.) StatIdentity
  })
 

library(devtools)
dev_mode()
library(ggplot2)
library(plyr)
library(reshape)
library(scales)
       
        dsmall <- diamonds[sample(nrow(diamonds), 100), ]
          dsmall <- rename(dsmall, c("cut" = "Cut"))
     ggplot(dsmall, aes(carat, price)) +
      annotate("custom",  x=0, y=11000, table=ddply(dsmall,"Cut", summarise,

 Avg_price = mean(price)),
      gp=gpar(cex=1),just=c("left","bottom"),show.rownames=F,gpar.coretext =
 gpar(fontsize=9,
      col="lightblue",fontface="bold.italic"))  +
       geom_text(aes(x=0.4, y=16000, label="Table of Means"),colour="red") +
 geom_point()
 
 
 
sessionInfo()
R version 2.14.0 (2011-10-31)
Platform: i386-pc-mingw32/i386 (32-bit)
locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                           LC_TIME=English_United States.1252   
attached base packages:
 [1] grDevices datasets  splines   graphics  tcltk     tools     stats     utils     methods   base    
other attached packages:
 [1] ggplot2_0.9.0    devtools_0.4     svSocket_0.9-51  TinnR_1.0.3      R2HTML_2.2       Hmisc_3.8-3      survival_2.36-10 sos_1.3-1      
 [9] brew_1.0-6       zoo_1.7-5        xtable_1.6-0     rcom_2.2-3.1     rscproxy_1.3-1 
loaded via a namespace (and not attached):
 [1] cluster_1.14.1     colorspace_1.1-0   dichromat_1.2-3    digest_0.5.1       grid_2.14.0        lattice_0.20-0     MASS_7.3-16      
 [8] memoise_0.1        munsell_0.3        plyr_1.6           proto_0.3-9.2      RColorBrewer_1.0-5 RCurl_1.8-0.1      reshape2_1.2     
[15] scales_0.1.0       stringr_0.6        svMisc_0.9-63    
>
 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish & Wildlife Service
California, USA
>>>> To unsubscribe: email ggplot2+unsub...@googlegroups.com

>>>> More options: http://groups.google.com/group/ggplot2
>>>
>>> --
>>> You received this message because you are subscribed to the ggplot2
>>> mailing
>>> list.
>>> Please provide a reproducible example: http://gist.github.com/270442
>>>
>>> To post: email ggp...@googlegroups.com
>>> To unsubscribe: email ggplot2+unsub...@googlegroups.com

>>> More options: http://groups.google.com/group/ggplot2
>>>
>>>
>>
>> --
>> You received this message because you are subscribed to the ggplot2
>> mailing
>> list.
>> Please provide a reproducible example: http://gist.github.com/270442
>>
>> To post: email ggp...@googlegroups.com
>> To unsubscribe: email ggplot2+unsub...@googlegroups.com

>> More options: http://groups.google.com/group/ggplot2
>>
>>
>
>
> --
> You received this message because you are subscribed to the ggplot2 mailing
> list.
> Please provide a reproducible example: http://gist.github.com/270442
>
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+unsub...@googlegroups.com

> More options: http://groups.google.com/group/ggplot2
>
>
> --
> You received this message because you are subscribed to the ggplot2 mailing
> list.
> Please provide a reproducible example: http://gist.github.com/270442
>
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+unsub...@googlegroups.com

> More options: http://groups.google.com/group/ggplot2

--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: http://gist.github.com/270442

To post: email ggp...@googlegroups.com

Dennis Murphy

unread,
Dec 30, 2011, 4:38:01 PM12/30/11
to Felipe Carrillo, baptiste auguie, ggplot2
Actually, Baptiste sent the link to me privately (thank you! :) and
the simple example worked on my end in 0.9.0 - a nice table in the
middle of the plot area. As for the additional example you provided,
I'd suggest using tableGrob() in gridExtra to create the grob first
and use a simpler call in annotate(). The error I get in 0.9.0 is:

> library('plyr')
> library('reshape2')


> dsmall <- diamonds[sample(nrow(diamonds), 100), ]
> dsmall <- rename(dsmall, c("cut" = "Cut"))
> ggplot(dsmall, aes(carat, price)) +

+ geom_point() +


+ annotate("custom", x=0, y=11000, table=ddply(dsmall,"Cut", summarise,

+ Avg_price = mean(price)),
+ gp=gpar(cex=1), just=c("left","bottom"), show.rownames=F,
+ gpar.coretext = gpar(fontsize=9,
+ col="lightblue",fontface="bold.italic")) +


+ geom_text(aes(x=0.4, y=16000, label="Table of Means"),
colour="red")

Error in grobWidth(grob) : argument "grob" is missing, with no default


Maybe you could get away with something like
annotate(..., grob = tableGrob(ddply(dsmall, "Cut", ...)

but Baptiste is the expert on matters involving gridExtra. All I'm
suggesting is to break up the code a bit so that it's easier to see
where things might go wrong.

HTH,
Dennis

>>>>> To unsubscribe: email ggplot2+u...@googlegroups.com


>>>>> More options: http://groups.google.com/group/ggplot2
>>>>
>>>> --
>>>> You received this message because you are subscribed to the ggplot2
>>>> mailing
>>>> list.
>>>> Please provide a reproducible example: http://gist.github.com/270442
>>>>
>>>> To post: email ggp...@googlegroups.com

>>>> To unsubscribe: email ggplot2+u...@googlegroups.com


>>>> More options: http://groups.google.com/group/ggplot2
>>>>
>>>>
>>>
>>> --
>>> You received this message because you are subscribed to the ggplot2
>>> mailing
>>> list.
>>> Please provide a reproducible example: http://gist.github.com/270442
>>>
>>> To post: email ggp...@googlegroups.com

>>> To unsubscribe: email ggplot2+u...@googlegroups.com


>>> More options: http://groups.google.com/group/ggplot2
>>>
>>>
>>
>>
>> --
>> You received this message because you are subscribed to the ggplot2
>> mailing
>> list.
>> Please provide a reproducible example: http://gist.github.com/270442
>>
>> To post: email ggp...@googlegroups.com

>> To unsubscribe: email ggplot2+u...@googlegroups.com


>> More options: http://groups.google.com/group/ggplot2
>>
>>
>> --
>> You received this message because you are subscribed to the ggplot2
>> mailing
>> list.
>> Please provide a reproducible example: http://gist.github.com/270442
>>
>> To post: email ggp...@googlegroups.com

>> To unsubscribe: email ggplot2+u...@googlegroups.com


>> More options: http://groups.google.com/group/ggplot2
>
> --
> You received this message because you are subscribed to the ggplot2 mailing
> list.
> Please provide a reproducible example: http://gist.github.com/270442
>
> To post: email ggp...@googlegroups.com

baptiste auguie

unread,
Dec 30, 2011, 5:04:38 PM12/30/11
to Dennis Murphy, Felipe Carrillo, ggplot2, ggplot2-dev
Yes, geom_custom expects a grob (whereas geom_table, now defunct, used
a data.frame as input). I attach a script that tries to conform better
with the prototype of annotation_raster in ggplot2. Would that be
useful enough to belong in ggplot2 after some polishing?

baptiste

annotation-custom.r

Felipe Carrillo

unread,
Dec 30, 2011, 5:30:03 PM12/30/11
to baptiste auguie, Dennis Murphy, ggplot2, ggplot2-dev
 This works now..in order for this to work, the summary table MUST be inside the tableGrob. Thanks Baptiste and Dennis
 
dsmall <- diamonds[sample(nrow(diamonds), 100), ]
 dsmall <- rename(dsmall, c("cut" = "Cut"))
 ggplot(dsmall, aes(carat, price)) +
    geom_point() +
    annotate("custom",  x=0, y=11000, grob=tableGrob(ddply(dsmall,"Cut", summarise,
    Avg_price = mean(price))),

    gp=gpar(cex=1), just=c("left","bottom"), show.rownames=F,
    gpar.coretext = gpar(fontsize=9,
    col="lightblue",fontface="bold.italic"))  +
    geom_text(aes(x=0.4, y=16000, label="Table of Means"),colour="red")
>>>>>> To unsubscribe: email ggplot2+unsub...@googlegroups.com

>>>>>> More options: http://groups.google.com/group/ggplot2
>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the ggplot2
>>>>> mailing
>>>>> list.
>>>>> Please provide a reproducible example: http://gist.github.com/270442
>>>>>
>>>>> To post: email ggp...@googlegroups.com
>>>>> To unsubscribe: email ggplot2+unsub...@googlegroups.com

>>>>> More options: http://groups.google.com/group/ggplot2
>>>>>
>>>>>
>>>>
>>>> --
>>>> You received this message because you are subscribed to the ggplot2
>>>> mailing
>>>> list.
>>>> Please provide a reproducible example: http://gist.github.com/270442
>>>>
>>>> To post: email ggp...@googlegroups.com
>>>> To unsubscribe: email ggplot2+unsub...@googlegroups.com

>>>> More options: http://groups.google.com/group/ggplot2
>>>>
>>>>
>>>
>>>
>>> --
>>> You received this message because you are subscribed to the ggplot2
>>> mailing
>>> list.
>>> Please provide a reproducible example: http://gist.github.com/270442
>>>
>>> To post: email ggp...@googlegroups.com
>>> To unsubscribe: email ggplot2+unsub...@googlegroups.com

>>> More options: http://groups.google.com/group/ggplot2
>>>
>>>
>>> --
>>> You received this message because you are subscribed to the ggplot2
>>> mailing
>>> list.
>>> Please provide a reproducible example: http://gist.github.com/270442
>>>
>>> To post: email ggp...@googlegroups.com
>>> To unsubscribe: email ggplot2+unsub...@googlegroups.com

>>> More options: http://groups.google.com/group/ggplot2
>>
>> --
>> You received this message because you are subscribed to the ggplot2 mailing
>> list.
>> Please provide a reproducible example: http://gist.github.com/270442
>>
>> To post: email ggp...@googlegroups.com
>> To unsubscribe: email ggplot2+unsub...@googlegroups.com

>> More options: http://groups.google.com/group/ggplot2
>>
>>

--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: http://gist.github.com/270442

To post: email ggp...@googlegroups.com

Troy S

unread,
Dec 30, 2011, 5:51:40 PM12/30/11
to Felipe Carrillo, baptiste auguie, Dennis Murphy, ggplot2, ggplot2-dev
This looks like an excellent learning example.  Can it be added to the documentation?

Hadley Wickham

unread,
Dec 30, 2011, 7:17:44 PM12/30/11
to baptiste auguie, Dennis Murphy, Felipe Carrillo, ggplot2, ggplot2-dev
Looks good - please submit a pull request.
Hadley

--

baptiste auguie

unread,
Dec 30, 2011, 8:14:12 PM12/30/11
to Hadley Wickham, Dennis Murphy, Felipe Carrillo, ggplot2, ggplot2-dev
On 31 December 2011 13:17, Hadley Wickham <had...@rice.edu> wrote:
> Looks good - please submit a pull request.

Sorry but I've lost track of what we're talking about: an example of
using annotation_custom, the code itself, an example intended for
gridExtra, or ggplot2? I'm assuming the first two; I'll try to submit
a pull request with the file I attached earlier as soon as I
understand what that involves.

baptiste

Hadley Wickham

unread,
Dec 30, 2011, 8:44:19 PM12/30/11
to baptiste auguie, Dennis Murphy, Felipe Carrillo, ggplot2, ggplot2-dev
>> Looks good - please submit a pull request.
>
> Sorry but I've lost track of what we're talking about: an example of
> using annotation_custom, the code itself, an example intended for
> gridExtra, or ggplot2? I'm assuming the first two; I'll try to submit
> a pull request with the file I attached earlier as soon as I
> understand what that involves.

Yup, that's right. Feel free to email the ggplot-dev mailing list if
you need a hand.

Hadley

Greg

unread,
Apr 7, 2012, 6:35:09 AM4/7/12
to ggp...@googlegroups.com
I have the same problem as Joran with colors like "#CC000022" and think it's pretty annoying for two reasons:
1) ggplot2 0.8X used to allow the setting of the alpha channel in hex colors so 0.9 breaks compatibility with the old code
2) hex colors with an alpha channel are standard syntax in R and I don't see why ggplot2 shouldn't support that. 
This used to work but doesn't anymore 
qplot(rnorm(100),rnorm(100),color="#cc000044")
plot supports the alpha channel:
plot(rnorm(100),rnorm(100),bg="#cc000044",pch=21)

I am also not sure whether there is some connection to R 2.15 because I think the hex colors with alpha worked before I updated...
Reply all
Reply to author
Forward
0 new messages