[R-es] Colores en floating.pie
pepeceb
pepeceb en yahoo.es
Jue Nov 13 14:40:29 CET 2014
Hola a todos,
mi problema es sencillo pero no logro dar con el.
Estoy incrustando unos floating.pie en un mapa. Relaciono unas variables (letras) con ciudades.
El caso es que no soy capaz de relacionar los colores de la leyenda con las variables, solamente utiliza los primeros colores por orden y yo quiero cada variable un color. Lo puedo hacer "a pedal" pero queria un método mas directo.
Adjunto mapa, excel con datos y script el cual tambien pongo aqui
saludos
library(maps)
library(mapdata)
library(plotrix)
# creating metafile
win.metafile(filename = "C:/RUN//prueba.emf",40,20,pointsize=15)
par(mar=c(2,2,2,2) + 0.1)
# mapping
map(database = "worldHires", xlim = c(-10,4), ylim = c(32,46),type="n")
map(database = "worldHires", xlim = c(-10,4), ylim = c(32,46),fill=T,col="darkseagreen",add=T)
text(-9.45,42.25,"Vigo",cex=3,font=1)
text(2.15,41,"Barcelona",cex=3,font=1)
text(-5.8,43.8,"Oviedo",cex=3,font=1)
text(-4.42,37,"Malaga",cex=3,font=1)
text(-3.68,43,"Santander",cex=3,font=1)
prueba<-read.csv("C:/RUN//prueba.csv",sep=";",dec=".")
prueba1<-as.matrix(prueba[,-1])
cores<-c("darkgreen","yellow","red","brown","orange","pink","green","yellow","lightgreen","blue","pink","lightblue","white","purple")
for (n in 1:nrow(prueba1))
{
kk<-as.vector(prueba1[n,])
floating.pie(kk[1],kk[2],x=kk[3:18],col=cores,radius=0.35)
}
#leyenda1
z<- c("A","B","C","D","E","F","G",
"H","I","J","K","L",
"M","N","O", "P")
legend(-10,41,z,pch=22,pt.cex=2,pt.bg=cores,title="LETTER",text.width=2,cex=2.5,inset=.03,bg="white")
# cierra el fichero metafile
dev.off()
------------ próxima parte ------------
Se ha borrado un adjunto en formato HTML...
URL: <https://stat.ethz.ch/pipermail/r-help-es/attachments/20141113/3f75b484/attachment-0001.html>
------------ próxima parte ------------
A non-text attachment was scrubbed...
Name: prueba.xls
Type: application/vnd.ms-excel
Size: 18944 bytes
Desc: no disponible
URL: <https://stat.ethz.ch/pipermail/r-help-es/attachments/20141113/3f75b484/attachment-0001.xls>
------------ próxima parte ------------
A non-text attachment was scrubbed...
Name: Prueba.r
Type: application/octet-stream
Size: 1311 bytes
Desc: no disponible
URL: <https://stat.ethz.ch/pipermail/r-help-es/attachments/20141113/3f75b484/attachment-0002.obj>
------------ próxima parte ------------
A non-text attachment was scrubbed...
Name: prueba.csv
Type: application/vnd.ms-excel
Size: 558 bytes
Desc: no disponible
URL: <https://stat.ethz.ch/pipermail/r-help-es/attachments/20141113/3f75b484/attachment-0001.xlb>
------------ próxima parte ------------
A non-text attachment was scrubbed...
Name: prueba.emf
Type: application/octet-stream
Size: 102712 bytes
Desc: no disponible
URL: <https://stat.ethz.ch/pipermail/r-help-es/attachments/20141113/3f75b484/attachment-0003.obj>
Más información sobre la lista de distribución R-help-es