Re: [R] polygons on scatterplot3d

From: Jon Loehrke <jloehrke_at_umassd.edu>
Date: Fri, 11 Apr 2008 15:11:11 -0400

This is rather embarrassing, but the solution was fairly simple, thanks to Uwe and Martin for a GREAT PACKAGE. Anyhow, hope somebody else gets inspired at the very least

Jon

> library(scatterplot3d)
>
> # get a coastline
> library(maps)
> library(mapdata)
> coast<-map('worldHires', c('usa','canada'),xlim=c(-72,-67),
> ylim=c(40,45),fill=TRUE, col='gray')
> # note: substitute a simple polygon if you don't have maps and mapdata
> # coast<-list()
> # coast$x<-c(-70.5,-70.5,-70,-70)
> # coast$y<-c(41.2,43,43,41.2)
>
> lat<-c(41,41.5,42,42.5,43)
> long<-c(-71,-69.5,-70,-70.2,-69.8)
> weight<-c(80,20,30,30,10)

> p3d<-scatterplot3d(long, lat, weight, angle=75, type='h', box=FALSE,
> asp=1, grid=FALSE)
> p3d$points3d(coast$x,coast$y,rep(0, length(coast$x)), type='l',
> col='gray')

#####
v<-p3d$xyz.convert(coast$x, coast$y, rep(0,length(coast$x))) polygon(v$x, v$y,col='grey')
#####

> # Now how to fill this polygon...?
>

Begin forwarded message:

> From: Jon Loehrke <jloehrke_at_umassd.edu>
> Date: April 11, 2008 3:01:03 PM EDT
> To: r-help_at_r-project.org
> Subject: polygons on scatterplot3d
>
> Does anyone have any experience plotting complex polygons on a
> scatterplot3d display? I would like to present some spatially
> binned data in a 3-d type plot with background polygons (i.e.. a
> filled coastline map). I can get the coastline onto the plot window
> as a line type but cannot figure out how to fill the shape. I'm
> certain it may be possible but might require a bit of digging into
> the scatterplot3d code and rotational method.
>
> Any and all help or suggestions appreciated.
>
> EX.
>
> library(scatterplot3d)
>
> # get a coastline
> library(maps)
> library(mapdata)
> coast<-map('worldHires', c('usa','canada'),xlim=c(-72,-67),
> ylim=c(40,45),fill=TRUE, col='gray')
> # note: substitute a simple polygon if you don't have maps and mapdata
> # coast<-list()
> # coast$x<-c(-70.5,-70.5,-70,-70)
> # coast$y<-c(41.2,43,43,41.2)
>
> lat<-c(41,41.5,42,42.5,43)
> long<-c(-71,-69.5,-70,-70.2,-69.8)
> weight<-c(80,20,30,30,10)
>
> p3d<-scatterplot3d(long, lat, weight, angle=75, type='h', box=FALSE,
> asp=1, grid=FALSE)
> p3d$points3d(coast$x,coast$y,rep(0, length(coast$x)), type='l',
> col='gray')
> # Now how to fill this polygon...?
>
> Cheers,
>
> Jon
> Mac OS 10.5
> R 2.6.2
> Intelligence Finite
>
>
>
> Jon Loehrke
> Graduate Research Assistant
> Department of Fisheries Oceanography
> School for Marine Science and Technology
> University of Massachusetts
> 200 Mill Road, Suite 325
> Fairhaven, MA 02719
> jloehrke_at_umassd.edu
> 508-910-6393
>

Jon Loehrke
Graduate Research Assistant
Department of Fisheries Oceanography
School for Marine Science and Technology University of Massachusetts
200 Mill Road, Suite 325
Fairhaven, MA 02719
jloehrke_at_umassd.edu
508-910-6393

        [[alternative HTML version deleted]]



R-help_at_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. Received on Fri 11 Apr 2008 - 19:13:45 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 11 Apr 2008 - 19:30:29 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive