dreamRs / esquisse

RStudio add-in to make plots interactively with ggplot2
https://dreamrs.github.io/esquisse
Other
1.76k stars 227 forks source link

Combine more than one plot #223

Open vim15 opened 1 year ago

vim15 commented 1 year ago

hello,

This is a feature request. I was wondering if there is any scope to add more than two types of plots together. Like geom_bar() and geom_line(), in a single plot.

For example, if you have the below data frame named 'cost' :

structure(list(Date = structure(c(18686, 18686, 18714, 18714, 18745, 18745), class = "Date"), Utility = c("Gas", "Electricity", "Gas", "Electricity", "Gas", "Electricity"), usage = c(0, 0, 125, 208, 104, 232), price = c(0, 0, 45.46, 37.82, 39.67, 43.09 )), row.names = c(NA, -6L), class = c("tbl_df", "tbl", "data.frame" ))

be able to plot something like this in esquisse :

ggplot(cost) + geom_bar(aes(x = Date, fill = Utility, weight = usage)) + geom_line(aes(x = Date, y = price, colour = Utility), size = 0.5) + scale_fill_hue(direction = 1) + scale_color_manual( values = c(Electricity = "#8E0152", Gas = "#276419") ) + theme_minimal()

I think it would be a nifty feature which at the moment is missing.