0

I'm trying to use plotly to make my graph slightly more interactive. However, when I use it, it is shrinking my graph vertically, is there a way I can stop this, or just stretch my graph vertically again?

here is the code for the graph;

##stacked column chart for expenditure breakdowns
stackedCol <- ggplot(expenditureDS, aes(fill = Category, y=AvgExpenditurePerWeek, x=Category)) + 
    geom_bar(stat="identity",
             width = 0.6,
             color = "black",
             size = 0.5,
             alpha = 0.7) + 
    theme_minimal() +
    theme(legend.position = "none", axis.text.x = element_text(angle = 45, hjust = 0.8)) +
    labs(x= "Categories", y = "Expenditure Per Week",
            title = "All Households in NZ - Expenditure Breakdowns",
            caption = "2008-2020 data") +
    theme(
    panel.grid.major.x = element_blank(),
    panel.grid.minor.x = element_blank()) +
    theme(plot.title = element_text(hjust = 0)) +
    geom_text(aes(label = if_else(AvgExpenditurePerWeek > 20, as.character(SubCategory), "")), 
          position = position_stack(vjust = 0.5), size = 2.5, hjust = 0.5, angle = 0) +
    scale_y_continuous(labels= dollar_format(prefix="$"))

ggplotly(stackedCol)

here is the graph without the ggplotly(stackedCol); enter image description here

here is the graph with the ggplotly(stackedCol); enter image description here

Jon Spring
  • 40,151
  • 4
  • 32
  • 50
Nad
  • 39
  • 5
  • Are you viewing in the Viewer window of RStudio, or a chunk in an R Markdown file, or in another manner? The size will depend on the size of that window and is probably not controlled by your plot directly. – Jon Spring Jun 08 '21 at 23:26
  • im using Jupyter notebook, and both the images are taken from that, but that is what i am submitting, so wouldn't want it looking ugly in the .ipynb file – Nad Jun 08 '21 at 23:30
  • Do these help? I think this is a Jupyter question and not a ggplot2 or plotly one. https://stackoverflow.com/questions/36367986/how-to-make-inline-plots-in-jupyter-notebook-larger. https://stackoverflow.com/questions/41760737/output-figure-size-in-jupyter-notebook https://plotly.com/python/setting-graph-size/ – Jon Spring Jun 08 '21 at 23:43

0 Answers0