Instantly share code, notes, and snippets.

Embed
What would you like to do?
simple bar graph
library(ggplot2)
# deviation_potsdam.csv has been created using crash:
# bin/crash --format=csv -c "SELECT format('%tY', date) AS year, AVG(temp) - 8.659611756762368 as deviation FROM german_climate_denormalized WHERE temp IS NOT NULL AND station_name = 'Potsdam' and date < '2015-01-01' GROUP BY 1 ORDER BY 1 ASC" > deviation_potsdam.csv
frame <- read.table('deviation_potsam.csv', header=TRUE, sep=",")
negative <- frame$deviation < 0
# create the png
png("deviation_potsdam.png", width=900, height=480)
print(
ggplot(
frame,
aes(x=frame$year, y=frame$deviation, fill=negative)
) + geom_bar(stat="identity") + labs(x="Year", y="Deviation") + guides(fill=FALSE) + scale_x_continuous(breaks=seq(1890, 2015, by=5)))
dev.off()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment