manually condense the legend
The group you are posting to is a
Usenet group . Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
From:
Peng Zhang <pczh... @gmail.com>
Date: Tue, 18 Sep 2012 13:26:41 -0700 (PDT)
Local: Tues, Sep 18 2012 4:26 pm
Subject: manually condense the legend
Dear all,
I am plotting paths for seven subgroup (g). I specify color=g, so they will have different colors. Next I want to enhance one of them by choosing different size for one of seven subgroups, I then create a manual scale for size according to g==1.
In the plot, I will have both legends for color and size. My question is if there is a way that I can manually condense those two legends into one. (six lines with the regular size and different colors and one more line with enhanced size and another color)
Thanks, Peng
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
Kohske Takahashi <takahashi.koh... @gmail.com>
Date: Thu, 27 Sep 2012 07:14:55 +0900
Local: Wed, Sep 26 2012 6:14 pm
Subject: Re: manually condense the legend
Could you please provide a reproducible example:
https://github.com/hadley/devtools/wiki/Reproducibility
2012/9/19 Peng Zhang <pczh... @gmail.com>:
> Dear all,
> I am plotting paths for seven subgroup (g). I specify color=g, so they will
> have different colors. Next I want to enhance one of them by choosing
> different size for one of seven subgroups, I then create a manual scale for
> size according to g==1.
> In the plot, I will have both legends for color and size. My question is if
> there is a way that I can manually condense those two legends into one. (six
> lines with the regular size and different colors and one more line with
> enhanced size and another color)
> Thanks,
> Peng
> --
> You received this message because you are subscribed to the ggplot2 mailing
> list.
> Please provide a reproducible example:
> https://github.com/hadley/devtools/wiki/Reproducibility
> To post: email ggplot2@googlegroups.com
> To unsubscribe: email ggplot2+unsubscribe@googlegroups.com
> More options: http://groups.google.com/group/ggplot2
--
Kohske Takahashi <takahashi.koh
... @gmail.com>
Assistant Professor,
Research Center for Advanced Science and Technology,
The University of Tokyo, Japan.
http://www.fennel.rcast.u-tokyo.ac.jp/profilee_ktakahashi.html
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
Peng Zhang <pczh... @gmail.com>
Date: Wed, 26 Sep 2012 21:56:07 -0400
Local: Wed, Sep 26 2012 9:56 pm
Subject: Re: manually condense the legend
Thank you for your reply.
The following small code gives me two legends (one for color and one for size). Is it possible that I only have one legend?
thick red line ---- Cubic
thin green line ---- Linear
thick blue line ----- Quadratic
Thanks,
Peng
x = 1:9
a = rep(x, 3)
b = c(x, x^2, x^3)
col = c(rep("Linear", 9), rep("Quadratic", 9), rep("Cubic", 9))
size = c(rep("Linear", 9), rep("Non-Linear", 18))
d = data.frame(a, b, col, size)
library(ggplot2)
ggplot(data = d, aes(a, b, color = col, size = size)) + geom_path() + labs(color = "", size = "")
On 09/26/2012 06:14 PM, Kohske Takahashi wrote:
> Could you please provide a reproducible example:
>
https://github.com/hadley/devtools/wiki/Reproducibility
> 2012/9/19 Peng Zhang <pczh... @gmail.com>:
>> Dear all,
>> I am plotting paths for seven subgroup (g). I specify color=g, so they will
>> have different colors. Next I want to enhance one of them by choosing
>> different size for one of seven subgroups, I then create a manual scale for
>> size according to g==1.
>> In the plot, I will have both legends for color and size. My question is if
>> there is a way that I can manually condense those two legends into one. (six
>> lines with the regular size and different colors and one more line with
>> enhanced size and another color)
>> Thanks,
>> Peng
>> --
>> You received this message because you are subscribed to the ggplot2 mailing
>> list.
>> Please provide a reproducible example:
>> https://github.com/hadley/devtools/wiki/Reproducibility
>> To post: email ggplot2@googlegroups.com
>> To unsubscribe: email ggplot2+unsubscribe@googlegroups.com
>> More options: http://groups.google.com/group/ggplot2
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
Kohske Takahashi <takahashi.koh... @gmail.com>
Date: Thu, 27 Sep 2012 10:58:58 +0900
Local: Wed, Sep 26 2012 9:58 pm
Subject: Re: manually condense the legend
you can suppress to show guide by
ggplot(data = d, aes(a, b, color = col, size = size)) + geom_path() +
labs(color = "", size = "") + guides(size = "none")
2012/9/27 Peng Zhang <pczh... @gmail.com>:
> x = 1:9
> a = rep(x, 3)
> b = c(x, x^2, x^3)
> col = c(rep("Linear", 9), rep("Quadratic", 9), rep("Cubic", 9))
> size = c(rep("Linear", 9), rep("Non-Linear", 18))
> d = data.frame(a, b, col, size)
> library(ggplot2)
> ggplot(data = d, aes(a, b, color = col, size = size)) + geom_path() +
> labs(color = "", size = "")
--
Kohske Takahashi <takahashi.koh
... @gmail.com>
Assistant Professor,
Research Center for Advanced Science and Technology,
The University of Tokyo, Japan.
http://www.fennel.rcast.u-tokyo.ac.jp/profilee_ktakahashi.html
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
Peng Zhang <pczh... @gmail.com>
Date: Wed, 26 Sep 2012 22:06:03 -0400
Local: Wed, Sep 26 2012 10:06 pm
Subject: Re: manually condense the legend
Thanks. I kind of still want size, but to show it together with color.
(by changing the size of line in the color legend)
Best,
Peng
On 09/26/2012 09:58 PM, Kohske Takahashi wrote:
> you can suppress to show guide by
> ggplot(data = d, aes(a, b, color = col, size = size)) + geom_path() +
> labs(color = "", size = "") + guides(size = "none")
> 2012/9/27 Peng Zhang <pczh... @gmail.com>:
>> x = 1:9
>> a = rep(x, 3)
>> b = c(x, x^2, x^3)
>> col = c(rep("Linear", 9), rep("Quadratic", 9), rep("Cubic", 9))
>> size = c(rep("Linear", 9), rep("Non-Linear", 18))
>> d = data.frame(a, b, col, size)
>> library(ggplot2)
>> ggplot(data = d, aes(a, b, color = col, size = size)) + geom_path() +
>> labs(color = "", size = "")
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
Kohske Takahashi <takahashi.koh... @gmail.com>
Date: Thu, 27 Sep 2012 11:16:25 +0900
Local: Wed, Sep 26 2012 10:16 pm
Subject: Re: manually condense the legend
then try this:
x = 1:9
a = rep(x, 3)
b = c(x, x^2, x^3)
col = c(rep("Linear", 9), rep("Quadratic", 9), rep("Cubic", 9))
d = data.frame(a, b, col)
d$col <- factor(d$col, levels = c("Linear", "Quadratic", "Cubic"))
library(ggplot2)
ggplot(data = d, aes(a, b, color = col, size = col)) + geom_path() +
scale_size_manual(labels = levels(d$col), values = c(1, 6, 6))
2012/9/27 Peng Zhang <pczh... @gmail.com>:
> Thanks. I kind of still want size, but to show it together with color. (by
> changing the size of line in the color legend)
> Best,
> Peng
> On 09/26/2012 09:58 PM, Kohske Takahashi wrote:
>> you can suppress to show guide by
>> ggplot(data = d, aes(a, b, color = col, size = size)) + geom_path() +
>> labs(color = "", size = "") + guides(size = "none")
>> 2012/9/27 Peng Zhang <pczh... @gmail.com>:
>>> x = 1:9
>>> a = rep(x, 3)
>>> b = c(x, x^2, x^3)
>>> col = c(rep("Linear", 9), rep("Quadratic", 9), rep("Cubic", 9))
>>> size = c(rep("Linear", 9), rep("Non-Linear", 18))
>>> d = data.frame(a, b, col, size)
>>> library(ggplot2)
>>> ggplot(data = d, aes(a, b, color = col, size = size)) + geom_path() +
>>> labs(color = "", size = "")
--
Kohske Takahashi <takahashi.koh
... @gmail.com>
Assistant Professor,
Research Center for Advanced Science and Technology,
The University of Tokyo, Japan.
http://www.fennel.rcast.u-tokyo.ac.jp/profilee_ktakahashi.html
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
Peng Zhang <pczh... @gmail.com>
Date: Wed, 26 Sep 2012 22:21:55 -0400
Local: Wed, Sep 26 2012 10:21 pm
Subject: Re: manually condense the legend
That is exactly what I am looking for. Thank you for your help!
Best,
Peng
On 09/26/2012 10:16 PM, Kohske Takahashi wrote:
> then try this:
> x = 1:9
> a = rep(x, 3)
> b = c(x, x^2, x^3)
> col = c(rep("Linear", 9), rep("Quadratic", 9), rep("Cubic", 9))
> d = data.frame(a, b, col)
> d$col <- factor(d$col, levels = c("Linear", "Quadratic", "Cubic"))
> library(ggplot2)
> ggplot(data = d, aes(a, b, color = col, size = col)) + geom_path() +
> scale_size_manual(labels = levels(d$col), values = c(1, 6, 6))
> 2012/9/27 Peng Zhang <pczh... @gmail.com>:
>> Thanks. I kind of still want size, but to show it together with color. (by
>> changing the size of line in the color legend)
>> Best,
>> Peng
>> On 09/26/2012 09:58 PM, Kohske Takahashi wrote:
>>> you can suppress to show guide by
>>> ggplot(data = d, aes(a, b, color = col, size = size)) + geom_path() +
>>> labs(color = "", size = "") + guides(size = "none")
>>> 2012/9/27 Peng Zhang <pczh... @gmail.com>:
>>>> x = 1:9
>>>> a = rep(x, 3)
>>>> b = c(x, x^2, x^3)
>>>> col = c(rep("Linear", 9), rep("Quadratic", 9), rep("Cubic", 9))
>>>> size = c(rep("Linear", 9), rep("Non-Linear", 18))
>>>> d = data.frame(a, b, col, size)
>>>> library(ggplot2)
>>>> ggplot(data = d, aes(a, b, color = col, size = size)) + geom_path() +
>>>> labs(color = "", size = "")
You must
Sign in before you can post messages.
You do not have the permission required to post.