'Why are the x and y limits of a 3D histogram 0 to 1 using hist3D package in R?

This is my goal: Make a 3D histogram that shows a histogram of my x variable (with the histogram values on the z axis) and my y variable.

This is my problem: I followed this post to make a 3D histogram in R. However, the limits of the 3D histogram plot are 0 to 1 on the x-axis and 0 to 1 on the y-axis yet my data range from 0 to 17 and 0 to 20 on the x and y axes, respectively. So the limits of the plot seem wrong. What am I doing wrong? Below is a sample of my data and my code.

library(plot3D)
x_c <- cut(data2$x,15)
y_c <- cut(data2$y,15)
z <- table(x_c, y_c)
hist3D(z=z)
hist3D(z=z,xlim=c(0,1),ylim=c(0,1))
x y
23.27125 8.111366
22.47496 8.139645
22.47496 8.139645
22.47496 8.139645
22.47496 8.139645
22.47496 8.139645
22.47496 8.139645
22.47496 8.139645
22.47496 8.139645
22.47496 8.139645
22.47496 8.139645
22.47496 8.139645
19.52674 7.245736
22.47496 8.139645
18.50059 6.326572
17.89179 5.452516
22.47496 8.139645
22.47496 8.139645
22.47496 8.139645
22.47496 8.139645
22.47496 8.139645
22.47496 8.139645
0.2285616 0.9823013
0.2285616 0.9823013
0.2285616 0.9823013
0.2267763 0.9316706

Image of the 3D histogram



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source