here is a minimal example:
d <- data.frame(x=1:3, y=1:3, co=c("green", "pink", "green"))
ggplot(d, aes(x,y,colour=co)) + geom_point() +
scale_colour_manual(value=d$co, breaks=d$co)
--
Kohske Takahashi <takahash...@gmail.com>
Research Center for Advanced Science and Technology,
The University of Tokyo, Japan.
http://www.fennel.rcast.u-tokyo.ac.jp/profilee_ktakahashi.html
> --
> 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
>
Antje
--
Antje Niederlein, Dipl. Informatikerin (FH)
Research Assistant, Image Analysis
HT-Technology Development Studio (TDS)
Max Planck Institute of Molecular Cell Biology and Genetics (MPI-CBG)
Pfotenhauerstrasse 108
D-01307 Dresden
Phone: ++49 351 210 - 2724
Fax: ++49 351 210 - 1349
E-mail: nied...@mpi-cbg.de
Internet: http://mpi-cbg.de/
Antje
On 19 March 2011 16:07, Antje Niederlein
could you please provide a minimum example?
--
Kohske Takahashi <takahash...@gmail.com>
Research Center for Advanced Science and Technology,
The University of Tokyo, Japan.
http://www.fennel.rcast.u-tokyo.ac.jp/profilee_ktakahashi.html
here is a little example
library(ggplot2)
row <- 1:10
col <- 1:10
myDF <- expand.grid(row = row, col = col)
myDF$value <- 1:100
myDF$colIv <- cut(myDF$value, breaks = seq(0,100,2))
my.colors <- c("blue",rainbow(48),"green")
p <- ggplot(myDF, aes(x = col, y = row, fill = colIv)) + geom_tile()
p <- p + scale_fill_manual(values = my.colors)
p
The legend I get is pretty long and using my real data it slows down
the plot. If I don't plot the legend it's fine. A colour scale bar
would be nice in this case (something like this:
http://www.mathworks.com/matlabcentral/fx_files/2558/2/colorscales.png
)
Hadley
> --
> 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
>
--
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/
I just went for the discrete scale because I could not find any way to
apply customized colours on a continuous scale (exactly defining
colors for given intervals). In the end, color mapping is nothing else
than mapping discrete values ( colours) to intervals of continuous
values, no?
I don't use Matlab at all, I just sent this link to make sure that you
know what I'm looking for.
For now, I use a simple solution - creating a colorbar as additional plot:
library(ggplot2)
row <- 1:10
col <- 1:10
my.colors <- c("blue",rainbow(48),"green")
myDF <- expand.grid(row = row, col = col)
myDF$value <- 1:100
myDF$colIv <- my.colors[unclass(cut(myDF$value, breaks = seq(0,100,2)))]
myDF$meta <- "data"
scaleDF <- data.frame(col = 1, row = 1:50, colIv = my.colors, meta =
"scalebar", value = NA)
myDF <- rbind(myDF,scaleDF)
p <- ggplot(myDF, aes(x = col, y = row, fill = colIv)) + geom_tile()
p <- p + scale_fill_identity()
p <- p + facet_wrap( ~ meta , scales = "free_y")
p <- p + opts(legend.position = "none")
p
Antje
On 22 March 2011 03:05, Kohske Takahashi <takahash...@gmail.com> wrote:
> Hi,
>
> yes, scale_*_identity does this.
>
> As for the matlab type colormap (colorbar), now I'm just on the way to
> implement that for my own use.
> Generally, colormap cannot work with discrete scale, so maybe it is
> not available for your case (even in matlab? i don't know matlab is
> sensitive to if the variable is discrete or continuous).
>
> I attached the example code and output, but the current state is very
> very ad-hoc and hence is even far from alpha, and I'm not sure this
> feature is merged in the future release.
> If many people want this feature, and Hadley are considering to merge
> this kind of feature, then maybe I will try to make a progress on this
> feature.
>
>
> # note that this code cannot work with current version of ggplot2
> d <- data.frame(x=1:100, y=runif(100), fi=runif(100))
> ggplot(d, aes(x,y,colour=fi, size=fi)) + geom_point() +
> scale_colour_continuous(colorbar=TRUE)
>
> colorbar=TRUE works for scale_fill or scale_color (maybe also scale_alpha?)
>
> --
> Kohske Takahashi <takahash...@gmail.com>
>
> Research Center for Advanced Science and Technology,
> The University of Tokyo, Japan.
> http://www.fennel.rcast.u-tokyo.ac.jp/profilee_ktakahashi.html
>
>
>
--
yes, scale_*_identity does this.
As for the matlab type colormap (colorbar), now I'm just on the way to
implement that for my own use.
Generally, colormap cannot work with discrete scale, so maybe it is
not available for your case (even in matlab? i don't know matlab is
sensitive to if the variable is discrete or continuous).
I attached the example code and output, but the current state is very
very ad-hoc and hence is even far from alpha, and I'm not sure this
feature is merged in the future release.
If many people want this feature, and Hadley are considering to merge
this kind of feature, then maybe I will try to make a progress on this
feature.
# note that this code cannot work with current version of ggplot2
d <- data.frame(x=1:100, y=runif(100), fi=runif(100))
ggplot(d, aes(x,y,colour=fi, size=fi)) + geom_point() +
scale_colour_continuous(colorbar=TRUE)
colorbar=TRUE works for scale_fill or scale_color (maybe also scale_alpha?)
--
Kohske Takahashi <takahash...@gmail.com>
Research Center for Advanced Science and Technology,
The University of Tokyo, Japan.
http://www.fennel.rcast.u-tokyo.ac.jp/profilee_ktakahashi.html
On Mon, Mar 21, 2011 at 10:36 PM, Hadley Wickham <had...@rice.edu> wrote:
This would be cool - for integration into ggplot2, it would great if
you could make sure that it was implemented as it's own grid grob.
This makes use in other places easier.
Hadley