Hello Thiago,
First, I owe you and the list a reproducible example (my first example
does not run properly - my bad):
dat <- data.frame(x=runif(50), y=runif(50),
category=sample(letters[1:3], size=50, replace=TRUE),
continuous=runif(50))
# You may want to do some spatial analysis on that data.frame
library(sp)
coordinates(dat) <- ~x+y
# Some spatial analysis here
# Now you want to plot it
library(ggplot2)
df <- as.data.frame(dat) # backtransforms dat into a data.frame object
(ggplot2 does not handle sp objects)
# Here I chose to plot the continuous variable with the size of the
bubbles, and the categorical variable with the colours
my.plot <- ggplot(data=df, aes(x=x, y=y)) +
geom_point(aes(size=continuous, colour=category)) + coord-equal()
print(my.plot)
Second, about plotting a shape file: yes, it is possible. Consider
this blog entry for example:
http://blog.revolutionanalytics.com/2009/11/choropleth-challenge-result.html
Basically, you want to use either geom_path() for simple state
boundaries, or geom_polygon() for polygons (e.g. you want to map some
attribute by state).
Sorry I haven't much experience with this. That could be a good
question on the ggplot2 mailing list
(http://groups.google.com/group/ggplot2).
Pierre
2010/8/25 Thiago Veloso <thi_veloso at yahoo.com.br>:
> Hello, Matthew.
> Just a superb complement of yours.
> I was about to ask the same question to Pierre and Paul, after thanking them for the useful and functional tip. I managed to follow the ggplot examples, but a next step would involve plotting my interest points over a shape file (state contour).
> Is that possible?
> Best wishes,
> Thiago.
>> --- On Tue, 24/8/10, Matthew Landis <landis at isciences.com> wrote:
>> From: Matthew Landis <landis at isciences.com>
> Subject: Re: [R-sig-Geo] Mapping multiple attributes at once
> To: r-sig-geo at stat.math.ethz.ch> Date: Tuesday, 24 August, 2010, 11:47
>> I've been following this topic with some interest, since this is something I might like to do fairly often. I'm not that familiar with ggplot2, but it looks really useful. Is there a way to overplot (or underplot) a shapefile (e.g. of coastlines) with the approach suggested by Paul?
>> Matt
>> On 8/24/2010 10:25 AM, Paul Hiemstra wrote:
>> In addition to the reply by Pierre Roudier, take a look at the ggplot2
>> pacakge. An example:
>>>>> -- ~~~~~~~~~~~~~~~~~~~~~~~~~~
> Matthew Landis, Ph.D.
> Research Scientist
> ISciences, LLC
> 61 Main St. Suite 200
> Burlington VT 05401
> 802.864.2999
> ~~~~~~~~~~~~~~~~~~~~~~~~~~
>> _______________________________________________
> R-sig-Geo mailing list
>R-sig-Geo at stat.math.ethz.ch>https://stat.ethz.ch/mailman/listinfo/r-sig-geo>>>>> [[alternative HTML version deleted]]
>>> _______________________________________________
> R-sig-Geo mailing list
>R-sig-Geo at stat.math.ethz.ch>https://stat.ethz.ch/mailman/listinfo/r-sig-geo>>