Mercurial > repos > moheydarian > ggplot_histogram
comparison ggplotscripthistogram.R @ 15:19546f3ef70a draft
Uploaded
| author | moheydarian |
|---|---|
| date | Tue, 11 Apr 2017 16:43:46 -0400 |
| parents | ed06f51b00ef |
| children | 9577cd390ee6 |
comparison
equal
deleted
inserted
replaced
| 14:bd1c3f88daa9 | 15:19546f3ef70a |
|---|---|
| 35 'woutputdim', 'w', 2, 'integer', | 35 'woutputdim', 'w', 2, 'integer', |
| 36 'houtputdim', 'd', 2, 'integer', | 36 'houtputdim', 'd', 2, 'integer', |
| 37 'dim', 'k', 2, 'character', | 37 'dim', 'k', 2, 'character', |
| 38 'scaling', 'j', 2, 'character', | 38 'scaling', 'j', 2, 'character', |
| 39 'legend', 'l', 2, 'character', | 39 'legend', 'l', 2, 'character', |
| 40 'density', 'm', 2, 'character', | |
| 40 'output', 'o', 2, 'character' | 41 'output', 'o', 2, 'character' |
| 41 ), byrow=TRUE, ncol=4); | 42 ), byrow=TRUE, ncol=4); |
| 42 | 43 |
| 43 # Parse options | 44 # Parse options |
| 44 options = getopt(option_specification); | 45 options = getopt(option_specification); |
| 61 #Show/hide legend | 62 #Show/hide legend |
| 62 if(options$legend == "yes"){ | 63 if(options$legend == "yes"){ |
| 63 gg_legend = NULL | 64 gg_legend = NULL |
| 64 } else { | 65 } else { |
| 65 gg_legend = theme(legend.position="none") | 66 gg_legend = theme(legend.position="none") |
| 67 } | |
| 68 | |
| 69 #density | |
| 70 if(options$density == "counts"){ | |
| 71 gg_density = NULL | |
| 72 } else { | |
| 73 gg_density = , ...density..., | |
| 66 } | 74 } |
| 67 | 75 |
| 68 #Choose between automatically scaled x and y axis or user defined | 76 #Choose between automatically scaled x and y axis or user defined |
| 69 if(options$scaling == "Automatic"){ | 77 if(options$scaling == "Automatic"){ |
| 70 gg_scalex = NULL | 78 gg_scalex = NULL |
| 110 gg_colorscale = NULL | 118 gg_colorscale = NULL |
| 111 } else { | 119 } else { |
| 112 gg_colorscale = scale_color_brewer(palette=options$colors, direction=options$colororder) | 120 gg_colorscale = scale_color_brewer(palette=options$colors, direction=options$colororder) |
| 113 } | 121 } |
| 114 | 122 |
| 115 ggplot(input,aes(value,color=variable)) + | 123 ggplot(input,aes(value gg_density,color=variable)) + |
| 116 geom_freqpoly(binwidth=options$binwidth,size=options$size)+gg_facet+gg_colorscale+ | 124 geom_freqpoly(binwidth=options$binwidth,size=options$size)+gg_facet+gg_colorscale+ |
| 117 gg_scalex+gg_scaley+theme_bw()+xlab(options$xlab)+ylab(options$ylab)+gg_legend+ | 125 gg_scalex+gg_scaley+theme_bw()+xlab(options$xlab)+ylab(options$ylab)+gg_legend+ |
| 118 ggtitle(options$title) | 126 ggtitle(options$title) |
| 119 | 127 |
| 120 ggsave(file=options$output) | 128 ggsave(file=options$output) |
