Re: [R] 3D surface plot
On 30/04/2016 1:48 PM, T.Riedle wrote: Dear R users, I am trying to generate a 3D surface plot given the inflator formula in the attached file. Now, I want to create a 3D plot showing how Delta changes with the values of Abs(B) and sigma. The other variables in the formula are constant. Delta is calculated daily therefore the subscript t which denotes the day. I have used different functions and different packages but I get either wrong results or an error in R. Does anyone have an idea which function I should use? One way is to create a function of two arguments, e.g. f <- function(x, y) x^2 + y^2 This function needs to be "vectorized", i.e. if x and y are vectors, it needs to pair the values and produce a vector as an answer. Then library(rgl) persp3d(f) will do a perspective plot of it. There are a lot of optional arguments to set the range of x, y, labels, colours, etc. Duncan Murdoch Furthermore, I think I have to create a matrix using the formula above but I do not know how to do that in this connection. Can any body help me with the code for this purpose? Thanks a lot in advance. __ 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 surface plot
There are several packages and functions that can do this (e.g. search on "3d surface plots" at rseek.org or internet search engine). You are much more likely to get a helpful answer if you provide a minimal data set (e.g. via dput() ) and code from any function(s) and package(s) that you tried. A pdf with a formula in it is not very r-helper friendly. Cheers, Bert 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 Sat, Apr 30, 2016 at 10:48 AM, T.Riedlewrote: > Dear R users, > > I am trying to generate a 3D surface plot given the inflator formula in the > attached file. > > Now, I want to create a 3D plot showing how Delta changes with the values of > Abs(B) and sigma. The other variables in the formula are constant. Delta is > calculated daily therefore the subscript t which denotes the day. I have used > different functions and different packages but I get either wrong results or > an error in R. > > Does anyone have an idea which function I should use? > > Furthermore, I think I have to create a matrix using the formula above but I > do not know how to do that in this connection. Can any body help me with the > code for this purpose? > > Thanks a lot in advance. > > > __ > 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 surface plot
Dear R users, I am trying to generate a 3D surface plot given the inflator formula in the attached file. Now, I want to create a 3D plot showing how Delta changes with the values of Abs(B) and sigma. The other variables in the formula are constant. Delta is calculated daily therefore the subscript t which denotes the day. I have used different functions and different packages but I get either wrong results or an error in R. Does anyone have an idea which function I should use? Furthermore, I think I have to create a matrix using the formula above but I do not know how to do that in this connection. Can any body help me with the code for this purpose? Thanks a lot in advance. buvar_countercyclical_capital_buffer_17_1419139702[1].pdf Description: buvar_countercyclical_capital_buffer_17_1419139702[1].pdf __ 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 Surface Plot
Check out the wireframe() function in the R package lattice ... library(lattice) ?wireframe Jean On Wed, Dec 18, 2013 at 9:30 AM, Simon Delay-Fortier simon.delay-fort...@mail.mcgill.ca wrote: Hi everyone,I am a very new user of r. I am now mandated to draw a 3-d surface (and possibly rotating) of a mine pit hole. I have all the location points (around 5000 points) of the pit in a CSV file under 3 column X, Y Z. The fllowing gives a 3d scatter but i would like to have a surface. attach(EASTPITCREST) par(bg=grey6, col.lab=white, col.axis=white, col.main=white, col.sub=white) scatterplot3d(X, Y, Z, color = red, pch=19, main=Mine and Drilling Map) I noted is that most of the time X and Y have to be in ascending order but the data I have are not (since they are finite points of the pit, if X gets in ascending order, Y and Z are not). Also with the data, sometimes 2 rows fallowing each ohter have the same X and Y value with a different Z. Hope you can help. Sincerly, Simon Delay-Fortier __ 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. [[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 Surface plot
Hi everyone, I am a very new user of r (doing most of my previous stuff in vba). I am now mandated to draw a 3-d surface of a mine pit hole. I have all the location points (around 5000 points) of the pit in a CSV file under 3 column X, Y Z. However, going from page to page on the web, I could not figure out how to code the figure. Something I noted is that most of the time X and Y have to be in ascending order but the data I have are not (since they are finite points of the pit, if X gets in ascending order, Y and Z are not). Also with the data, sometimes 2 rows fallowing each ohter have the same X and Y value with a different Z. That would be nice if things could be modeled with rgl function in order to have a rotating pit, but I would be glad to only have a 3d surface to start! Hope you can help. Sincerly, Simon Delay-Fortier __ 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 Surface Plot
Hi everyone,I am a very new user of r. I am now mandated to draw a 3-d surface (and possibly rotating) of a mine pit hole. I have all the location points (around 5000 points) of the pit in a CSV file under 3 column X, Y Z. The fllowing gives a 3d scatter but i would like to have a surface. attach(EASTPITCREST) par(bg=grey6, col.lab=white, col.axis=white, col.main=white, col.sub=white) scatterplot3d(X, Y, Z, color = red, pch=19, main=Mine and Drilling Map) I noted is that most of the time X and Y have to be in ascending order but the data I have are not (since they are finite points of the pit, if X gets in ascending order, Y and Z are not). Also with the data, sometimes 2 rows fallowing each ohter have the same X and Y value with a different Z. Hope you can help. Sincerly, Simon Delay-Fortier __ 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 Surface plot
On Wed, Dec 18, 2013 at 2:52 PM, Simon Delay-Fortier simon.delay-fort...@mail.mcgill.ca wrote: Hi everyone, I am a very new user of r (doing most of my previous stuff in vba). I am now mandated to draw a 3-d surface of a mine pit hole. I have all the location points (around 5000 points) of the pit in a CSV file under 3 column X, Y Z. However, going from page to page on the web, I could not figure out how to code the figure. Something I noted is that most of the time X and Y have to be in ascending order but the data I have are not (since they are finite points of the pit, if X gets in ascending order, Y and Z are not). Also with the data, sometimes 2 rows fallowing each ohter have the same X and Y value with a different Z. That would be nice if things could be modeled with rgl function in order to have a rotating pit, but I would be glad to only have a 3d surface to start! How 3d is your surface here? Because there's 3d and there's what's known as 2.5d A 3d surface could be something like the surface of a sphere, or a cave, or an overhanging cliff, whereas a 2.5d surface is a single-valued function of x and y. If you have a true 3d surface then that's beyond me and involves working out surface normals and all sorts of other clever stuff which I don't know about. If its really 2.5d then yes, you do need to compute the values of your surface on a grid in order to display it using rgl's surface3d function. You can do this with some 2d interpolation code, such as kriging or inverse distance weighting, using assorted packages such as automap (which makes it easy but beware) or gstat. Since this seems to be a real-world geography problem, you might haul over to the r-sig-geo mailing list and as there where the spatial guys hang out. Barry __ 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 surface plot (ideally using rgl package)?
It is by no means clear what the peaks function does or if it has any R equivalent, but perhaps looking at demo(rgl) will get you started. After that, you should probably show what you've tried (at least as far as replicating the calculation aspects). Michael On Fri, Mar 2, 2012 at 1:32 AM, e-mail athula.herath athula.her...@ntlworld.com wrote: Dear HelpeRs, I would be grateful for anybody who might help to produce the following plot (the code for matlab is below) using the rgl package of R? [t,r] = meshgrid(linspace(0,2*pi,361),linspace(-4,4,101)); [x,y] = pol2cart(t,r); P = peaks(x,y); figure('color','white'); polarplot3d(P,'colordata',gradient(P)); view([-18 72]); You may see the code and plot output at: https://plus.google.com/u/0/109789409461372488563/posts/YfcrsMhkjyf Many Thanks A. [[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 surface plot (ideally using rgl package)?
Dear HelpeRs, I would be grateful for anybody who might help to produce the following plot (the code for matlab is below) using the rgl package of R? [t,r] = meshgrid(linspace(0,2*pi,361),linspace(-4,4,101)); [x,y] = pol2cart(t,r); P = peaks(x,y); figure('color','white'); polarplot3d(P,'colordata',gradient(P)); view([-18 72]); You may see the code and plot output at: https://plus.google.com/u/0/109789409461372488563/posts/YfcrsMhkjyf Many Thanks A. [[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 surface plot
On 11-08-16 9:50 PM, Eric Heupel wrote: I have what is probably a noob question, but I am trying to create a 3d plot to illustrate the range of values for the following simple function: A = B*(C/D) B, C, and D are independent variables whose range are equal (e.g. 1 to 3 inclusive) I figure it's not possible to map the surface of A on the 3d space defined by B, C and D but I would like to create a surface defined by the lower and upper limits of the variables - that is to say a rectangle with corners at (1,1,1), (2,3,2), (3,3,3) and (3,2,2) with a color map displayed on it corresponding to the values of A and a color key to the side of that. I have been able to wrap my head part way around persp and wireframe and can create a surface for A~B*(C/D) in either, but have not managed to create either the The contour3d function in misc3d might do what you want. See the examples. 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 surface plot
I have what is probably a noob question, but I am trying to create a 3d plot to illustrate the range of values for the following simple function: A = B*(C/D) B, C, and D are independent variables whose range are equal (e.g. 1 to 3 inclusive) I figure it's not possible to map the surface of A on the 3d space defined by B, C and D but I would like to create a surface defined by the lower and upper limits of the variables - that is to say a rectangle with corners at (1,1,1), (2,3,2), (3,3,3) and (3,2,2) with a color map displayed on it corresponding to the values of A and a color key to the side of that. I have been able to wrap my head part way around persp and wireframe and can create a surface for A~B*(C/D) in either, but have not managed to create either the __ 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 surface plot
On Aug 16, 2011, at 9:50 PM, Eric Heupel wrote: I have what is probably a noob question, but I am trying to create a 3d plot to illustrate the range of values for the following simple function: A = B*(C/D) B, C, and D are independent variables whose range are equal (e.g. 1 to 3 inclusive) I figure it's not possible to map the surface of A on the 3d space defined by B, C and D but I would like to create a surface defined by the lower and upper limits of the variables - that is to say a rectangle with corners at (1,1,1), (2,3,2), (3,3,3) and (3,2,2) with a color map displayed on it corresponding to the values of A and a color key to the side of that. I have been able to wrap my head part way around persp and wireframe and can create a surface for A~B*(C/D) in either, but have not managed to create either the The rgl package will allow plotting in pseudo 3D space ... once you unwrap your head sufficiently to provide a suitable sample dataset. Persp and wireframe are designed for a function of two variables: A ~ B*C. You could also plot slices at various levels of D with those or perhaps more clearly with levelplot -- David Winsemius, MD West Hartford, CT __ 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 surface plot
Thanks for the prompt reply. Will dig into rgl ASAP. My sample data set is: B,C,D,A 1,1,1,1 1,1,2,0.5 2,1,1,2 1,2,1,2 1,1,3,0.3 3,1,1,3 1,3,1,3 2,1,2,1 1,2,2,1 2,2,1,4 2,1,3,0.7 3,1,2,1.5 1,2,3,0.7 1,3,2,1.5 3,2,1,6 2,3,1,6 2,2,2,2 3,1,3,1 1,3,3,1 3,3,1,9 2,2,3,1.3 3,2,2,3 2,3,2,3 3,2,3,2 2,3,3,2 3,3,2,4.5 3,3,3,3 On Aug 16, 2011, at 10:48 PM, David Winsemius wrote: On Aug 16, 2011, at 9:50 PM, Eric Heupel wrote: I have what is probably a noob question, but I am trying to create a 3d plot to illustrate the range of values for the following simple function: A = B*(C/D) B, C, and D are independent variables whose range are equal (e.g. 1 to 3 inclusive) I figure it's not possible to map the surface of A on the 3d space defined by B, C and D but I would like to create a surface defined by the lower and upper limits of the variables - that is to say a rectangle with corners at (1,1,1), (2,3,2), (3,3,3) and (3,2,2) with a color map displayed on it corresponding to the values of A and a color key to the side of that. I have been able to wrap my head part way around persp and wireframe and can create a surface for A~B*(C/D) in either, but have not managed to create either the The rgl package will allow plotting in pseudo 3D space ... once you unwrap your head sufficiently to provide a suitable sample dataset. Persp and wireframe are designed for a function of two variables: A ~ B*C. You could also plot slices at various levels of D with those or perhaps more clearly with levelplot -- David Winsemius, MD West Hartford, CT __ 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 surface plot
On Aug 16, 2011, at 11:07 PM, Eric Heupel wrote: Thanks for the prompt reply. Will dig into rgl ASAP. My sample data set is: B,C,D,A 1,1,1,1 1,1,2,0.5 2,1,1,2 1,2,1,2 1,1,3,0.3 3,1,1,3 1,3,1,3 2,1,2,1 1,2,2,1 2,2,1,4 2,1,3,0.7 3,1,2,1.5 1,2,3,0.7 1,3,2,1.5 3,2,1,6 2,3,1,6 2,2,2,2 3,1,3,1 1,3,3,1 3,3,1,9 2,2,3,1.3 3,2,2,3 2,3,2,3 3,2,3,2 2,3,3,2 3,3,2,4.5 3,3,3,3 Here's a wireframe approach... which requires that we define a variable that holds the ratio C/D, so this is a sort of projection. Any case on the C/D value of 1 ( a plane in either 3 or 4 space I believe) will be on the CoverD line = 1 on that plot. The equi-ratio planes will fan out from the A=0, B=0 axis I think. dput(dat) structure(list(B = c(1L, 1L, 2L, 1L, 1L, 3L, 1L, 2L, 1L, 2L, 2L, 3L, 1L, 1L, 3L, 2L, 2L, 3L, 1L, 3L, 2L, 3L, 2L, 3L, 2L, 3L, 3L), C = c(1L, 1L, 1L, 2L, 1L, 1L, 3L, 1L, 2L, 2L, 1L, 1L, 2L, 3L, 2L, 3L, 2L, 1L, 3L, 3L, 2L, 2L, 3L, 2L, 3L, 3L, 3L), D = c(1L, 2L, 1L, 1L, 3L, 1L, 1L, 2L, 2L, 1L, 3L, 2L, 3L, 2L, 1L, 1L, 2L, 3L, 3L, 1L, 3L, 2L, 2L, 3L, 3L, 2L, 3L), A = c(1, 0.5, 2, 2, 0.3, 3, 3, 1, 1, 4, 0.7, 1.5, 0.7, 1.5, 6, 6, 2, 1, 1, 9, 1.3, 3, 3, 2, 2, 4.5, 3), CoverD = c(1, 0.5, 1, 2, 0.333, 1, 3, 0.5, 1, 2, 0.333, 0.5, 0.667, 1.5, 2, 3, 1, 0.333, 1, 3, 0.667, 1, 1.5, 0.667, 1, 1.5, 1)), .Names = c(B, C, D, A, CoverD), row.names = c(NA, -27L), class = data.frame) require(rms) dat$CoverD - with(dat, C/D) mod - ols(A~ rcs(B,3)*rcs(CoverD), data=dat) ddd - datadist(dat) options(datadist=ddd) ddd - datadist(dat) bplot(Predict(mod, B, CoverD), lfun=wireframe) On Aug 16, 2011, at 10:48 PM, David Winsemius wrote: On Aug 16, 2011, at 9:50 PM, Eric Heupel wrote: I have what is probably a noob question, but I am trying to create a 3d plot to illustrate the range of values for the following simple function: A = B*(C/D) B, C, and D are independent variables whose range are equal (e.g. 1 to 3 inclusive) I figure it's not possible to map the surface of A on the 3d space defined by B, C and D but I would like to create a surface defined by the lower and upper limits of the variables - that is to say a rectangle with corners at (1,1,1), (2,3,2), (3,3,3) and (3,2,2) with a color map displayed on it corresponding to the values of A and a color key to the side of that. I have been able to wrap my head part way around persp and wireframe and can create a surface for A~B*(C/D) in either, but have not managed to create either the The rgl package will allow plotting in pseudo 3D space ... once you unwrap your head sufficiently to provide a suitable sample dataset. Persp and wireframe are designed for a function of two variables: A ~ B*C. You could also plot slices at various levels of D with those or perhaps more clearly with levelplot -- David Winsemius, MD West Hartford, CT __ 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 surface plot
On 11.05.2010 23:25, kun.z...@wmich.edu wrote: Hi,Sir or Miss: We meet a problem of plotting 3d, which is a part of 5D. In other word, we just fixed the rest of 2 variables and slice 5d into 3d. Consider a function like Y=f(x1, x2, x3, x4). We want to have a 3D surface plot in R for the fitted value Yhat (which is of course a function of x1, x2, x3 and x4) against x1 and x2 say, keeping x3 at its median level and fixing x4 as =1 (note that x4 is binary which can take values of 1 or 0 only). So we plot yhat, x1 and x2 in 3D surface after estimating the whole model (based on all 4 covariates) . See ?persp. Uwe Ligges Awaiting your reply. Thanks for your time, Best Kun [[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 surface plot
Hi,Thomas: We meet a problem of plotting 3d, which is a part of 5D. In other word, we just fixed the rest of 2 variables and slice 5d into 3d. Consider a function like Y=f(x1, x2, x3, x4). We want to have a 3D surface plot in R for the fitted value Yhat (which is of course a function of x1, x2, x3 and x4) against x1 and x2 say, keeping x3 at its median level and fixing x4 as =1 (note that x4 is binary which can take values of 1 or 0 only). So we plot yhat, x1 and x2 in 3D surface after estimating the whole model (based on all 4 covariates) . How do we do that? Please advice. If you feel it is more involved then Kun can come to your office/consulting center for help. Awaiting your reply. Thanks for your time, Best Kun [[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 surface plot
Hi,Sir or Miss: We meet a problem of plotting 3d, which is a part of 5D. In other word, we just fixed the rest of 2 variables and slice 5d into 3d. Consider a function like Y=f(x1, x2, x3, x4). We want to have a 3D surface plot in R for the fitted value Yhat (which is of course a function of x1, x2, x3 and x4) against x1 and x2 say, keeping x3 at its median level and fixing x4 as =1 (note that x4 is binary which can take values of 1 or 0 only). So we plot yhat, x1 and x2 in 3D surface after estimating the whole model (based on all 4 covariates) . Awaiting your reply. Thanks for your time, Best Kun [[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 Surface plot
Dear All, I want to create a surface plot from the data. My data set is consists of x, y and z data. I plotted in very easy way by Excel worksheet as shown in the attached picture. I did some steps in R, but I cannot have the same plot as in Excel worksheet's figure. the R code is x - c(-1,-0.75,-0.5,-0.25,0,0.25,0.5,0.75,1) y- c(-1,-0.75,-0.5,-0.25,0,0.25,0.5,0.75,1) z- c(0.226598762, 0.132395904,0.14051906, 0.208607098, 0.320840304, 0.429423216,0.54086732, 0.647792527,0.256692375, 0.256403273, 0.172881269,0.121978079,0.156718831, 0.17175081, 0.32791861, 0.420194456,0.493195109,0.619020921, 0.278066455, 0.199822296,0.140827896,0.140139205, 0.206984231, 0.2684947, 0.340728872,0.422645622,0.501908648, 0.285697424, 0.22749307, 0.16881002, 0.13354722, 0.149532449, 0.213353293,0.283777474,0.355946993,0.427175997, 0.294521663, 0.236133131,0.18710497, 0.14828074, 0.145457711, 0.182992988,0.228281887,0.291865148,0.341808458, 0.271987072, 0.252962505,0.201123092,0.162942848, 0.14828074, 0.167205292,0.214481881,0.27141981, 0.332162403, 0.268966875, 0.253628745,0.213509108,0.180342353, 0.151623426, 0.1617176, 0.192572929,0.243404723,0.301780548, 0.284462825, 0.25473406, 0.215401758,0.202840815, 0.171061666, 0.160368388,0.183680312,0.226156887,0.272598273, 0.305655289, 0.247134344,0.235118253,0.214725129, 0.185684599, 0.167917048,0.184066896,0.218763431,0.256692375) model-data.frame(x,y,z) scatterplot3d(model, type=h,highlight.3d=TRUE, col.axis=blue,col.grid=grey, main=scatterplot3d - 2, pch=16,) Any help would appreciat. http://n4.nabble.com/forum/FileDownload.jtp?type=nid=2077409name=Excel_Figure.png -- View this message in context: http://r.789695.n4.nabble.com/3D-Surface-plot-tp2077409p2077409.html Sent from the R help mailing list archive at Nabble.com. [[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 Surface plot
On 2010-04-30 13:35, abotaha wrote: Dear All, I want to create a surface plot from the data. My data set is consists of x, y and z data. I plotted in very easy way by Excel worksheet as shown in the attached picture. I did some steps in R, but I cannot have the same plot as in Excel worksheet's figure. the R code is x- c(-1,-0.75,-0.5,-0.25,0,0.25,0.5,0.75,1) y- c(-1,-0.75,-0.5,-0.25,0,0.25,0.5,0.75,1) z- c(0.226598762, 0.132395904,0.14051906, 0.208607098, 0.320840304, 0.429423216,0.54086732, 0.647792527,0.256692375, 0.256403273, 0.172881269,0.121978079,0.156718831, 0.17175081, 0.32791861, 0.420194456,0.493195109,0.619020921, 0.278066455, 0.199822296,0.140827896,0.140139205, 0.206984231, 0.2684947, 0.340728872,0.422645622,0.501908648, 0.285697424, 0.22749307, 0.16881002, 0.13354722, 0.149532449, 0.213353293,0.283777474,0.355946993,0.427175997, 0.294521663, 0.236133131,0.18710497, 0.14828074, 0.145457711, 0.182992988,0.228281887,0.291865148,0.341808458, 0.271987072, 0.252962505,0.201123092,0.162942848, 0.14828074, 0.167205292,0.214481881,0.27141981, 0.332162403, 0.268966875, 0.253628745,0.213509108,0.180342353, 0.151623426, 0.1617176, 0.192572929,0.243404723,0.301780548, 0.284462825, 0.25473406, 0.215401758,0.202840815, 0.171061666, 0.160368388,0.183680312,0.226156887,0.272598273, 0.305655289, 0.247134344,0.235118253,0.214725129, 0.185684599, 0.167917048,0.184066896,0.218763431,0.256692375) model-data.frame(x,y,z) scatterplot3d(model, type=h,highlight.3d=TRUE, col.axis=blue,col.grid=grey, main=scatterplot3d - 2, pch=16,) Any help would appreciat. You're misunderstanding what scatterplot3d() does: it produces a _point cloud_, not a surface. You probably want persp() or wireframe() in pkg:lattice. Try this: z1 - matrix(z, 9, 9) persp(x, y, z1) or library(lattice) g - expand.grid(x = x, y = y) g$z - z wireframe(z ~ x * y, data = g) or, depending on your needs, you might want to fool around with persp3d() in the rgl package (assuming that have installed it): library(rgl) persp3d(x, y, z1, col = 'skyblue') -Peter Ehlers http://n4.nabble.com/forum/FileDownload.jtp?type=nid=2077409name=Excel_Figure.png -- Peter Ehlers University of Calgary __ 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 surface plot with wireframe or persp?
You cannot specify a dfunction for z, but need to compute the values in the matrix yourself as in: persp(data_for_time, data_for_s, outer(data_for_time, data_for_s, plot_R_i_3d)) Uwe Ligges On 20.04.2010 17:35, Jin wrote: Hello Dear, I have a function, like z=f(x,y), and try a surface plot with this function. But, on the reference of wireframe requires data option, so I generated x and y, and computed z with them. But, still I have a problem to draw a surface plot. The code and errors are ## mle_beta0=64.43707; mle_beta1=-24365.16; # generating for the requirement of wireframe data_for_c = runif(1000,30,85); # range is (30,50) data_for_s = sort(1/(273+data_for_c)); data_for_time = sort(runif(1000,0,10)) # range is (0,10) data_for_R = exp((-exp(mle_beta0+mle_beta1*data_for_s))*data_for_time) data_all = cbind(data_for_s,data_for_time,data_for_R) # function: plot_R_i_3d = f(data_for_time,data_for_s) plot_R_i_3d = function(data_for_time,data_for_s) { R_i = exp((-exp(mle_beta0+mle_beta1*data_for_s))*data_for_time); return(R_i) } # tried 1) persp or 2) wireframe persp(data_for_time,data_for_s,plot_R_i_3d) == Error in min(x, na.rm = na.rm) : invalid 'type' (list) of argument wireframe(formula=data_for_R ~ data_for_s*data_for_time,data=data_all) == Error in nrow(x) : element 1 is empty; the part of the args list of 'dim' being evaluated was: (x) ### I have two questions: 1) which one is better to plot in this case - persp and wireframe, Is there another suggestion? 2) Is it possible to plot with only a function? 3) If not, what is wrong in the code above? Many thank you in advance, Jin __ 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 surface plot with wireframe or persp?
Hello Dear, I have a function, like z=f(x,y), and try a surface plot with this function. But, on the reference of wireframe requires data option, so I generated x and y, and computed z with them. But, still I have a problem to draw a surface plot. The code and errors are ## mle_beta0=64.43707; mle_beta1=-24365.16; # generating for the requirement of wireframe data_for_c = runif(1000,30,85); # range is (30,50) data_for_s = sort(1/(273+data_for_c)); data_for_time = sort(runif(1000,0,10)) # range is (0,10) data_for_R = exp((-exp(mle_beta0+mle_beta1*data_for_s))*data_for_time) data_all = cbind(data_for_s,data_for_time,data_for_R) # function: plot_R_i_3d = f(data_for_time,data_for_s) plot_R_i_3d = function(data_for_time,data_for_s) { R_i = exp((-exp(mle_beta0+mle_beta1*data_for_s))*data_for_time); return(R_i) } # tried 1) persp or 2) wireframe persp(data_for_time,data_for_s,plot_R_i_3d) == Error in min(x, na.rm = na.rm) : invalid 'type' (list) of argument wireframe(formula=data_for_R ~ data_for_s*data_for_time,data=data_all) == Error in nrow(x) : element 1 is empty; the part of the args list of 'dim' being evaluated was: (x) ### I have two questions: 1) which one is better to plot in this case - persp and wireframe, Is there another suggestion? 2) Is it possible to plot with only a function? 3) If not, what is wrong in the code above? Many thank you in advance, Jin -- View this message in context: http://n4.nabble.com/3D-surface-plot-with-wireframe-or-persp-tp2017559p2017559.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.