I have a dataset and each entry contains data of a form (x0,x1,y0,y1
,...).
Suppose that x0,x1
are cost and y0,y1
are time.
I want to plot a scatterplot where for each entry a "bubble" is used to display the area captured by (x0,x1,y0,y1
) in the 2D space, i.e., in the x axis the region [x0,x1]
and in the y axis the region [y0,y1]
.
Update
For instance, consider this frame
x0 x1 y0 y1
1 2 2 3
1.5 2 2 3.5
How can I plot these areas?
Also, what if I want to plot 3D areas of the form
x0 x1 y0 y1 z0 z1
1 2 2 3 3 3.5
1.5 2 2 3.5 2.5 3
I tried to do this using geom_point()
but it does not seem to work. Neither bubble charts can do the job.
@Philip, suggested to use geom_rect()
, and it might work for the 2D space, but what about 3D?
Any ideas?
Update 2
Following Philip's comment, here is my code:
library(plot3D)
df <- read.csv(...)
box3D(x0=df$V1, x1 = df$V2, y0=df$V3, y1=df$V4, z0=df$V5, z1=df$V6,
col = rainbow(n = 8, alpha = 0.1),
border = "black", lwd = 2, phi = 0, theta=40,
ticktype="detailed")
This question would be easier to answer in general if you provided some sample data, but since you mention geom_point
I conclude you are using ggplot2
(good start!), so probably the answer is geom_rect
:
ggplot(df, aes(xmin = x1, xmax = x2, ymin = y1, ymax = y2)) +
geom_rect()
Or something like that.