Dear all

I have such data

temp <- structure(list(x = c(1.22640164371796, 2.06054252402081, 
0.648406692116093,
0.502688462027622, 1.20971015442933, -1.33912870469085, 1.04053747125611,
1.08845105918041, 1.6409121019292, 0.596150765260052, 1.78013122654094,
0.4709422376346), y = c(9.09784917753244, 13.504613667029, 6.32295145782312,
4.91330174840941, 9.64505500251317, -4.36103528399272, 7.24123291486505,
9.71909654124553, 9.95890922449066, 5.50184347916369, 11.9072994677964,
5.42938848141327), a = c("b", "b", "b", "b", "b", "b", "a", "a",
"a", "a", "a", "a"), b = c("e", "e", "f", "f", "e", "e", "f",
"f", "f", "f", "f", "f"), c = c("j", "j", "j", "k", "k", "k",
NA, NA, NA, NA, NA, NA), d = c("o", "o", "o", "o", "o", "o",
"o", "o", "p", "p", "p", "p")), .Names = c("x", "y", "a", "b",
"c", "d"), row.names = c(NA, 12L), class = "data.frame")

and I can make ggplot with colour, shape, and size for variables a,b, and c.

p <- ggplot(temp, aes(x=x, y=y, colour=c, shape=b, size=a))
p+geom_point()+geom_smooth(method="lm", size=1, 
se=FALSE)+scale_size_discrete(range = c(2, 4))

Some values are missing for variable "c" and I would like to mark them by 
variable "d" let say by plotting different shape based on value in this 
variable d. Actually I can tune this variable to have missing values if 
necessary.

I thought that something like that can do it

p1 <- p+geom_point()+geom_smooth(method="lm", size=1, 
se=FALSE)+scale_size_discrete(range = c(2, 4))
p1 + geom_point(data=temp, aes(x=x, y=y, shape=d)) )

However I need to have separate legends for variable b and d respectively so 
that these values do not mix together.

To make it short, I need two different legends for shape for 2 variables in one 
plot.

Any hints?
Petr


________________________________
Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny 
pouze jeho adresátům.
Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně 
jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze 
svého systému.
Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email 
jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat.
Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či 
zpožděním přenosu e-mailu.

V případě, že je tento e-mail součástí obchodního jednání:
- vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, a 
to z jakéhokoliv důvodu i bez uvedení důvodu.
- a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; 
Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany příjemce 
s dodatkem či odchylkou.
- trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným 
dosažením shody na všech jejích náležitostech.
- odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost 
žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně 
pověřen a takové pověření nebo plná moc byly adresátovi tohoto emailu případně 
osobě, kterou adresát zastupuje, předloženy nebo jejich existence je adresátovi 
či osobě jím zastoupené známá.

This e-mail and any documents attached to it may be confidential and are 
intended only for its intended recipients.
If you received this e-mail by mistake, please immediately inform its sender. 
Delete the contents of this e-mail with all attachments and its copies from 
your system.
If you are not the intended recipient of this e-mail, you are not authorized to 
use, disseminate, copy or disclose this e-mail in any manner.
The sender of this e-mail shall not be liable for any possible damage caused by 
modifications of the e-mail or by delay with transfer of the email.

In case that this e-mail forms part of business dealings:
- the sender reserves the right to end negotiations about entering into a 
contract in any time, for any reason, and without stating any reasoning.
- if the e-mail contains an offer, the recipient is entitled to immediately 
accept such offer; The sender of this e-mail (offer) excludes any acceptance of 
the offer on the part of the recipient containing any amendment or variation.
- the sender insists on that the respective contract is concluded only upon an 
express mutual agreement on all its aspects.
- the sender of this e-mail informs that he/she is not authorized to enter into 
any contracts on behalf of the company except for cases in which he/she is 
expressly authorized to do so in writing, and such authorization or power of 
attorney is submitted to the recipient or the person represented by the 
recipient, or the existence of such authorization is known to the recipient of 
the person represented by the recipient.
______________________________________________
R-help@r-project.org 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 via email to