Re: [R] 3d plot of earth with cut

2020-10-27 Thread Duncan Murdoch

One addition to this thread:

I've just committed contourLines3d() to rgl (in version 0.102.28).  It 
will let you display contour lines of a function on any surface in a scene.


Duncan Murdoch

On 23/10/2020 2:30 p.m., Duncan Murdoch wrote:

Good to hear you've made such progress.  Just a couple of comments:

- You should use points3d() rather than rgl.points().  The latter is a
low level function that may have unpleasant side effects, especially
mixing it with other *3d() functions like persp3d().
- There are several ways to draw a flat surface to illustrate your data.
   Which one to use really depends on the form of data.  With randomly
distributed points, yours is as good as any.  If the values are a known
function of location, there are probably better ones.

Duncan Murdoch


On 23/10/2020 12:18 p.m., Balint Radics wrote:

Dear All,

Thanks a lot for the useful help again. I manage to get it done up to a
point where I think I
just need to apply some smoothing/interpolation to get denser points, to
make it nice.
Basically, I started from Duncen's script to visualize and make the
clipping along a plane
at a slice.
Then I map my data points' values to a color palette and just plot them as
points on this
plane. Since I have already the (x,y,z) coordinates for my points in the
slice's plane
I just plot them directly. I copied the code below..

To make it nicer would be able to make a real "smooth" map on the 2D
surface, rather
than plotting all points (e.g. using polygons?).

Best,
Balint


# Construct a plane at a given longitude
r <- 6378.1 # radius of Earth in km
fixlong <- 10.0*pi/180.0 # The longitude slice

# Construct a plane in 3D:
# Let vec(P0) = (P0x, P0y, P0z) be a point given in the plane of the
longitude
# let vec(n) = (nx, ny, nz) an orthogonal vector to this plane
# then vec(P) = (Px, Py, Pz) will be in the plane if (vec(P) - vec(P0)) *
vec(n) = 0
# We pick 2 arbitrary vectors in the plane out of 3 points
p0x <- r*cos(2)*cos(fixlong)
p0y <- r*cos(2)*sin(fixlong)
p0z <- r*sin(2)
p1x <- r*cos(2.5)*cos(fixlong)
p1y <- r*cos(2.5)*sin(fixlong)
p1z <- r*sin(2.5)
p2x <- r*cos(3)*cos(fixlong)
p2y <- r*cos(3)*sin(fixlong)
p2z <- r*sin(3)
# Make the vectors pointing to P and P0
v1x <- p1x - p0x # P
v1y <- p1y - p0y
v1z <- p1z - p0z
v2x <- p2x - p0x # P0
v2y <- p2y - p0y
v2z <- p2z - p0z

# The cross product will give a vector orthogonal to the plane, (nx, ny, nz)
nx <- v1y*v2z - v1z*v2y;
ny <- v1z*v2x - v1x*v2z;
nz <- v1x*v2y - v1y*v2x;
# normalize
nMag <- sqrt(nx*nx + ny*ny + nz*nz);
nx <- nx / nMag;
ny <- ny / nMag;
nz <- nz / nMag;

# Plane equation (vec(P) - vec(P0)) * vec(n) = 0, with P=(x, y, z), P0=(x0,
y0, z0),
# giving a*(x-x0)+b*(y-y0)+c*(z-z0) = 0, where x,x0 are two points in the
plane
# a, b, c are the normal vector coordinates
a <- -nx
b <- -ny
c <- -nz
d <- -(a*v2x + b*v2y + c*v2z )

open3d()

# Plot the globe - from Duncan
# points of a sphere
lat <- matrix(seq(90, -90, len = 50)*pi/180, 50, 50, byrow = TRUE)
long <- matrix(seq(-180, 180, len = 50)*pi/180, 50, 50)
x <- r*cos(lat)*cos(long)
y <- r*cos(lat)*sin(long)
z <- r*sin(lat)
# Plot with texture
ids <- persp3d(x, y, z, col = "white",
  texture = system.file("textures/world.png", package =
"rgl"),
  specular = "black", axes = FALSE, box = FALSE, xlab = "",
  ylab = "", zlab = "", normal_x = x, normal_y = y, normal_z
= z)

# Plot the plane across the longitude slice
#planes3d(a, b, c, d, alpha = 0.6) # optionally visualize the plane
# Apply clipping to only one side of the plane using the normal vector
clipplanes3d(a, b, c, d)

# Map something onto this plane - how? Let's try with rgl.points and
mapping the colors
# The data is: data_activity and variables are $X, $Y, $Z, $Ar
library(leaflet)
# map the colors to the data values
pal <- colorNumeric(
palette = "Blues",
domain = data_activity$Ar) #
# plot the points and the mapped colors
rgl.points( data_activity$X, data_activity$Y, data_activity$Z, color =
pal(data_activity$Ar), size=3)




On Fri, Oct 23, 2020 at 1:50 AM aBBy Spurdle, ⍺XY 
wrote:


It should be a 2D slice/plane embedded into a 3D space.


I was able to come up with the plot, attached.
My intention was to plot national boundaries on the surface of a sphere.
And put the slice inside.
However, I haven't (as yet) worked out how to get the coordinates for
the boundaries.

Let me know, if of any value.
And I'll post the code.
(But needs to be polished first)



[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.






Re: [R] 3d plot of earth with cut

2020-10-23 Thread Duncan Murdoch

Good to hear you've made such progress.  Just a couple of comments:

- You should use points3d() rather than rgl.points().  The latter is a 
low level function that may have unpleasant side effects, especially 
mixing it with other *3d() functions like persp3d().
- There are several ways to draw a flat surface to illustrate your data. 
 Which one to use really depends on the form of data.  With randomly 
distributed points, yours is as good as any.  If the values are a known 
function of location, there are probably better ones.


Duncan Murdoch


On 23/10/2020 12:18 p.m., Balint Radics wrote:

Dear All,

Thanks a lot for the useful help again. I manage to get it done up to a
point where I think I
just need to apply some smoothing/interpolation to get denser points, to
make it nice.
Basically, I started from Duncen's script to visualize and make the
clipping along a plane
at a slice.
Then I map my data points' values to a color palette and just plot them as
points on this
plane. Since I have already the (x,y,z) coordinates for my points in the
slice's plane
I just plot them directly. I copied the code below..

To make it nicer would be able to make a real "smooth" map on the 2D
surface, rather
than plotting all points (e.g. using polygons?).

Best,
Balint


# Construct a plane at a given longitude
r <- 6378.1 # radius of Earth in km
fixlong <- 10.0*pi/180.0 # The longitude slice

# Construct a plane in 3D:
# Let vec(P0) = (P0x, P0y, P0z) be a point given in the plane of the
longitude
# let vec(n) = (nx, ny, nz) an orthogonal vector to this plane
# then vec(P) = (Px, Py, Pz) will be in the plane if (vec(P) - vec(P0)) *
vec(n) = 0
# We pick 2 arbitrary vectors in the plane out of 3 points
p0x <- r*cos(2)*cos(fixlong)
p0y <- r*cos(2)*sin(fixlong)
p0z <- r*sin(2)
p1x <- r*cos(2.5)*cos(fixlong)
p1y <- r*cos(2.5)*sin(fixlong)
p1z <- r*sin(2.5)
p2x <- r*cos(3)*cos(fixlong)
p2y <- r*cos(3)*sin(fixlong)
p2z <- r*sin(3)
# Make the vectors pointing to P and P0
v1x <- p1x - p0x # P
v1y <- p1y - p0y
v1z <- p1z - p0z
v2x <- p2x - p0x # P0
v2y <- p2y - p0y
v2z <- p2z - p0z

# The cross product will give a vector orthogonal to the plane, (nx, ny, nz)
nx <- v1y*v2z - v1z*v2y;
ny <- v1z*v2x - v1x*v2z;
nz <- v1x*v2y - v1y*v2x;
# normalize
nMag <- sqrt(nx*nx + ny*ny + nz*nz);
nx <- nx / nMag;
ny <- ny / nMag;
nz <- nz / nMag;

# Plane equation (vec(P) - vec(P0)) * vec(n) = 0, with P=(x, y, z), P0=(x0,
y0, z0),
# giving a*(x-x0)+b*(y-y0)+c*(z-z0) = 0, where x,x0 are two points in the
plane
# a, b, c are the normal vector coordinates
a <- -nx
b <- -ny
c <- -nz
d <- -(a*v2x + b*v2y + c*v2z )

open3d()

# Plot the globe - from Duncan
# points of a sphere
lat <- matrix(seq(90, -90, len = 50)*pi/180, 50, 50, byrow = TRUE)
long <- matrix(seq(-180, 180, len = 50)*pi/180, 50, 50)
x <- r*cos(lat)*cos(long)
y <- r*cos(lat)*sin(long)
z <- r*sin(lat)
# Plot with texture
ids <- persp3d(x, y, z, col = "white",
 texture = system.file("textures/world.png", package =
"rgl"),
 specular = "black", axes = FALSE, box = FALSE, xlab = "",
 ylab = "", zlab = "", normal_x = x, normal_y = y, normal_z
= z)

# Plot the plane across the longitude slice
#planes3d(a, b, c, d, alpha = 0.6) # optionally visualize the plane
# Apply clipping to only one side of the plane using the normal vector
clipplanes3d(a, b, c, d)

# Map something onto this plane - how? Let's try with rgl.points and
mapping the colors
# The data is: data_activity and variables are $X, $Y, $Z, $Ar
library(leaflet)
# map the colors to the data values
pal <- colorNumeric(
   palette = "Blues",
   domain = data_activity$Ar) #
# plot the points and the mapped colors
rgl.points( data_activity$X, data_activity$Y, data_activity$Z, color =
pal(data_activity$Ar), size=3)




On Fri, Oct 23, 2020 at 1:50 AM aBBy Spurdle, ⍺XY 
wrote:


It should be a 2D slice/plane embedded into a 3D space.


I was able to come up with the plot, attached.
My intention was to plot national boundaries on the surface of a sphere.
And put the slice inside.
However, I haven't (as yet) worked out how to get the coordinates for
the boundaries.

Let me know, if of any value.
And I'll post the code.
(But needs to be polished first)



[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.



__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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, 

Re: [R] 3d plot of earth with cut

2020-10-23 Thread Balint Radics
Dear All,

Thanks a lot for the useful help again. I manage to get it done up to a
point where I think I
just need to apply some smoothing/interpolation to get denser points, to
make it nice.
Basically, I started from Duncen's script to visualize and make the
clipping along a plane
at a slice.
Then I map my data points' values to a color palette and just plot them as
points on this
plane. Since I have already the (x,y,z) coordinates for my points in the
slice's plane
I just plot them directly. I copied the code below..

To make it nicer would be able to make a real "smooth" map on the 2D
surface, rather
than plotting all points (e.g. using polygons?).

Best,
Balint


# Construct a plane at a given longitude
r <- 6378.1 # radius of Earth in km
fixlong <- 10.0*pi/180.0 # The longitude slice

# Construct a plane in 3D:
# Let vec(P0) = (P0x, P0y, P0z) be a point given in the plane of the
longitude
# let vec(n) = (nx, ny, nz) an orthogonal vector to this plane
# then vec(P) = (Px, Py, Pz) will be in the plane if (vec(P) - vec(P0)) *
vec(n) = 0
# We pick 2 arbitrary vectors in the plane out of 3 points
p0x <- r*cos(2)*cos(fixlong)
p0y <- r*cos(2)*sin(fixlong)
p0z <- r*sin(2)
p1x <- r*cos(2.5)*cos(fixlong)
p1y <- r*cos(2.5)*sin(fixlong)
p1z <- r*sin(2.5)
p2x <- r*cos(3)*cos(fixlong)
p2y <- r*cos(3)*sin(fixlong)
p2z <- r*sin(3)
# Make the vectors pointing to P and P0
v1x <- p1x - p0x # P
v1y <- p1y - p0y
v1z <- p1z - p0z
v2x <- p2x - p0x # P0
v2y <- p2y - p0y
v2z <- p2z - p0z

# The cross product will give a vector orthogonal to the plane, (nx, ny, nz)
nx <- v1y*v2z - v1z*v2y;
ny <- v1z*v2x - v1x*v2z;
nz <- v1x*v2y - v1y*v2x;
# normalize
nMag <- sqrt(nx*nx + ny*ny + nz*nz);
nx <- nx / nMag;
ny <- ny / nMag;
nz <- nz / nMag;

# Plane equation (vec(P) - vec(P0)) * vec(n) = 0, with P=(x, y, z), P0=(x0,
y0, z0),
# giving a*(x-x0)+b*(y-y0)+c*(z-z0) = 0, where x,x0 are two points in the
plane
# a, b, c are the normal vector coordinates
a <- -nx
b <- -ny
c <- -nz
d <- -(a*v2x + b*v2y + c*v2z )

open3d()

# Plot the globe - from Duncan
# points of a sphere
lat <- matrix(seq(90, -90, len = 50)*pi/180, 50, 50, byrow = TRUE)
long <- matrix(seq(-180, 180, len = 50)*pi/180, 50, 50)
x <- r*cos(lat)*cos(long)
y <- r*cos(lat)*sin(long)
z <- r*sin(lat)
# Plot with texture
ids <- persp3d(x, y, z, col = "white",
texture = system.file("textures/world.png", package =
"rgl"),
specular = "black", axes = FALSE, box = FALSE, xlab = "",
ylab = "", zlab = "", normal_x = x, normal_y = y, normal_z
= z)

# Plot the plane across the longitude slice
#planes3d(a, b, c, d, alpha = 0.6) # optionally visualize the plane
# Apply clipping to only one side of the plane using the normal vector
clipplanes3d(a, b, c, d)

# Map something onto this plane - how? Let's try with rgl.points and
mapping the colors
# The data is: data_activity and variables are $X, $Y, $Z, $Ar
library(leaflet)
# map the colors to the data values
pal <- colorNumeric(
  palette = "Blues",
  domain = data_activity$Ar) #
# plot the points and the mapped colors
rgl.points( data_activity$X, data_activity$Y, data_activity$Z, color =
pal(data_activity$Ar), size=3)




On Fri, Oct 23, 2020 at 1:50 AM aBBy Spurdle, ⍺XY 
wrote:

> > It should be a 2D slice/plane embedded into a 3D space.
>
> I was able to come up with the plot, attached.
> My intention was to plot national boundaries on the surface of a sphere.
> And put the slice inside.
> However, I haven't (as yet) worked out how to get the coordinates for
> the boundaries.
>
> Let me know, if of any value.
> And I'll post the code.
> (But needs to be polished first)
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] 3d plot of earth with cut

2020-10-22 Thread aBBy Spurdle , ⍺XY
> It should be a 2D slice/plane embedded into a 3D space.

I was able to come up with the plot, attached.
My intention was to plot national boundaries on the surface of a sphere.
And put the slice inside.
However, I haven't (as yet) worked out how to get the coordinates for
the boundaries.

Let me know, if of any value.
And I'll post the code.
(But needs to be polished first)
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] 3d plot of earth with cut

2020-10-22 Thread Balint Radics
Thanks for your idea. It should be a 2D slice/plane embedded into a 3D
space. Could be static, I just need to make a single figure from it for
illustration of the Earth together with its interior in 3D. So, the
interior would be a slice in 2D along a fixed longitude. And along this 2D
slice would be a heatmap. Again, embedded in 3D, since it would be shown as
a slice of Earth in 3D.

Duncan’s suggestion is almost exactly what I need so I will try that as a
start. Like that it is rotateable which is not a must, but it helps to
figure out which angle of view is the best, I hope i can save it as a PDF
or image.

Also, happy to try other solutions as well, if you think I overcomplicate
it!

Balint

On Thu 22. Oct 2020 at 23:54, aBBy Spurdle, ⍺XY  wrote:

> If you have "value" as a function of latitude and radius, isn't that a
> 2D (not 3D) scalar field?
> Which can be plotted using a regular heatmap.
>
> If you want a curved edge where depth=0 (radius=?), that's not too
> difficult to achieve.
> Not quite sure what continent boundaries mean in this context, but
> that could possibly be added to.
>
> Or do you want a 2D slice superimposed within a 3D space?
>
> And if so, does it need to be dynamic?
> (i.e. Rotate the whole thing, with a trackball/mouse).
>
> Note that the further you go down the list above, the more work is
> required.
>
>
> On Fri, Oct 23, 2020 at 7:41 AM Balint Radics 
> wrote:
> >
> > Hello,
> >
> > Could someone suggest a package/way to make a 3D raster plot of the Earth
> > (with continent boundaries), and then make a "cut" or "slice" of it such
> > that one can also visualize some scalar quantity as a function of the
> > Radius/Depth across that given slice ?
> >
> > Formally, I would have a given, fixed longitude, and a list of vectors
> > {latitude, radius, Value}
> > that would show the distribution of the quantity "Value" at various
> depths
> > and latitudes in 3D.
> >
> > Thanks a lot in advance,
> > Balint
> >
> > [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > 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.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] 3d plot of earth with cut

2020-10-22 Thread Balint Radics
Hello,

this is very close to exactly what I need! I have tried it and it works
nicely, I just have to map some values onto to the polygon or 2D plane that
cuts into the 3D object.

Thanks!

Balint

On Thu 22. Oct 2020 at 21:28, Duncan Murdoch 
wrote:

> On 21/10/2020 8:45 a.m., Balint Radics wrote:
> > Hello,
> >
> > Could someone suggest a package/way to make a 3D raster plot of the Earth
> > (with continent boundaries), and then make a "cut" or "slice" of it such
> > that one can also visualize some scalar quantity as a function of the
> > Radius/Depth across that given slice ?
> >
> > Formally, I would have a given, fixed longitude, and a list of vectors
> > {latitude, radius, Value}
> > that would show the distribution of the quantity "Value" at various
> depths
> > and latitudes in 3D.
>
> The rgl package has a full sphere of the Earth with (obsolete) political
> boundaries in example(persp3d).  To cut it in half along the plane
> through a given longitude (and that longitude + 180 deg), you could use
> clipPlanes3d, or clipObj3d.  For example,
>
> library(rgl)
> lat <- matrix(seq(90, -90, len = 50)*pi/180, 50, 50, byrow = TRUE)
> long <- matrix(seq(-180, 180, len = 50)*pi/180, 50, 50)
>
> r <- 6378.1 # radius of Earth in km
> x <- r*cos(lat)*cos(long)
> y <- r*cos(lat)*sin(long)
> z <- r*sin(lat)
>
> open3d()
> ids <- persp3d(x, y, z, col = "white",
>  texture = system.file("textures/worldsmall.png", package = "rgl"),
>  specular = "black", axes = FALSE, box = FALSE, xlab = "", ylab
> = "", zlab = "",
>  normal_x = x, normal_y = y, normal_z = z)
>
> clipFn <- function(coords) {
>pmax(coords[,1], coords[,2]) # Just an example...
> }
> clipObj3d(ids["surface"], clipFn)
>
>
> Filling in the exposed surface could be done with polygon3d(), with some
> work to construct the polygon. Displaying the function across that
> surface could be done in a couple of ways, either by using a texture map
> (like for the map), or subdividing the polygon and setting colour by the
> coordinates of each vertex.
>
> Note that the clipObj3d function isn't on CRAN yet; there you'd have to
> use clipPlanes3d.  You can get the newer version from R-forge.
>
> Duncan Murdoch
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] 3d plot of earth with cut

2020-10-22 Thread Balint Radics
Hi

Thanks a lot for this pointer, I will need to look at it. I did indeed
google but did not find an example. In the meantime some additional
solutions were suggested, that I also need to try.

Cheers,
Balint

On Thu 22. Oct 2020 at 20:56, Bert Gunter  wrote:

> 1. Have you looked here:
> https://cran.r-project.org/web/views/Spatial.html
> (I assume you have done some web searches on possible terms like "3D Earth
> Data R" or whatever)
>
> 2. You might try posting on the r-sig-geo list rather than here, where
> relative expertise may more likely be available.
>
> Cheers,
>
> Bert Gunter
>
> "The trouble with having an open mind is that people keep coming along and
> sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>
>
> On Thu, Oct 22, 2020 at 11:41 AM Balint Radics 
> wrote:
>
>> Hello,
>>
>> Could someone suggest a package/way to make a 3D raster plot of the Earth
>> (with continent boundaries), and then make a "cut" or "slice" of it such
>> that one can also visualize some scalar quantity as a function of the
>> Radius/Depth across that given slice ?
>>
>> Formally, I would have a given, fixed longitude, and a list of vectors
>> {latitude, radius, Value}
>> that would show the distribution of the quantity "Value" at various depths
>> and latitudes in 3D.
>>
>> Thanks a lot in advance,
>> Balint
>>
>> [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> 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.
>>
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] 3d plot of earth with cut

2020-10-22 Thread aBBy Spurdle , ⍺XY
If you have "value" as a function of latitude and radius, isn't that a
2D (not 3D) scalar field?
Which can be plotted using a regular heatmap.

If you want a curved edge where depth=0 (radius=?), that's not too
difficult to achieve.
Not quite sure what continent boundaries mean in this context, but
that could possibly be added to.

Or do you want a 2D slice superimposed within a 3D space?

And if so, does it need to be dynamic?
(i.e. Rotate the whole thing, with a trackball/mouse).

Note that the further you go down the list above, the more work is required.


On Fri, Oct 23, 2020 at 7:41 AM Balint Radics  wrote:
>
> Hello,
>
> Could someone suggest a package/way to make a 3D raster plot of the Earth
> (with continent boundaries), and then make a "cut" or "slice" of it such
> that one can also visualize some scalar quantity as a function of the
> Radius/Depth across that given slice ?
>
> Formally, I would have a given, fixed longitude, and a list of vectors
> {latitude, radius, Value}
> that would show the distribution of the quantity "Value" at various depths
> and latitudes in 3D.
>
> Thanks a lot in advance,
> Balint
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] 3d plot of earth with cut

2020-10-22 Thread Duncan Murdoch

On 21/10/2020 8:45 a.m., Balint Radics wrote:

Hello,

Could someone suggest a package/way to make a 3D raster plot of the Earth
(with continent boundaries), and then make a "cut" or "slice" of it such
that one can also visualize some scalar quantity as a function of the
Radius/Depth across that given slice ?

Formally, I would have a given, fixed longitude, and a list of vectors
{latitude, radius, Value}
that would show the distribution of the quantity "Value" at various depths
and latitudes in 3D.


The rgl package has a full sphere of the Earth with (obsolete) political 
boundaries in example(persp3d).  To cut it in half along the plane 
through a given longitude (and that longitude + 180 deg), you could use 
clipPlanes3d, or clipObj3d.  For example,


library(rgl)
lat <- matrix(seq(90, -90, len = 50)*pi/180, 50, 50, byrow = TRUE)
long <- matrix(seq(-180, 180, len = 50)*pi/180, 50, 50)

r <- 6378.1 # radius of Earth in km
x <- r*cos(lat)*cos(long)
y <- r*cos(lat)*sin(long)
z <- r*sin(lat)

open3d()
ids <- persp3d(x, y, z, col = "white",
texture = system.file("textures/worldsmall.png", package = "rgl"),
specular = "black", axes = FALSE, box = FALSE, xlab = "", ylab 
= "", zlab = "",

normal_x = x, normal_y = y, normal_z = z)

clipFn <- function(coords) {
  pmax(coords[,1], coords[,2]) # Just an example...
}
clipObj3d(ids["surface"], clipFn)


Filling in the exposed surface could be done with polygon3d(), with some 
work to construct the polygon. Displaying the function across that 
surface could be done in a couple of ways, either by using a texture map 
(like for the map), or subdividing the polygon and setting colour by the 
coordinates of each vertex.


Note that the clipObj3d function isn't on CRAN yet; there you'd have to 
use clipPlanes3d.  You can get the newer version from R-forge.


Duncan Murdoch

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] 3d plot of earth with cut

2020-10-22 Thread Bert Gunter
1. Have you looked here:
https://cran.r-project.org/web/views/Spatial.html
(I assume you have done some web searches on possible terms like "3D Earth
Data R" or whatever)

2. You might try posting on the r-sig-geo list rather than here, where
relative expertise may more likely be available.

Cheers,

Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Thu, Oct 22, 2020 at 11:41 AM Balint Radics 
wrote:

> Hello,
>
> Could someone suggest a package/way to make a 3D raster plot of the Earth
> (with continent boundaries), and then make a "cut" or "slice" of it such
> that one can also visualize some scalar quantity as a function of the
> Radius/Depth across that given slice ?
>
> Formally, I would have a given, fixed longitude, and a list of vectors
> {latitude, radius, Value}
> that would show the distribution of the quantity "Value" at various depths
> and latitudes in 3D.
>
> Thanks a lot in advance,
> Balint
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


[R] 3d plot of earth with cut

2020-10-22 Thread Balint Radics
Hello,

Could someone suggest a package/way to make a 3D raster plot of the Earth
(with continent boundaries), and then make a "cut" or "slice" of it such
that one can also visualize some scalar quantity as a function of the
Radius/Depth across that given slice ?

Formally, I would have a given, fixed longitude, and a list of vectors
{latitude, radius, Value}
that would show the distribution of the quantity "Value" at various depths
and latitudes in 3D.

Thanks a lot in advance,
Balint

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] 3D Plot with Date Axis?

2017-10-28 Thread David Winsemius

> On Oct 27, 2017, at 12:22 PM, Alex Restrepo  wrote:
> 
> Hello,
> 
> I would like to format the X axis of the plot created via the scatterplot3d 
> function or any other function which will work.
> 
> Here is an example of what I am trying to do:
> 
> library("scatterplot3d")
> 
> mydf=data.frame(rate=c(1,1,4,4), age=c(2,2,5,5), market_date=c('2017-01-01', 
> '2017-02-02', '2017-03-03', '2017-04-04'))
> 
> scatterplot3d(mydf$market_date, mydf$rate, mydf$age, xaxt="n")
> 
> axis.Date(1, mydf$market_date, format="%Y-%m-%d")
> 
> I tried to hide the x axis, but it looks like xaxt is not working for the 
> scatterplot3d function.

Please read the "?scatterplot3d page more carefully. I think you should be 
looking for the x.ticklabs parameter.

-- 
David.
> 
> Using the above example, could someone please provide me with some guidance 
> and help?
> 
> Many Thanks,
> 
> Alex
> 
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


[R] 3D Plot with Date Axis?

2017-10-27 Thread Alex Restrepo
Hello,

I would like to format the X axis of the plot created via the scatterplot3d 
function or any other function which will work.

Here is an example of what I am trying to do:

library("scatterplot3d")

mydf=data.frame(rate=c(1,1,4,4), age=c(2,2,5,5), market_date=c('2017-01-01', 
'2017-02-02', '2017-03-03', '2017-04-04'))

scatterplot3d(mydf$market_date, mydf$rate, mydf$age, xaxt="n")

axis.Date(1, mydf$market_date, format="%Y-%m-%d")

I tried to hide the x axis, but it looks like xaxt is not working for the 
scatterplot3d function.

Using the above example, could someone please provide me with some guidance and 
help?

Many Thanks,

Alex


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] 3D plot with coordinates

2017-06-22 Thread Duncan Murdoch

On 22/06/2017 3:15 AM, Alaios wrote:

Thanks. So after searching 4 hours last night it looks like that there
is no R package that can do this right now. Any other ideas or
suggestions might be helpful.


I don't know what you want the display to look like, but if you want it 
to be rotatable, rgl is probably the right package to use.


It doesn't directly support the coordinate system you're using, so you 
need to figure out where you want your points (or line segments) plotted 
in Euclidean coordinates, and write your own function to plot those. 
For example, to plot (r, theta) in polar coordinates in the XY plane, 
use (x = r*cos(theta), y = r*sin(theta), z = 0).


Duncan Murdoch


Regards
Alex


On Wednesday, June 21, 2017 3:21 PM, Alaios via R-help
 wrote:


Thanks Duncan for the replyI can not suppress anything these are
radiation pattern measurements that are typically are taken at X,Y and Z
planes. See an example here, where I want to plot the measurements for
the red, green and blue planes (so the image below withouth the 3d green
structure
inside)https://www.researchgate.net/publication/258391165/figure/fig7/AS:322947316240401@1454008048835/Radiation-pattern-of-Archimedean-spiral-antenna-a-3D-and-b-elevation-cuts-at-phi.png


I am quite confident that there is a tool in R to help me do this 3D
plot, and even better rotatable.
Thanks for the reply to allAlex

On Wednesday, June 21, 2017 1:07 PM, Duncan Murdoch
> wrote:


On 21/06/2017 5:23 AM, Alaios via R-help wrote:

Thanks a lot for the reply.After  looking at different parts of the

code today I was able to start with simple 2D polar plots as the
attached pdf file.  In case the attachment is not visible I used the
plot.polar function to create something like
that.https://vijaybarve.files.wordpress.com/2013/04/polarplot-05.png

Now the idea now will be to put three of those (for X,Y,Z) in a 3d

rotatable plane. I tried the rgl function but is not clear how I can use
directly polar coordinates to draw the points at the three different planes.

Any ideas on that?


You can't easily do what you're trying to do.  You have 6 coordinates to
display:  the 3 angles and values corresponding to each of them.  You
need to suppress something.

If the values for matching angles correspond to each other (e.g. x=23
degrees and y=23 degrees and z=23 degrees all correspond to the same
observation), then I'd suggest suppressing the angles.  Just do a
scatterplot of the 3 corresponding values.  It might make sense to join
them (to make a path as the angles change), and perhaps to colour the
path to indicate the angle (or plot text along the path to show it).

Duncan Murdoch


Thanks a lot.RegardsAlex

   On Tuesday, June 20, 2017 9:49 PM, Uwe Ligges

> wrote:



 package rgl.

Best,
Uwe Ligges


On 20.06.2017 21:29, Alaios via R-help wrote:

HelloI have three x,y,z vectors (lets say each is set as

rnorm(360)). So each one is having 360 elements each one correpsonding
to angular coordinates (1 degree, 2 degrees, 3 degrees, 360 degrees)
and I want to plot those on the xyz axes that have degress.

Is there a function or library to look at R cran? The ideal will be

that after plotting I will be able to rotate the shape.

I would like to thank you in advance for your helpRegardsAlex
   [[alternative HTML version deleted]]

__
R-help@r-project.org  mailing list -- To

UNSUBSCRIBE and more, see

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.








__
R-help@r-project.org  mailing list -- To

UNSUBSCRIBE and more, see

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.









[[alternative HTML version deleted]]

__
R-help@r-project.org  mailing list -- To
UNSUBSCRIBE and more, see
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.




__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see

Re: [R] 3D plot with coordinates

2017-06-22 Thread Alaios via R-help
Thanks. So after searching 4 hours last night it looks like that there is no R 
package that can do this right now. Any other ideas or suggestions might be 
helpful.RegardsAlex 

On Wednesday, June 21, 2017 3:21 PM, Alaios via R-help 
 wrote:
 

 Thanks Duncan for the replyI can not suppress anything these are radiation 
pattern measurements that are typically are taken at X,Y and Z planes. See an 
example here, where I want to plot the measurements for the red, green and blue 
planes (so the image below withouth the 3d green structure 
inside)https://www.researchgate.net/publication/258391165/figure/fig7/AS:322947316240401@1454008048835/Radiation-pattern-of-Archimedean-spiral-antenna-a-3D-and-b-elevation-cuts-at-phi.png
 

I am quite confident that there is a tool in R to help me do this 3D plot, and 
even better rotatable.
Thanks for the reply to allAlex 

    On Wednesday, June 21, 2017 1:07 PM, Duncan Murdoch 
 wrote:
 

 On 21/06/2017 5:23 AM, Alaios via R-help wrote:
> Thanks a lot for the reply.After  looking at different parts of the code 
> today I was able to start with simple 2D polar plots as the attached pdf 
> file.  In case the attachment is not visible I used the plot.polar function 
> to create something like 
> that.https://vijaybarve.files.wordpress.com/2013/04/polarplot-05.png
> Now the idea now will be to put three of those (for X,Y,Z) in a 3d rotatable 
> plane. I tried the rgl function but is not clear how I can use directly polar 
> coordinates to draw the points at the three different planes.
> Any ideas on that?

You can't easily do what you're trying to do.  You have 6 coordinates to 
display:  the 3 angles and values corresponding to each of them.  You 
need to suppress something.

If the values for matching angles correspond to each other (e.g. x=23 
degrees and y=23 degrees and z=23 degrees all correspond to the same 
observation), then I'd suggest suppressing the angles.  Just do a 
scatterplot of the 3 corresponding values.  It might make sense to join 
them (to make a path as the angles change), and perhaps to colour the 
path to indicate the angle (or plot text along the path to show it).

Duncan Murdoch

> Thanks a lot.RegardsAlex
>
>    On Tuesday, June 20, 2017 9:49 PM, Uwe Ligges 
> wrote:
>
>
>  package rgl.
>
> Best,
> Uwe Ligges
>
>
> On 20.06.2017 21:29, Alaios via R-help wrote:
>> HelloI have three x,y,z vectors (lets say each is set as  rnorm(360)). So 
>> each one is having 360 elements each one correpsonding to angular 
>> coordinates (1 degree, 2 degrees, 3 degrees, 360 degrees) and I want to 
>> plot those on the xyz axes that have degress.
>> Is there a function or library to look at R cran? The ideal will be that 
>> after plotting I will be able to rotate the shape.
>> I would like to thank you in advance for your helpRegardsAlex
>>    [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> 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.
>>
>
>
>
>
>
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
>



  
    [[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

   
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Re: [R] 3D plot with coordinates

2017-06-21 Thread Alaios via R-help
Thanks Duncan for the replyI can not suppress anything these are radiation 
pattern measurements that are typically are taken at X,Y and Z planes. See an 
example here, where I want to plot the measurements for the red, green and blue 
planes (so the image below withouth the 3d green structure 
inside)https://www.researchgate.net/publication/258391165/figure/fig7/AS:322947316240401@1454008048835/Radiation-pattern-of-Archimedean-spiral-antenna-a-3D-and-b-elevation-cuts-at-phi.png
 

I am quite confident that there is a tool in R to help me do this 3D plot, and 
even better rotatable.
Thanks for the reply to allAlex 

On Wednesday, June 21, 2017 1:07 PM, Duncan Murdoch 
 wrote:
 

 On 21/06/2017 5:23 AM, Alaios via R-help wrote:
> Thanks a lot for the reply.After  looking at different parts of the code 
> today I was able to start with simple 2D polar plots as the attached pdf 
> file.  In case the attachment is not visible I used the plot.polar function 
> to create something like 
> that.https://vijaybarve.files.wordpress.com/2013/04/polarplot-05.png
> Now the idea now will be to put three of those (for X,Y,Z) in a 3d rotatable 
> plane. I tried the rgl function but is not clear how I can use directly polar 
> coordinates to draw the points at the three different planes.
> Any ideas on that?

You can't easily do what you're trying to do.  You have 6 coordinates to 
display:  the 3 angles and values corresponding to each of them.  You 
need to suppress something.

If the values for matching angles correspond to each other (e.g. x=23 
degrees and y=23 degrees and z=23 degrees all correspond to the same 
observation), then I'd suggest suppressing the angles.  Just do a 
scatterplot of the 3 corresponding values.  It might make sense to join 
them (to make a path as the angles change), and perhaps to colour the 
path to indicate the angle (or plot text along the path to show it).

Duncan Murdoch

> Thanks a lot.RegardsAlex
>
>    On Tuesday, June 20, 2017 9:49 PM, Uwe Ligges 
> wrote:
>
>
>  package rgl.
>
> Best,
> Uwe Ligges
>
>
> On 20.06.2017 21:29, Alaios via R-help wrote:
>> HelloI have three x,y,z vectors (lets say each is set as  rnorm(360)). So 
>> each one is having 360 elements each one correpsonding to angular 
>> coordinates (1 degree, 2 degrees, 3 degrees, 360 degrees) and I want to 
>> plot those on the xyz axes that have degress.
>> Is there a function or library to look at R cran? The ideal will be that 
>> after plotting I will be able to rotate the shape.
>> I would like to thank you in advance for your helpRegardsAlex
>>    [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> 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.
>>
>
>
>
>
>
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
>



   
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Re: [R] 3D plot with coordinates

2017-06-21 Thread Duncan Murdoch

On 21/06/2017 5:23 AM, Alaios via R-help wrote:

Thanks a lot for the reply.After  looking at different parts of the code today 
I was able to start with simple 2D polar plots as the attached pdf file.  In 
case the attachment is not visible I used the plot.polar function to create 
something like 
that.https://vijaybarve.files.wordpress.com/2013/04/polarplot-05.png
Now the idea now will be to put three of those (for X,Y,Z) in a 3d rotatable 
plane. I tried the rgl function but is not clear how I can use directly polar 
coordinates to draw the points at the three different planes.
Any ideas on that?


You can't easily do what you're trying to do.  You have 6 coordinates to 
display:  the 3 angles and values corresponding to each of them.  You 
need to suppress something.


If the values for matching angles correspond to each other (e.g. x=23 
degrees and y=23 degrees and z=23 degrees all correspond to the same 
observation), then I'd suggest suppressing the angles.  Just do a 
scatterplot of the 3 corresponding values.  It might make sense to join 
them (to make a path as the angles change), and perhaps to colour the 
path to indicate the angle (or plot text along the path to show it).


Duncan Murdoch


Thanks a lot.RegardsAlex

On Tuesday, June 20, 2017 9:49 PM, Uwe Ligges 
 wrote:


 package rgl.

Best,
Uwe Ligges


On 20.06.2017 21:29, Alaios via R-help wrote:

HelloI have three x,y,z vectors (lets say each is set as  rnorm(360)). So each 
one is having 360 elements each one correpsonding to angular coordinates (1 
degree, 2 degrees, 3 degrees, 360 degrees) and I want to plot those on the 
xyz axes that have degress.
Is there a function or library to look at R cran? The ideal will be that after 
plotting I will be able to rotate the shape.
I would like to thank you in advance for your helpRegardsAlex
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.








__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.



__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] 3D plot with coordinates

2017-06-21 Thread Alaios via R-help
Thanks a lot for the reply.After  looking at different parts of the code today 
I was able to start with simple 2D polar plots as the attached pdf file.  In 
case the attachment is not visible I used the plot.polar function to create 
something like 
that.https://vijaybarve.files.wordpress.com/2013/04/polarplot-05.png
Now the idea now will be to put three of those (for X,Y,Z) in a 3d rotatable 
plane. I tried the rgl function but is not clear how I can use directly polar 
coordinates to draw the points at the three different planes. 
Any ideas on that?
Thanks a lot.RegardsAlex

On Tuesday, June 20, 2017 9:49 PM, Uwe Ligges 
 wrote:
 

 package rgl.

Best,
Uwe Ligges


On 20.06.2017 21:29, Alaios via R-help wrote:
> HelloI have three x,y,z vectors (lets say each is set as  rnorm(360)). So 
> each one is having 360 elements each one correpsonding to angular coordinates 
> (1 degree, 2 degrees, 3 degrees, 360 degrees) and I want to plot those on 
> the xyz axes that have degress.
> Is there a function or library to look at R cran? The ideal will be that 
> after plotting I will be able to rotate the shape.
> I would like to thank you in advance for your helpRegardsAlex
>     [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
> 


   

XNoSink.pdf
Description: Adobe PDF document
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Re: [R] 3D plot with coordinates

2017-06-20 Thread Uwe Ligges

package rgl.

Best,
Uwe Ligges


On 20.06.2017 21:29, Alaios via R-help wrote:

HelloI have three x,y,z vectors (lets say each is set as  rnorm(360)). So each 
one is having 360 elements each one correpsonding to angular coordinates (1 
degree, 2 degrees, 3 degrees, 360 degrees) and I want to plot those on the 
xyz axes that have degress.
Is there a function or library to look at R cran? The ideal will be that after 
plotting I will be able to rotate the shape.
I would like to thank you in advance for your helpRegardsAlex
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.



__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


[R] 3D plot with coordinates

2017-06-20 Thread Alaios via R-help
HelloI have three x,y,z vectors (lets say each is set as  rnorm(360)). So each 
one is having 360 elements each one correpsonding to angular coordinates (1 
degree, 2 degrees, 3 degrees, 360 degrees) and I want to plot those on the 
xyz axes that have degress.
Is there a function or library to look at R cran? The ideal will be that after 
plotting I will be able to rotate the shape.
I would like to thank you in advance for your helpRegardsAlex
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Re: [R] 3D Plot of Convex hull

2013-11-19 Thread David Winsemius

On Nov 18, 2013, at 8:01 PM, wwreith wrote:

 I have a data set in which I am trying to plot a convex hull in 3 dim. Below
 is a subset of the points I would use. Columns 2,3,4 are my x,y,z
 coordinates. I found some ways to plot 2D convext hulls or find a convex
 hull for higher dimensions, but not how to plot the data. 

Doing a simple search with: 3d convex hull r-project  I find the geometry 
package supports construction of multidimensional convex hulls and construction 
of tessalations. That package also suggsets the rgl package, which makes me 
think that 3d tessellations may be suitable for input to the rgl::surface3d 
function.

-- 
David.
 
 I have have attached an example of what I am shooting for in my plot. 
 
 Thanks for the help!
 
 6466574 37 225 27  53.69230 5
 6466575 38 225 27  47.54898 5
 6466576 39 225 27  58.71439 5
 6466577 40 225 27  67.40830 5
 6466578 41 225 27  64.40646 5
 6466579 42 225 27  71.59792 5
 6466580 43 225 27  66.10197 5
 6466581 44 225 27  61.53381 5
 6466582 45 225 27  69.49900 5
 6466583 46 225 27  93.91280 5
 6466800 31 226 27 102.78361 5
 6466801 32 226 27  69.58787 5
 6466802 33 226 27  67.53348 5
 6466803 34 226 27  66.83624 5
 6466804 35 226 27  52.74981 5
 6466805 36 226 27  58.10865 5
 6466806 37 226 27  64.29259 5
 6466807 38 226 27  55.37983 5
 6466808 39 226 27  58.48212 5
 6466809 40 226 27  66.21062 5
 6466810 41 226 27  58.39149 5
 6466811 42 226 27  60.40741 5
 6466812 43 226 27  60.95507 5
 6466813 44 226 27  64.16653 5
 6466814 45 226 27  62.48255 5
 6466815 46 226 27  74.37065 5
 6466816 47 226 27 100.51262 5 
 
 http://r.789695.n4.nabble.com/file/n4680712/turbo_ch3d_lung3.jpg 
 
 
 
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/3D-Plot-of-Convex-hull-tp4680712.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@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.

David Winsemius
Alameda, CA, USA

__
R-help@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.


[R] 3D Plot of Convex hull

2013-11-18 Thread wwreith
I have a data set in which I am trying to plot a convex hull in 3 dim. Below
is a subset of the points I would use. Columns 2,3,4 are my x,y,z
coordinates. I found some ways to plot 2D convext hulls or find a convex
hull for higher dimensions, but not how to plot the data. 

I have have attached an example of what I am shooting for in my plot. 

Thanks for the help!

6466574 37 225 27  53.69230 5
6466575 38 225 27  47.54898 5
6466576 39 225 27  58.71439 5
6466577 40 225 27  67.40830 5
6466578 41 225 27  64.40646 5
6466579 42 225 27  71.59792 5
6466580 43 225 27  66.10197 5
6466581 44 225 27  61.53381 5
6466582 45 225 27  69.49900 5
6466583 46 225 27  93.91280 5
6466800 31 226 27 102.78361 5
6466801 32 226 27  69.58787 5
6466802 33 226 27  67.53348 5
6466803 34 226 27  66.83624 5
6466804 35 226 27  52.74981 5
6466805 36 226 27  58.10865 5
6466806 37 226 27  64.29259 5
6466807 38 226 27  55.37983 5
6466808 39 226 27  58.48212 5
6466809 40 226 27  66.21062 5
6466810 41 226 27  58.39149 5
6466811 42 226 27  60.40741 5
6466812 43 226 27  60.95507 5
6466813 44 226 27  64.16653 5
6466814 45 226 27  62.48255 5
6466815 46 226 27  74.37065 5
6466816 47 226 27 100.51262 5 

http://r.789695.n4.nabble.com/file/n4680712/turbo_ch3d_lung3.jpg 



--
View this message in context: 
http://r.789695.n4.nabble.com/3D-Plot-of-Convex-hull-tp4680712.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.


[R] 3D plot

2013-05-14 Thread Amir

Dear all,

I need to plot more than one surface in 3D using R.
I tried with persp function, it produce only one surface.
Could you please help me how can I do it? The X and Y axis are the same 
but I have Z1 and Z2. I want to have both results in one graph.


Thanks
Amir


--
__
 Amir Darehshoorzadeh |  Computer Engineering Department
 PostDoc Fellow   |  University of Ottawa, Paradise LAb
 Email: adare...@uottawa.ca   |  800 King Edward Ave
 Tel: -   |  ON K1N 6N5, Ottawa - CANADA
 http://personals.ac.upc.edu/amir

__
R-help@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.


Re: [R] 3D plot

2013-05-14 Thread Duncan Murdoch

On 14/05/2013 1:10 PM, Amir wrote:

Dear all,

  I need to plot more than one surface in 3D using R.
I tried with persp function, it produce only one surface.
Could you please help me how can I do it? The X and Y axis are the same
but I have Z1 and Z2. I want to have both results in one graph.


That's quite hard to do with persp because it needs to plot the segments 
in a certain order.  You can do it in the rgl package using persp3d for 
the first surface, then persp3d( ..., add=TRUE) for the second.   Note 
that persp3d and persp use slightly different conventions for how to 
specify colours; see ?persp3d for details.


Duncan Murdoch

__
R-help@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.


[R] 3D plot RGL

2011-09-08 Thread francogrex
Hi, anyone has experience with 3D plot (ex: in package RGL) I have a
question, I draw a 3D plot of country, year and sales in z axis but when the
type is h then it's ok but when I want to link the points and type is 'l'
lines it's a mess Is there a way to link the points only in one direction?
For example a unique line from each country through each year?

The code example is below

library(rgl)
data=read.csv(c:/datout.csv, header=T)
Colors=as.vector(data[,1])
dat=as.vector(data[,2])
Year=as.vector(data[,3])
Country=as.vector(data[,4])
Sales=as.vector(data[,5])
Sales=as.matrix(Sales)

plot3d(Year, dat, Sales, type=h, axes=F, lwd=5, 
xlab=Year, ylab=Country, zlab=Sales, col=Colors, 
main=Typherix: Country/Year/Sales) ##replacing type=l makes a
connections all around, I want only one per country
axis3d(x, nticks=10, cex=0.7)
axis3d(z, nticks=5, cex=0.7, las=2)
axis3d(y, labels=Country, las=2, nticks=20, cex=0.5)

--
View this message in context: 
http://r.789695.n4.nabble.com/3D-plot-RGL-tp3798754p3798754.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.


Re: [R] 3D plot RGL

2011-09-08 Thread Jean V Adams
francogrex wrote on 09/08/2011 08:08:19 AM:
 
 Hi, anyone has experience with 3D plot (ex: in package RGL) I have a
 question, I draw a 3D plot of country, year and sales in z axis but when 
the
 type is h then it's ok but when I want to link the points and type is 
'l'
 lines it's a mess Is there a way to link the points only in one 
direction?
 For example a unique line from each country through each year?
 
 The code example is below
 
 library(rgl)
 data=read.csv(c:/datout.csv, header=T)


You will get more help from readers of this list if you supply example 
data such that anyone can run the code that you share.

Jean


 Colors=as.vector(data[,1])
 dat=as.vector(data[,2])
 Year=as.vector(data[,3])
 Country=as.vector(data[,4])
 Sales=as.vector(data[,5])
 Sales=as.matrix(Sales)
 
 plot3d(Year, dat, Sales, type=h, axes=F, lwd=5, 
 xlab=Year, ylab=Country, zlab=Sales, col=Colors, 
 main=Typherix: Country/Year/Sales) ##replacing type=l makes a
 connections all around, I want only one per country
 axis3d(x, nticks=10, cex=0.7)
 axis3d(z, nticks=5, cex=0.7, las=2)
 axis3d(y, labels=Country, las=2, nticks=20, cex=0.5)
[[alternative HTML version deleted]]

__
R-help@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.


[R] 3D plot with it's quadratic approximation superimposed in same plot

2011-05-23 Thread Megh Dal
Dear all, I would like to draw a 3D plot as shown 
here http://en.wikipedia.org/wiki/File:NaturalLogarithmAll.png, for this 
function f = exp[ 1 - x^2 - y^2] (this function is some arbitrary!). I am 
aware of different 3D plotting system in R, however it would be great if I can 
get that kind of soft look (this will help me to make a good-looking 
presentation.)

Additionally, I want to superimpose the Quadratic approximation (at some 
arbitrary point) of that function, on the top of the same plot. Can somebody 
help me to achieve that?

Thanks,

__
R-help@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.


Re: [R] 3D plot

2010-09-26 Thread Ben Bolker
jethi kartija at hotmail.com writes:

 hey,  is there anybody who can help me? its very urgent because i have to
 send my bachelor thesis on monday. pls help me

  I'm really sorry that you're stuck, but ... waiting until a few days
before an important assignment is due and then depending on the generosity
of unpaid volunteers is a dangerous procedure ...

  I tried to run your code but got an error (object 'p' not found);
it's very hard to understand what the code is doing, there are lots
of things that look funny/wrong ... in particular, you should look at
the gute() function and think about what it's doing.  Be aware that
functions in R do not work like 'macros', that is, information about
variables that are defined or modified within functions does not 
propagate outside the functions.

  If you post a function that actually works, you are more likely to
get help drawing the graph.

  If your results are in the form of a matrix, persp() is probably
the easiest way to draw the surface. wireframe (in the lattice package)
is an alternative.

__
R-help@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.


[R] 3D plot

2010-09-25 Thread jethi

hey, how can i plot this function??? thanks for ur help

n=1000
m=2
k=n/m
N=100
myfun - function(n, m, alpha = .05, seeder = 1000) {
l=matrix(0,nrow=m,ncol=N)
for(i in 1:N){
set.seed(i)
for(j in 1:m){
x=rnorm(n,0,0.5)
y=rnorm(n,0,0.8)
l[j,i]=cor((x[(((j-1)*k)+1):(((j-1)*k)+k)]),
(y[(((j-1)*k)+1):(((j-1)*k)+k)]))
}
}

for(i in 1:N){
for (j in 1:m){
gute - function() {
q_1 - qnorm(alpha, 0, 0.05)
 
q_2 - qnorm(1 - alpha, 0, 0.05)
 
p=matrix(0,nrow=m,ncol=N)
H=matrix(0,nrow=N,ncol=1)

p[j,i]=x[j]^2/sum(x[,i]^2)
}
H[i]=log(m)-sum(p[,i]*log(p[,i]))
}
   1 - mean(q_1 = H  H = q_2)
}
output - gute(a = l[,i])
 return(output)
}

regards 
jethi
-- 
View this message in context: 
http://r.789695.n4.nabble.com/3D-plot-tp2713818p2713818.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.


Re: [R] 3D plot

2010-09-25 Thread Steve Lianoglou
Hi Jethi,

On Sat, Sep 25, 2010 at 3:42 PM, jethi kart...@hotmail.com wrote:

 hey, how can i plot this function??? thanks for ur help

I don't really have the time (or inclination, sorry) to look through
your code, but if it relates to your subject line, then there are
several ways to plot 3d objects in R.

You can look at the scatterplot3d package, or more interestingly (I
think) the rgl package, and its plot3d, lines3d, etc. functions.

-steve


 n=1000
 m=2
 k=n/m
 N=100
 myfun - function(n, m, alpha = .05, seeder = 1000) {
 l=matrix(0,nrow=m,ncol=N)
 for(i in 1:N){
 set.seed(i)
 for(j in 1:m){
 x=rnorm(n,0,0.5)
 y=rnorm(n,0,0.8)
 l[j,i]=cor((x[(((j-1)*k)+1):(((j-1)*k)+k)]),
 (y[(((j-1)*k)+1):(((j-1)*k)+k)]))
 }
 }

 for(i in 1:N){
 for (j in 1:m){
 gute - function() {
    q_1 - qnorm(alpha, 0, 0.05)

    q_2 - qnorm(1 - alpha, 0, 0.05)

 p=matrix(0,nrow=m,ncol=N)
 H=matrix(0,nrow=N,ncol=1)

 p[j,i]=x[j]^2/sum(x[,i]^2)
 }
 H[i]=log(m)-sum(p[,i]*log(p[,i]))
 }
   1 - mean(q_1 = H  H = q_2)
 }
 output - gute(a = l[,i])
  return(output)
 }

 regards
 jethi
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/3D-plot-tp2713818p2713818.html
 Sent from the R help mailing list archive at Nabble.com.

 __
 R-help@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.




-- 
Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact

__
R-help@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.


Re: [R] 3D plot

2010-09-25 Thread jethi

hi steve, thnx for ur reply. but my problem is, that i have a matrix as a
functions value and as a result i get a single number. so  how can i plot
this? and it would be nice if u read over my function, because i´m not sure
if it correct. anyway thnx
regards 
jethi
-- 
View this message in context: 
http://r.789695.n4.nabble.com/3D-plot-tp2713818p2713856.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.


Re: [R] 3D plot

2010-09-25 Thread jethi

hey,  is there anybody who can help me? its very urgent because i have to
send my bachelor thesis on monday. pls help me
-- 
View this message in context: 
http://r.789695.n4.nabble.com/3D-plot-tp2713818p2713909.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.


[R] 3d plot layout?

2010-09-08 Thread Martin Ivanov
 Hello!

I would like to ask if R can solve the following problem. 
I need to produce two 3d plots on a single page, that is
to arrange them one above the other. Also, I need to
 visualize points by means of spheres, pyramids and cubes
in the 3d space. Also, I would like to fill these symbols
with colours. Is this possible to be done with R?

In the two dimensional case the R plots are of excellent quality,
I use the layout function to arrange the plots and the symbols
from 20 to 25 that can be filled. So my question is can I produce
an analogous 3d plot with R?

Thank you in advance.

Regards, Martin

__
R-help@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.


Re: [R] 3D Plot

2010-04-24 Thread Jim Lemon

On 04/23/2010 10:51 PM, Ariane C. Böhm wrote:

Hi guys of the R-Help-Team!br /br /First of all - you do a great job!br
/I've found a lot of your mails in the internet. So I thought it would be a
good idea to ask you a question about R.br /br /R is new to me, so sorry,
if the question is too simple :)br /br /I have a matrix.br /I can make a
2D Heatmap of this matrix.br /br /My question:br /Can I also make a 3D
Heatmap of this matrix - so the third parameter should the value in the
matrix.br /br /My first thought was :br /gt; matlt;- read.table(file
=quot;AvgMatrix.matquot;)br /gt; xlt;-as.matrix(mat)br /gt; hv
lt;- heatmap.2 (x, col=topo.colors, Colv = NA, Rowv = NA,
main=quot;AvgMatrixquot;, xlab=quot;Columnsquot;, ylab=quot;Rowsquot;,
key=TRUE, trace =quot;nonequot;)br /But that is just a 2D heatmap.br
/br /Thanks for your helpbr /br /Arianebr /br /


Hi Ariane,
The color2D.matplot function can almost do this, as there is an option 
to display the numeric values within the cells. Now with the small 
kludge of adding an extra argument:


x3=NULL

and changing the following lines:

   if(show.values)
text(sort(rep((1:xdim[2])-0.5,xdim[1])),
 rep(seq(xdim[1]-0.5,0,by=-1),xdim[2]),
 round(x,show.values),col=vcol,cex=vcex)
  }

to this:

   if(show.values)
if(is.null(x3)) xval-x
else xval-x3
text(sort(rep((1:xdim[2])-0.5,xdim[1])),
 rep(seq(xdim[1]-0.5,0,by=-1),xdim[2]),
 round(xval,show.values),col=vcol,cex=vcex)
  }

You may have a solution to your plotting problem.

Of course this will do nothing at all for your problem of sending HTML 
formatted messages.


Jim

__
R-help@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.


[R] 3D Plot

2010-04-23 Thread Ariane C. Böhm
Hi guys of the R-Help-Team!br /br /First of all - you do a great job!br
/I've found a lot of your mails in the internet. So I thought it would be a
good idea to ask you a question about R.br /br /R is new to me, so sorry,
if the question is too simple :)br /br /I have a matrix.br /I can make a
2D Heatmap of this matrix.br /br /My question:br /Can I also make a 3D
Heatmap of this matrix - so the third parameter should the value in the
matrix.br /br /My first thought was :br /gt; mat lt;- read.table(file
= quot;AvgMatrix.matquot;)br /gt; x lt;-as.matrix(mat)br /gt; hv
lt;- heatmap.2 (x, col=topo.colors, Colv = NA, Rowv = NA,
main=quot;AvgMatrixquot;, xlab=quot;Columnsquot;, ylab=quot;Rowsquot;,
key=TRUE, trace = quot;nonequot;)br /But that is just a 2D heatmap.br
/br /Thanks for your helpbr /br /Arianebr /br /

__
R-help@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.


Re: [R] 3D Plot

2010-04-23 Thread Duncan Murdoch

On 23/04/2010 8:51 AM, Ariane C. Böhm wrote:

Hi guys of the R-Help-Team!br /br /First of all - you do a great job!br
/I've found a lot of your mails in the internet. So I thought it would be a
good idea to ask you a question about R.br /br /R is new to me, so sorry,
if the question is too simple :)br /br /I have a matrix.br /I can make a
2D Heatmap of this matrix.br /br /My question:br /Can I also make a 3D
Heatmap of this matrix - so the third parameter should the value in the
matrix.br /br /My first thought was :br /gt; mat lt;- read.table(file
= quot;AvgMatrix.matquot;)br /gt; x lt;-as.matrix(mat)br /gt; hv
lt;- heatmap.2 (x, col=topo.colors, Colv = NA, Rowv = NA,
main=quot;AvgMatrixquot;, xlab=quot;Columnsquot;, ylab=quot;Rowsquot;,
key=TRUE, trace = quot;nonequot;)br /But that is just a 2D heatmap.br
/br /Thanks for your helpbr /br /Arianebr /br /
  


If you can, please turn off the HTML formatting in your email:  it makes 
it quite hard to read.


I don't really know what you mean by a 3D heatmap:  can you point to any 
examples of such figures online?  You might be thinking of something 
like persp gives; try example(persp) (or example(persp3d) in the rgl 
package).


Duncan Murdoch

__
R-help@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.



__
R-help@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.


Re: [R] 3D plot

2010-02-21 Thread Duncan Murdoch

On 18/02/2010 11:43 AM, David A.G wrote:

Dearl list,

can anyone point me to a function or library that can create a graph similar to 
the one in the following powerpoint presentation?


It could be done in rgl with a lot of work.  I don't know of a package 
where someone has already done the work.


rgl can plot triangles and quadrilaterals in 3d, but not general 
polygons.  So you'd need to decompose each chromosome sequence into a 
sequence of simpler shapes.  For example,


n - 100
f - rnorm(n, mean=10, sd=1)
g - rnorm(n, mean=10, sd=1)
x - 1:n
fn - colorRamp(c(blue,white,red))
color - function(value) {
  vals - fn(value)
  rgb(vals[,1], vals[,2], vals[,3], max=255)
}

m - max(f,g)

quadx - cbind( x[-n], x[-1], x[-1], x[-n] )
quadh - cbind( 0, 0, f[-1], f[-n] )
quadcol - cbind( color(0), color(0), color(f[-1]/m), color(f[-n]/m))


quads3d( as.numeric(t(quadx)), 10, as.numeric(t(quadh)), 
col=as.character(t(quadcol)))

quadh - cbind( 0, 0, g[-1], g[-n] )
quadcol - cbind( color(0), color(0), color(g[-1]/m), color(g[-n]/m))
quads3d( as.numeric(t(quadx)), 20, as.numeric(t(quadh)), 
col=as.character(t(quadcol)))


This doesn't get the colours the way the presentation had them, that 
would be a bit more work.


Duncan Murdoch



http://bmi.osu.edu/~khuang/IBGP705/BMI705-Lecture7.ppt

(pages 36-37)

In order to try to explain the graph, the way I see it in R terms is something 
like this:

the p-q axis is a vector of positions (for example, seq(0,500,1))
the Chr1-Chrx is a vector of units, in this case chromosomes (so something 
like seq(1,10,1))
the plotted data is observations for each unit at each position

I guess the fancy gradient on the highest peaks is tougher to get (knowing I am 
not an R expert), but just plain blue would suffice.

I have checked some of the graphs in the R graph gallery but I don´t think any 
of them would work

Thanks in advance,

Dave
 		 	   		  
_

Hotmail: Trusted email with powerful SPAM protection.

[[alternative HTML version deleted]]





__
R-help@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.


__
R-help@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.


Re: [R] 3D plot

2010-02-19 Thread Jim Lemon

On 02/19/2010 03:43 AM, David A.G wrote:


Dearl list,

can anyone point me to a function or library that can create a graph similar to 
the one in the following powerpoint presentation?

http://bmi.osu.edu/~khuang/IBGP705/BMI705-Lecture7.ppt

(pages 36-37)

In order to try to explain the graph, the way I see it in R terms is something 
like this:

the p-q axis is a vector of positions (for example, seq(0,500,1))
the Chr1-Chrx is a vector of units, in this case chromosomes (so something 
like seq(1,10,1))
the plotted data is observations for each unit at each position

I guess the fancy gradient on the highest peaks is tougher to get (knowing I am 
not an R expert), but just plain blue would suffice.

I have checked some of the graphs in the R graph gallery but I don´t think any 
of them would work


Hi Dave,
This is a sort of 2.5D plot, with each chromosome being a 2D plot spaced 
out on the z axis. If we assume that it is a static viewpoint, it would 
be a case of drawing the parallelogram base, then overlaying a 
sequence of polygons with the appropriate offset to give the 3D 
appearance. My eyeball says that there is no perspective correction.


Doable, but I would advise asking on the Bioconductor mailing list first.

Jim

__
R-help@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.


[R] 3D plot

2010-02-18 Thread David A.G

Dearl list,

can anyone point me to a function or library that can create a graph similar to 
the one in the following powerpoint presentation?

http://bmi.osu.edu/~khuang/IBGP705/BMI705-Lecture7.ppt

(pages 36-37)

In order to try to explain the graph, the way I see it in R terms is something 
like this:

the p-q axis is a vector of positions (for example, seq(0,500,1))
the Chr1-Chrx is a vector of units, in this case chromosomes (so something 
like seq(1,10,1))
the plotted data is observations for each unit at each position

I guess the fancy gradient on the highest peaks is tougher to get (knowing I am 
not an R expert), but just plain blue would suffice.

I have checked some of the graphs in the R graph gallery but I don´t think any 
of them would work

Thanks in advance,

Dave
  
_
Hotmail: Trusted email with powerful SPAM protection.

[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] 3D plot of following data

2010-02-07 Thread Paul Murrell

Hi


Jim Lemon wrote:

On 02/02/2010 11:01 PM, walter.dju...@chello.at wrote:

Hello R-experts,

I am having difficulties with 3D plotting (i.e. the evolution of
various forward curves through time).

I have two comma seperated files both ordered by date (in the first
column) one containing contracts (meaning forward delivery months
from YEAR_  Letter F ... January through letter Z ...
December) and the other holding the closing price of the respective
contract on the day also defined in the first column (see
attachments).

What I would like to do is plot a three dimensional figure with
trade day (date) on the X-axis, contract on the Y-axis and the
price of the forward contract being the z-value. I am quite a
newbie and did not manage to merge these two files in a logic way,
so that R could do a 3D plot.


Has anyone tried to program Hans Rosling's time evolution graphs in
R?



Take a look at 
http://www.omegahat.org/SVGAnnotation/JSSPaper.html#fig:gapMSS


Paul



Jim

__ R-help@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.


--
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
p...@stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/

__
R-help@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.


Re: [R] 3D plot of following data

2010-02-03 Thread Jim Lemon

On 02/02/2010 11:01 PM, walter.dju...@chello.at wrote:

Hello R-experts,

I am having difficulties with 3D plotting (i.e. the evolution of various 
forward curves through time).

I have two comma seperated files both ordered by date (in the first column) one containing contracts 
(meaning forward delivery months from YEAR_  Letter F ... January through letter 
Z ... December) and the other holding the closing price of the respective contract on the 
day also defined in the first column (see attachments).

What I would like to do is plot a three dimensional figure with trade day 
(date) on the X-axis, contract on the Y-axis and the price of the forward 
contract being the z-value.
I am quite a newbie and did not manage to merge these two files in a logic way, 
so that R could do a 3D plot.


Has anyone tried to program Hans Rosling's time evolution graphs in R?

Jim

__
R-help@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.


[R] 3D plot of following data

2010-02-02 Thread walter.djuric
Hello R-experts, 

I am having difficulties with 3D plotting (i.e. the evolution of various 
forward curves through time). 

I have two comma seperated files both ordered by date (in the first column) one 
containing contracts (meaning forward delivery months from YEAR_  Letter F 
... January through letter Z ... December) and the other holding the closing 
price of the respective contract on the day also defined in the first column 
(see attachments). 

What I would like to do is plot a three dimensional figure with trade day 
(date) on the X-axis, contract on the Y-axis and the price of the forward 
contract being the z-value. 
I am quite a newbie and did not manage to merge these two files in a logic way, 
so that R could do a 3D plot. 

Any help would be appreciated. 
--
WD__
R-help@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.


Re: [R] 3D plot of following data

2010-02-02 Thread Uwe Ligges
Since your files did not come through the mail list, I'd suggest to put 
them on some webside and provide a link.


Uwe Ligges



On 02.02.2010 13:01, walter.dju...@chello.at wrote:

Hello R-experts,

I am having difficulties with 3D plotting (i.e. the evolution of various 
forward curves through time).

I have two comma seperated files both ordered by date (in the first column) one containing contracts 
(meaning forward delivery months from YEAR_  Letter F ... January through letter 
Z ... December) and the other holding the closing price of the respective contract on the 
day also defined in the first column (see attachments).

What I would like to do is plot a three dimensional figure with trade day 
(date) on the X-axis, contract on the Y-axis and the price of the forward 
contract being the z-value.
I am quite a newbie and did not manage to merge these two files in a logic way, 
so that R could do a 3D plot.

Any help would be appreciated.
--
WD



__
R-help@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.


__
R-help@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.


Re: [R] 3D plot of following data

2010-02-02 Thread Uwe Ligges



On 02.02.2010 16:01, walter.dju...@chello.at wrote:

Here they are for now for you.
And I will put them somewhere in a few minutes and poost the link.



No need to do so. If you really want to use 3D plots (which I doubt you 
really want since you could do better in 2D using dotcharts or so):


setwd('d:/')
#READ IN Contracts
NG.contracts - read.csv('NG_contracts.csv', header=FALSE, sep=;, 
na.string=)

NG.contracts$V1 - as.Date(NG.contracts$V1,format='%d.%m.%Y')
#READ IN Values
NG.values - read.csv('NG_values.csv', header=FALSE, sep=;, na.string=?)
NG.values$V1 - as.Date(NG.values$V1, format='%d.%m.%Y')



## new stuff by UL:

NG.valuesl - reshape(NG.values, direction=long, varying=list(2:32), 
idvar=V1)
NG.contractsl - reshape(NG.contracts, direction=long, 
varying=list(2:32), idvar=V1)

NG - NG.valuesl[,c(V1,V2)]
colnames(NG) - c(Date, value)
rownames(NG) - NULL
NG$contract - NG.contractsl[,V2]


## two ways, one for nice viewing, one for easier printout:

library(rgl)
plot3d(NG$Date, NG$contract, NG$value)

library(scatterplot3d)
scatterplot3d(NG$Date, NG$contract, NG$value, pch=20)

Now you need to prettify exes etc.


Uwe Ligges






Greetings,
Walter

 Uwe Liggeslig...@statistik.tu-dortmund.de  schrieb:

Since your files did not come through the mail list, I'd suggest to put
them on some webside and provide a link.

Uwe Ligges



On 02.02.2010 13:01, walter.dju...@chello.at wrote:

Hello R-experts,

I am having difficulties with 3D plotting (i.e. the evolution of various 
forward curves through time).

I have two comma seperated files both ordered by date (in the first column) one containing contracts 
(meaning forward delivery months from YEAR_   Letter F ... January through letter 
Z ... December) and the other holding the closing price of the respective contract on the 
day also defined in the first column (see attachments).

What I would like to do is plot a three dimensional figure with trade day 
(date) on the X-axis, contract on the Y-axis and the price of the forward 
contract being the z-value.
I am quite a newbie and did not manage to merge these two files in a logic way, 
so that R could do a 3D plot.

Any help would be appreciated.
--
WD



__
R-help@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.


--
mfg
WD


__
R-help@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.


Re: [R] 3D plot of following data

2010-02-02 Thread walter.djuric
a link to the 3D plot data files 

http://members.chello.at/gwd

the files are NG_contracts and NG_values

--
mfg
WD

__
R-help@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.


[R] 3D plot, rotatable and with adjustable symbols

2009-11-19 Thread Joel Fürstenberg-Hägg

Hi all,

 

I've tried to make a 3D plot, but have run into some problems.

 

I'd like to have a plot that I can rotate interactively using the mouse, which 
is possible using the plots3d {R.basic}. However, I would like to change the 
symbols used as the points, but there's no pch in plot3d().

 

If I use the Scatterplot3d package, I'm able to change this, but not able to 
rotate the plot interactively.

 

Does anyone know a solution to this? Maybe another package is better?

 

Best regards,

 

Joel
  
_
Nya Windows 7 gör allt lite enklare. Hitta en dator som passar dig!
http://windows.microsoft.com/shop
[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] 3D plot, rotatable and with adjustable symbols

2009-11-19 Thread Remko Duursma
Try the rgl package.


r


-
Remko Duursma
Post-Doctoral Fellow

Centre for Plants and the Environment
University of Western Sydney
Hawkesbury Campus
Richmond NSW 2753

Dept of Biological Science
Macquarie University
North Ryde NSW 2109
Australia

Mobile: +61 (0)422 096908
www.remkoduursma.com



2009/11/19 Joel Fürstenberg-Hägg joel_furstenberg_h...@hotmail.com:

 Hi all,



 I've tried to make a 3D plot, but have run into some problems.



 I'd like to have a plot that I can rotate interactively using the mouse, 
 which is possible using the plots3d {R.basic}. However, I would like to 
 change the symbols used as the points, but there's no pch in plot3d().



 If I use the Scatterplot3d package, I'm able to change this, but not able to 
 rotate the plot interactively.



 Does anyone know a solution to this? Maybe another package is better?



 Best regards,



 Joel

 _
 Nya Windows 7 gör allt lite enklare. Hitta en dator som passar dig!
 http://windows.microsoft.com/shop
        [[alternative HTML version deleted]]


 __
 R-help@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.



__
R-help@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.


Re: [R] 3D plot, rotatable and with adjustable symbols

2009-11-19 Thread Greg Snow
Look at the ggobi program and the rggobi package for interactions between R and 
ggobi.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of Joel Fürstenberg-Hägg
 Sent: Thursday, November 19, 2009 2:27 AM
 To: r-help@r-project.org
 Subject: [R] 3D plot, rotatable and with adjustable symbols
 
 
 Hi all,
 
 
 
 I've tried to make a 3D plot, but have run into some problems.
 
 
 
 I'd like to have a plot that I can rotate interactively using the
 mouse, which is possible using the plots3d {R.basic}. However, I would
 like to change the symbols used as the points, but there's no pch in
 plot3d().
 
 
 
 If I use the Scatterplot3d package, I'm able to change this, but not
 able to rotate the plot interactively.
 
 
 
 Does anyone know a solution to this? Maybe another package is better?
 
 
 
 Best regards,
 
 
 
 Joel
 
 _
 Nya Windows 7 gör allt lite enklare. Hitta en dator som passar dig!
 http://windows.microsoft.com/shop
   [[alternative HTML version deleted]]

__
R-help@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.


[R] 3D PLOT

2009-03-27 Thread bastian2507hk
Hello,

I would like to create a 3D plot with the following data formats:

a - 1:100

b - 1:100

c - matrix(, 100, 100)

i.e.

c(i,j) = f ( a(i) , b(j) )

each of the 1 elements i,j in matrix c is a function of a(i) and
b(j). I would like to have a,b on the x and z axis and c on the y-axis. 

Does anybody have an idea how to accomplish that? Thanks in advance.

Regards

BO






#adBox3 {display:none;}



__
R-help@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.


Re: [R] 3D PLOT

2009-03-27 Thread Duncan Murdoch

On 3/27/2009 9:57 AM, bastian250...@freenet.de wrote:

Hello,

I would like to create a 3D plot with the following data formats:

a - 1:100

b - 1:100

c - matrix(, 100, 100)

i.e.

c(i,j) = f ( a(i) , b(j) )

each of the 1 elements i,j in matrix c is a function of a(i) and
b(j). I would like to have a,b on the x and z axis and c on the y-axis. 


Does anybody have an idea how to accomplish that? Thanks in advance.



persp, contour, image, wireframe, contourplot, etc. (in graphics and 
lattice); persp3d (in rgl).


Duncan Murdoch

__
R-help@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.


[R] 3d plot

2008-03-31 Thread kate
Hi,
I would like to have 3d plot, and I found that there is a command 
scatterplot3d. x is V, y=sigmaV, and z=TSE (note: After some calculation, I 
update TSE). How could I do to have 3d plot I want? 

V-seq(1279,1280,,100)
sigmaV-seq(0.28,0.29,,100)
TSE-matrix(0, length(V),length(sigmaV))

ps: TSE[i,j] corresponds to V[i] and sigmaV[j].

Thanks,

Kate 
[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] 3d plot

2008-03-31 Thread Uwe Ligges
If you want to plot some surface, use persp(); or wireframe() from 
package lattice; or persp3d() from package rgl or therelike.

Uwe Ligges

kate wrote:
 Hi,
 I would like to have 3d plot, and I found that there is a command 
 scatterplot3d. x is V, y=sigmaV, and z=TSE (note: After some calculation, I 
 update TSE). How could I do to have 3d plot I want? 
 
 V-seq(1279,1280,,100)
 sigmaV-seq(0.28,0.29,,100)
 TSE-matrix(0, length(V),length(sigmaV))
 
 ps: TSE[i,j] corresponds to V[i] and sigmaV[j].
 
 Thanks,
 
 Kate 
   [[alternative HTML version deleted]]
 
 __
 R-help@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.

__
R-help@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.


[R] 3d plot with dates on axis

2007-09-24 Thread Li, Yan (IED)
Hi all,

I'd like to make a 3D plot with dates on one of the axes. For example,

date1 - as.Date(2007-01-25) + seq(10)
y - seq(10)
z - seq(10)

I want to plot date1 on one axis, y on the other, and z as the height,
with the points connected.

Any help would be highly appreciated!

Yan


This is not an offer (or solicitation of an offer) to buy/se...{{dropped}}

__
R-help@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.


Re: [R] 3d plot with dates on axis

2007-09-24 Thread Duncan Murdoch
On 9/24/2007 10:48 AM, Li, Yan (IED) wrote:
 Hi all,
 
 I'd like to make a 3D plot with dates on one of the axes. For example,
 
 date1 - as.Date(2007-01-25) + seq(10)
 y - seq(10)
 z - seq(10)
 
 I want to plot date1 on one axis, y on the other, and z as the height,
 with the points connected.
 
 Any help would be highly appreciated!

library(rgl)
plot3d(date1,y,z, type='l',axes=F)
xlabs - date1[c(2,5,8)] # or some other way to get pretty dates
axes3d(xat=xlabs, xlab=as.character(xlabs))

Duncan Murdoch

__
R-help@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.