0

Can't start Y-axis on ggplot higher up

as soon as I specify c(15000000,max(variable)) I just lose all the visual

  aes(x= ecomm_data3$Month, y = ecomm_data3$Value, fill = ecomm_data3$Year) +
  geom_bar(stat = 'identity', position = "dodge") +
  scale_y_continuous(name="E-comm Value £", labels = comma) +
  labs(title = "Total e-comm value", x = "Date") +
  scale_fill_manual("Year", values = c("18" = "steelblue", "19" = "orange"))```

Loss of visual completely
  • Your code doesn't seem to be *correct/valid* `ggplot2` code. Please code through [recommended tutorials](https://r4ds.had.co.nz/data-visualisation.html) first. To solve your problem please see [this post](https://stackoverflow.com/questions/10365167/geom-bar-bars-not-displaying-when-specifying-ylim) or [this](https://stackoverflow.com/questions/49264108/set-y-limits-in-bar-chart-ggplot2) or [this](https://stackoverflow.com/questions/47951067/ggplot2-geom-bar-with-custom-y-limits) – pogibas Jun 20 '19 at 15:24
  • (a) Please make the example reproducible. This means sharing a little bit of sample data (just a few rows, hopefully you will share with `dput()` so it is copy/pasteable), and also showing the full code for the plot (probably starts with `ggplot()`, not with `aes()`). (b) Don't use `$` inside `aes()`. Use bare column names, `aes(x = Month, ...)`. (c) Show how you are adding `c(15000000,max(variable))`. Is it inside the y scale, named as `limits = ...`? And, unlike `aes()`, you *should* use `data$column` here... what is `variable`, anyway? On the y-axis you have acolumn called `Value`... – Gregor Thomas Jun 20 '19 at 15:27
  • 1
    If you want bars to start at something other than 0 you could manually shift things or use an alternative like `geom_segment()` as shown in answers [here](https://stackoverflow.com/questions/35324892/ggplot2-setting-geom-bar-baseline-to-1-instead-of-zero) or use `coord_cartesian()` or other options in `scale_y_continuous()` as in answers [here](https://stackoverflow.com/questions/10365167/geom-bar-bars-not-displaying-when-specifying-ylim). – aosmith Jun 20 '19 at 15:31
  • @aosmith - thanks for the helpful reply, the last suggestion worked for me. – Matthew Appleyard Jun 24 '19 at 09:34

0 Answers0