dear all: Im trying to obtain maps on R, under mapdata library, but I cannot define the labels. Here is an example: library(mapdata) map("worldHires", c("portugal","spain"),ylim=c(34,46),xlim=c(-14,3.5)) axis(1,at=seq(-12,3,3)) axis(2) when I try the parameter xlab or ylab in axis, i get: parameter "ylab" couldn't be set in high-level plot() function any suggestion? thanks in advance for your always useful advices j. silva [[alternative HTML version deleted]]
jose silva wrote:> dear all: > > Im trying to obtain maps on R, under mapdata library, but I cannot define the labels. > Here is an example: > > library(mapdata) > map("worldHires", c("portugal","spain"),ylim=c(34,46),xlim=c(-14,3.5)) > axis(1,at=seq(-12,3,3)) > axis(2) > > when I try the parameter xlab or ylab in axis, i get: > parameter "ylab" couldn't be set in high-level plot() function > > any suggestion? thanks in advance for your always useful advicesDespite their names, x and y axis labels aren't really part of the axis, they're titles in the margins of the plot. Use the title() function to set them. You could probably also set them in map(), but I don't have it installed to check. mtext() is another general purpose way to put text in the margins. Duncan Murdoch
What makes you think that there is a ylab parameter?> args(map)function (database = "world", regions = ".", exact = FALSE, boundary = TRUE, interior = TRUE, projection = "", parameters = NULL, orientation = NULL, fill = FALSE, col = 1, plot = TRUE, add = FALSE, namesonly = FALSE, xlim = NULL, ylim = NULL, wrap = FALSE, resolution = if (plot) 1 else 0, type = "l", bg = par("bg"), mar = c(0, 0, par("mar")[3], 0.1), border = 0.01, ...) NULL>Just because there are ellipses does not mean that ylab is an appropriate parameter. If you type map you'll see the function. Go looking for where the ellipses are used and you find polygon(coord, col = col, ...) lines(coord, col = col, type = type, ...) So how why would these functions take a ylab parameter, they are for use within a plot. You have to remember that each function will only do what the author has programmed it to do. So if you need to put a label somewhere you could always use mtext(side = 2,line = 1,"A label on side 2") Tom> -----Original Message----- > From: r-help-bounces at stat.math.ethz.ch > [mailto:r-help-bounces at stat.math.ethz.ch]On Behalf Of jose silva > Sent: Tuesday, 31 May 2005 8:12 AM > To: r-help at stat.math.ethz.ch > Subject: [R] labels on map > > > dear all: > > Im trying to obtain maps on R, under mapdata library, but I > cannot define the labels. > Here is an example: > > library(mapdata) > map("worldHires", c("portugal","spain"),ylim=c(34,46),xlim=c(-14,3.5)) > axis(1,at=seq(-12,3,3)) > axis(2) > > when I try the parameter xlab or ylab in axis, i get: > parameter "ylab" couldn't be set in high-level plot() function?? > > any suggestion??? thanks in advance for your always useful advices > > j. silva > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html >
thanks Duncan, thats what I was looking for :) p.s. xlab in map() gives the same result as in axis() j. silva jose silva wrote:> dear all: > > Im trying to obtain maps on R, under mapdata library, but I cannot define the labels. > Here is an example: > > library(mapdata) > map("worldHires", c("portugal","spain"),ylim=c(34,46),xlim=c(-14,3.5)) > axis(1,at=seq(-12,3,3)) > axis(2) > > when I try the parameter xlab or ylab in axis, i get: > parameter "ylab" couldn't be set in high-level plot() function > > any suggestion? thanks in advance for your always useful advicesDespite their names, x and y axis labels aren't really part of the axis, they're titles in the margins of the plot. Use the title() function to set them. You could probably also set them in map(), but I don't have it installed to check. mtext() is another general purpose way to put text in the margins. Duncan Murdoch [[alternative HTML version deleted]]