0

I have this dataframe:

Name <- c("Present", "Extra", "Updated")
Gyor <- c(94143, 13691,12661)
Agglomeration <- c(58462, 20669, 6613)
df <- data.frame(Name, Gyor, Agglomeration)
print(df)

What I would like to have is a 3D stacked bar plot like this (using ggplot)

3dplot

1 Answers1

1

You cannot generate 3D plots using ggplot. There are some extension packages which sort of allow it, but this type of plot is very much against the entire ethos of ggplot. It would be considered a terrible way to present data by modern data visualisation standards; it is difficult to read off accurately and looks very dated.

In addition, the data in your question can be easily plotted as a 2d stacked bar (it doesn't have enough dimensions to allow a 3D stacked bar like the one you have included)

library(tidyverse)

ggplot(pivot_longer(df, -Name), aes(Name, value, fill = name)) +
  geom_col() +
  scale_fill_brewer(NULL, palette = 'Set1') +
  labs(x = NULL) +
  scale_y_continuous(labels = scales::comma) +
  theme_minimal(base_size = 16)

enter image description here

Allan Cameron
  • 147,086
  • 7
  • 49
  • 87
  • So what is it that you want to change? – Allan Cameron Apr 18 '23 at 18:35
  • I mean I did the 2D graph, what you just proposed. But I do not know how to do the 3D one in R. The above graph was done by a colleague in Python, but since I am an R person, I wanted to write a code for this in R. – Attila Borsos Apr 18 '23 at 19:10