Reputation: 12152
I am quite new to R and more to plotting with it.
I have this example data in a dataframe.
head(dframe)
maingroup subgroup n
1 BR A 315
2 MV A 394
3 SAN A 253
4 BR B 230
5 MV B 242
6 SAN B 152
Now I want to visualize it:
Upvotes: 0
Views: 900
Reputation: 6362
If this is for publication (static image), you can use scatterplot3d
:
library(scatterplot3d)
DT <- data.frame(maingroup = letters[1:6], subgroup = letters[26:21], n = 1:6)
scatterplot3d(x = DT$maingroup, # x axis
y = DT$subgroup, # y axis
z = DT$n, # z axis
x.ticklabs = levels(DT$maingroup),
y.ticklabs = levels(DT$subgroup))
For something more interactive, you can use plotly
:
library(plotly)
plot_ly(x = DT$maingroup, # x axis
y = DT$subgroup, # y axis
z = DT$n, # z axis
type = "scatter3d")
Upvotes: 4