- display warning message when using legacy code
- Support title font style options
This commit is contained in:
dchakro 2021-06-13 03:15:31 +03:00
parent 2a8c075531
commit b16e24fa01
2 changed files with 18 additions and 4 deletions

View file

@ -1,4 +1,14 @@
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"){ 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 = "italic",
title.fontstyle = "bold.italic"){
# #<----------------------------> # #<---------------------------->
# # You must include this section when: # # You must include this section when:
# # Distributing, Embedding, Using and/or Modifying this code. # # Distributing, Embedding, Using and/or Modifying this code.
@ -18,7 +28,7 @@ DC_theme_generator <- function(type, legend=T, ticks="out", x.axis.angle=0, hjus
# legent: T = left, F = no legend # legent: T = left, F = no legend
# ticks: 'in', 'out' # ticks: 'in', 'out'
# fontfamily: 'serif' , 'sans' , 'mono', 'Helvetica', 'Palatino' # fontfamily: 'serif' , 'sans' , 'mono', 'Helvetica', 'Palatino'
# ax.fontstyle = 'plain', 'italic', 'bold', 'bold.italic' # title.fontstyle and ax.fontstyle = 'plain', 'italic', 'bold', 'bold.italic'
# x.axis.angle = 45 (i.e. angle for the x axis text) # x.axis.angle = 45 (i.e. angle for the x axis text)
# hjust and vjust = to adjust the x axis text # hjust and vjust = to adjust the x axis text
@ -37,7 +47,7 @@ DC_theme_generator <- function(type, legend=T, ticks="out", x.axis.angle=0, hjus
axis.ticks = element_line(colour = "black"), axis.ticks = element_line(colour = "black"),
text = element_text(family = fontfamily), text = element_text(family = fontfamily),
plot.title = element_text(family = fontfamily, plot.title = element_text(family = fontfamily,
face="bold", face = title.fontstyle,
color = "black", color = "black",
size = rel(fontsize.cex)), size = rel(fontsize.cex)),
axis.ticks.length = unit(ifelse(ticks=="in",-0.2,0.2),"cm"), axis.ticks.length = unit(ifelse(ticks=="in",-0.2,0.2),"cm"),
@ -77,7 +87,7 @@ DC_theme_generator <- function(type, legend=T, ticks="out", x.axis.angle=0, hjus
axis.ticks = element_line(colour = "black"), axis.ticks = element_line(colour = "black"),
text = element_text(family = fontfamily), text = element_text(family = fontfamily),
plot.title = element_text(family = fontfamily, plot.title = element_text(family = fontfamily,
face="bold", face = title.fontstyle,
color = "black", color = "black",
size = rel(fontsize.cex)), size = rel(fontsize.cex)),
axis.ticks.length = unit(ifelse(ticks=="in",-0.2,0.2), "cm"), axis.ticks.length = unit(ifelse(ticks=="in",-0.2,0.2), "cm"),

View file

@ -1,5 +1,9 @@
# This is legacy theme defination for maintaining compatibility with my own historical code base. # This is legacy theme defination for maintaining compatibility with my own historical code base.
warning("This is legacy code. Please migrate to: https://github.com/dchakro/ggplot_themes")
message("Please run:")
message("source('https://raw.githubusercontent.com/dchakro/ggplot_themes/master/DC_theme_generator.R')")
library(ggplot2) library(ggplot2)
theme_dc.plot.L.45.nolegend=ggplot2::theme( theme_dc.plot.L.45.nolegend=ggplot2::theme(
axis.line = element_line(colour = "black", axis.line = element_line(colour = "black",