I am a newbie on graphs and r and I got the exercise to analyse a dataset. I am willing to do a graph (facet_wrap?) from it, where I show the distribution of profits per month from different countries. I have a subset with 19 Countries, 12 Months and profit values! Something like (example):
Country Month Profit
Brazil Jan 50
Brazil fev 80
Brazil mar 15
Austria Jan 35
Austria fev 80
Austria mar 47
France Jan 21
France fev 66
France mar 15
[...]
Germany Dez 40
I have played a bit around with the graph but I am still struggling with understanding how does it work. So far I have:
test <- ggplot(sub, aes(x=Month, y=Profit, fill= Profit))+
geom_bar(stat='identity')+
facet_wrap(~Country) +
scale_fill_gradient(low = "red", high = "green", name = "Profit grade", labels = comma) +
scale_y_continuous(labels = function(x) format(x, scientific = FALSE))+
theme_bw()
there are a few problems though that I cant understand.
- Why aren't all the bars starting from the same line? they are not straight, is it normal? or why is the X axis fluctuating? (check France for clear picture)
- How can I fill it correctly? On my graph when I use the function Fill, the shade happens throughout the bar and not between different pars (Which would make more sense). Could you explain what this filling (from the photo) could be meaning?
- Would there be another/better way to present such information? I was willing to try a line graph, such as those mountain graphs about economics used on TV, but I don't know how to do it. I tried some points but didn't make sense for me (or I did wrong haha)