-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathplot_bar.r
24 lines (23 loc) · 930 Bytes
/
plot_bar.r
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#
# plot_bar.r
#
# Created by David Ruau on 2011-03-29.
# Department of Pediatrics/Div. System Medicine Stanford University.
#
##################### USAGE #########################
# source('sex_diff_pain.r')
# sex.pub <- sex_diff_pain(search.str = 'Sex+Characteristics[mh] AND Pain[mh]', year.span=1970:2011)
# par(las=1)
# plot_bar(x=sex.pub[1:41], linecol='royalblue', cols="Reds", myTitle='Number of publication per year for\n"sex differences" and "pain"')
#
#####################################################
plot_bar <- function(x=sex.pub, linecol="royalblue", cols, addArg=TRUE) {
require("RColorBrewer")
# colorfunction = colorRampPalette(brewer.pal(9, cols))
# mycolors = colorfunction(length(x))
## This draw the bar plot and save it in an object...
# bp <- barplot(x, col=mycolors)
bp <- barplot(x, col=cols, add=addArg)
fit <- stats::lowess(x, f=1/3)
lines(x=bp, fit$y, col=linecol, lwd=3)
}