Skip to content

North Arrow (.png file) on a Map

5 messages · Rodrigo Aluizio, Yihui Xie, Greg Snow +1 more

#
Is this "arrow" satisfactory for you?

north.arrow = function(x, y, h) {
    polygon(c(x, x, x + h/2), c(y - h, y, y - (1 + sqrt(3)/2) * h),
col = "black", border = NA)
    polygon(c(x, x + h/2, x, x - h/2), c(y - h, y - (1 + sqrt(3)/2) *
h, y, y - (1 + sqrt(3)/2) * h))
    text(x, y, "N", adj = c(0.5, 0), cex = 4)
}
plot(1, type = "n", ylim = c(0, 1))
north.arrow(1, 0.8, 0.3)

Regards,
Yihui
--
Yihui Xie <xieyihui at gmail.com>
Phone: +86-(0)10-82509086 Fax: +86-(0)10-82509086
Mobile: +86-15810805877
Homepage: http://www.yihui.name
School of Statistics, Room 1037, Mingde Main Building,
Renmin University of China, Beijing, 100872, China
On Tue, Mar 10, 2009 at 7:21 PM, Rodrigo Aluizio <r.aluizio at gmail.com> wrote:
#
Thanks a lot Yihui, It's perfect, in fact exactly identical the I have as a
png file in my computer.
Thank you so much.

Regards
Rodrigo

-----Mensagem original-----
De: Yihui Xie [mailto:xieyihui at gmail.com] 
Enviada em: quarta-feira, 11 de mar?o de 2009 02:48
Para: Rodrigo Aluizio
Cc: R Help
Assunto: Re: [R] North Arrow (.png file) on a Map

Is this "arrow" satisfactory for you?

north.arrow = function(x, y, h) {
    polygon(c(x, x, x + h/2), c(y - h, y, y - (1 + sqrt(3)/2) * h),
col = "black", border = NA)
    polygon(c(x, x + h/2, x, x - h/2), c(y - h, y - (1 + sqrt(3)/2) *
h, y, y - (1 + sqrt(3)/2) * h))
    text(x, y, "N", adj = c(0.5, 0), cex = 4)
}
plot(1, type = "n", ylim = c(0, 1))
north.arrow(1, 0.8, 0.3)

Regards,
Yihui
--
Yihui Xie <xieyihui at gmail.com>
Phone: +86-(0)10-82509086 Fax: +86-(0)10-82509086
Mobile: +86-15810805877
Homepage: http://www.yihui.name
School of Statistics, Room 1037, Mingde Main Building,
Renmin University of China, Beijing, 100872, China



On Tue, Mar 10, 2009 at 7:21 PM, Rodrigo Aluizio <r.aluizio at gmail.com>
wrote:
in
I
Batimetria<-readShapeSpatial('C:/Users/Rodrigo/Documents/UFPR/Micropaleontol
Estados<-readShapeSpatial('C:/Users/Rodrigo/Documents/UFPR/Micropaleontologi
Faciologia<-readShapeSpatial('C:/Users/Rodrigo/Documents/UFPR/Micropaleontol
postscript('MapaCampos.eps',paper='special',onefile=F,horizontal=F,width=3.5
plot(Faciologia,ylab='',xlab='',col=c('lightgreen','lightgreen','lightgreen'
,'lightgreen','lightgreen','lightgray','lightgray','lightgray','lightgray','
lightgray','lightgray','lightgray','lightgray','lightgray','lightgray','ligh
tgray','lightgray','lightgray','lightgray','lightgray','lightgray','lightyel
text(Coord$Longitude[Coord$R?plicas=='1'],Coord$Latitude[Coord$R?plicas=='1'
text(Coord$Longitude[Coord$R?plicas=='2'],Coord$Latitude[Coord$R?plicas=='2'
text(Coord$Longitude[Coord$R?plicas=='3'],Coord$Latitude[Coord$R?plicas=='3'
legend(40.2,23.5,c('Uma','Duas','Tr?s'),pch=21,cex=1,pt.bg=c('red','yellow',
legend(39.8,23.5,c('Areia','Calc?rio','Lama'),pch=21,cex=1,pt.bg=c('lightyel
low','lightgray','lightgreen'),bty='n',pt.cex=2,pt.lwd=0.6,title='Faciologia
http://www.R-project.org/posting-guide.html
#
Another possibility is the my.symbols function in the TeachingDemos package.  You can define a polygon of your arrow (or other symbol), then use my.symbols to add it to an existing graph, the advantage of my.symbols is that the size of the arrow is absolute, not in terms of the scale of the original plot.
#
Also, see

# install.packages('sp')
example('spplot', package='sp')


Kingsford Jones
On Wed, Mar 11, 2009 at 9:38 AM, Greg Snow <Greg.Snow at imail.org> wrote: