diff --git a/DC_theme_generator.R b/DC_theme_generator.R index 0c68e4b..b2104ef 100644 --- a/DC_theme_generator.R +++ b/DC_theme_generator.R @@ -1,18 +1,28 @@ DC_theme_generator <- function(type, legend=T, ticks="out", x.axis.angle=0, hjust=0.5, vjust=0.5, fontsize.cex=1.5, fontfamily="serif", ax.fontstyle="bold.italic"){ + # #<----------------------------> + # # You must include this section when: + # # Distributing, Embedding, Using and/or Modifying this code. + # # Please read and abide by the terms of the included LICENSE. + # # Copyright 2020, Deepankar Chakroborty, All rights reserved. - # # Generate themes for ggplot2 # # Author: Deepankar Chakroborty # # Available at: https://github.com/dchakro/ggplot_themes # # Report issues: https://github.com/dchakro/ggplot_themes/issues + # # LICENSE: https://github.com/dchakro/ggplot_themes/blob/master/LICENSE + # #<----------------------------> - ## Options: + # # PURPOSE: Generate themes for ggplot2 + + # # OPTIONS: # type: 'L', 'square' + # legent: T = left, F = no legend # ticks: 'in', 'out' # fontfamily: 'serif' , 'sans' , 'mono', 'Helvetica', 'Palatino' # ax.fontstyle = 'plain', 'italic', 'bold', 'bold.italic' + # x.axis.angle = 45 (i.e. angle for the x axis text) + # hjust and vjust = to adjust the x axis text ticks <- tolower(ticks) - # Supports system fonts, and doesn't transform them to lower case as font names are case-sensitive. fontfamily <- ifelse(test = tolower(fontfamily) %in% c("sans","serif","mono"),yes = tolower(fontfamily),no = fontfamily) if( type == "square"){ diff --git a/README.md b/README.md index 09a9513..bd240d7 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ I found myself writing these ```ggplot2::theme()``` objects everytime I wanted t ## Using DC_theme_generator ```R -source("https://gitlab.utu.fi/deecha/ggplot_themes/-/raw/master/DC_theme_generator.R") +source('https://raw.githubusercontent.com/dchakro/ggplot_themes/master/DC_theme_generator.R') customtheme <- DC_theme_generator(type='L') ggplot()+geom_point()+customtheme @@ -28,17 +28,18 @@ More detailed usage instructions along with an example can be found in the R scr Here is an example tweaking some of the defaults: ```R -source("https://gitlab.utu.fi/deecha/ggplot_themes/-/raw/master/DC_theme_generator.R") +source('https://raw.githubusercontent.com/dchakro/ggplot_themes/master/DC_theme_generator.R') customtheme <- DC_theme_generator(type = 'L', legend = 'F', - ticks = 'out', + ticks = 'in', x.axis.angle = 45, hjust = 0.5, vjust = 0.5, - fontsize.cex = 1.8, - fontfamily = 'mono') + fontsize.cex = 1.5, + fontfamily = 'Palatino', + ax.fontstyle = "bold.italic") -ggplot(data = dat, aes(x=X, y=Y, color=Class)) + geom_point() + scale_color_manual(values=c("red","blue")) + xlab("X-axis") + ylab("Y-axis") + ggtitle("Customized DC_theme_generator") + customtheme +ggplot(data = dat, aes(x=X,y=Y,color=Class)) + geom_point() + scale_color_manual(values=c("red","blue")) + xlab("X-axis") + ylab("Y-axis") + ggtitle("Customized DC_theme_generator") + customtheme ``` The above theme results in a canvas like this: diff --git a/img/Rplot.png b/img/Rplot.png index 77d678e..34d5c1e 100644 Binary files a/img/Rplot.png and b/img/Rplot.png differ diff --git a/source.R b/source.R index 8f7513a..3c32d23 100644 --- a/source.R +++ b/source.R @@ -32,8 +32,8 @@ customtheme <- DC_theme_generator(type = 'L', x.axis.angle = 45, hjust = 0.5, vjust = 0.5, - fontsize.cex = 1.8, - fontfamily = 'mono', - fontstyle = "bold") + fontsize.cex = 1.5, + fontfamily = 'Palatino', + ax.fontstyle = "bold.italic") ggplot(data = dat, aes(x=X,y=Y,color=Class)) + geom_point() + scale_color_manual(values=c("red","blue")) + xlab("X-axis") + ylab("Y-axis") + ggtitle("Customized DC_theme_generator") + customtheme