Skip to content

Instantly share code, notes, and snippets.

@betelgeuse
Created December 13, 2013 20:55
Show Gist options
  • Save betelgeuse/7951179 to your computer and use it in GitHub Desktop.
Save betelgeuse/7951179 to your computer and use it in GitHub Desktop.
library(ggplot2)
data = read.table('years.data',header=TRUE)
#geom_bar(width=.5) +
pdf('paper_years.pdf')
print(ggplot(data, aes(as.numeric(year))) +
geom_bar() +
xlab("Vuosi") +
ylab("Julkaisujen määrä") +
theme(axis.text.x = element_text(angle = -90)) +
scale_x_continuous(breaks=1979:2013)
)
dev.off()
@betelgeuse
Copy link
Author

$ head -n 3 years.data
year
1979
1979

@thomaskern
Copy link

data = data.frame(year=sample(1979:2013,1000,T))
p = ggplot(data, aes(factor(year,levels=1979:2013))) +
geom_bar() +
xlab("Vuosi") +
ylab("Julkaisujen määrä") +
theme(axis.text.x = element_text(angle = -90)) +
scale_x_discrete(drop=F)
print(p) #optional
ggsave("paper_years.pdf",p)

@thomaskern
Copy link

for homeboy jbecker

data = data.frame(year=sample(factor(1979:2013),1000,T))
p = ggplot(data, aes(factor(year,levels=1979:2013))) +
geom_bar() +
xlab("Vuosi") +
ylab("Julkaisujen määrä") +
theme(axis.text.x = element_text(angle = -90)) +
scale_x_discrete(drop=F)
print(p) #optional

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment