plot - How to make 3D histogram in R -


this goal: plot frequency of y according x in z axis.

these problems: have 2 columns array (x , y) , need divide x classes (p.ex. 0.2 ou 0.5) , calculate frequency of y each class of x. plot should appear x-y plot in "ground" plan , frequency in z axis. surface or 3d histogram. tried make using hist3d function of plot3d package don't know doing wrong.

this example of trying do:

https://www.safaribooksonline.com/library/view/r-data-visualization/9781783989508/ch06s05.html

thanks!!

using simulated data, should want. key have create bivariate bins, accomplished using cut() function. treating binned factors levels can count combinations of each factor level using table() function below:

library(plot3d)  ##  simulate data: set.seed(2002) x <- rnorm(1000) y <- rnorm(1000)  ##  create cuts: x_c <- cut(x, 20) y_c <- cut(y, 20)  ##  calculate joint counts @ cut levels: z <- table(x_c, y_c)  ##  plot 3d histogram: hist3d(z=z, border="black")  ##  plot 2d heatmap: image2d(z=z, border="black") 

3d2d


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -