When plotting a stacked bar chart with negative values, tinyplot doesn't stack them the way ggplot2 does for example. Currently for data that contains negative y-values the following warning is shown:
Warning message:
In settings$type_data(settings, ...) :
'beside' must be TRUE if there are negative 'y' values
and the bars are put beside. For some data it would make sense to show the bars stacked even if some values are negative (e.g. balances like below):
rm(list = ls())
library(tinyplot)
library(worldbank)
library(ggplot2)
df <- wb_data(
indicator = c("BN.GSR.GNFS.CD", "BN.GSR.FCTY.CD", "BN.TRF.CURR.CD"),
country = "US"
)
# tinyplot
plt(
value ~ date | indicator_id,
data = df,
type = "barplot"
)
# ggplot2
ggplot(df, aes(fill=indicator_id, y=value, x=date)) +
geom_bar(position="stack", stat="identity")
When plotting a stacked bar chart with negative values,
tinyplotdoesn't stack them the wayggplot2does for example. Currently for data that contains negative y-values the following warning is shown:and the bars are put beside. For some data it would make sense to show the bars stacked even if some values are negative (e.g. balances like below):