mirror of
https://github.com/dchakro/ggplot_themes.git
synced 2026-05-17 11:22:16 -07:00
update description
This commit is contained in:
parent
138478394c
commit
fe72db0a85
4 changed files with 23 additions and 12 deletions
|
|
@ -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"){
|
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
|
# # Author: Deepankar Chakroborty
|
||||||
# # Available at: https://github.com/dchakro/ggplot_themes
|
# # Available at: https://github.com/dchakro/ggplot_themes
|
||||||
# # Report issues: https://github.com/dchakro/ggplot_themes/issues
|
# # 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'
|
# type: 'L', 'square'
|
||||||
|
# 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'
|
# 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)
|
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)
|
fontfamily <- ifelse(test = tolower(fontfamily) %in% c("sans","serif","mono"),yes = tolower(fontfamily),no = fontfamily)
|
||||||
|
|
||||||
if( type == "square"){
|
if( type == "square"){
|
||||||
|
|
|
||||||
13
README.md
13
README.md
|
|
@ -17,7 +17,7 @@ I found myself writing these ```ggplot2::theme()``` objects everytime I wanted t
|
||||||
## Using DC_theme_generator
|
## Using DC_theme_generator
|
||||||
|
|
||||||
```R
|
```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')
|
customtheme <- DC_theme_generator(type='L')
|
||||||
ggplot()+geom_point()+customtheme
|
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:
|
Here is an example tweaking some of the defaults:
|
||||||
|
|
||||||
```R
|
```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',
|
customtheme <- DC_theme_generator(type = 'L',
|
||||||
legend = 'F',
|
legend = 'F',
|
||||||
ticks = 'out',
|
ticks = 'in',
|
||||||
x.axis.angle = 45,
|
x.axis.angle = 45,
|
||||||
hjust = 0.5,
|
hjust = 0.5,
|
||||||
vjust = 0.5,
|
vjust = 0.5,
|
||||||
fontsize.cex = 1.8,
|
fontsize.cex = 1.5,
|
||||||
fontfamily = 'mono')
|
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:
|
The above theme results in a canvas like this:
|
||||||
|
|
|
||||||
BIN
img/Rplot.png
BIN
img/Rplot.png
Binary file not shown.
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 16 KiB |
6
source.R
6
source.R
|
|
@ -32,8 +32,8 @@ customtheme <- DC_theme_generator(type = 'L',
|
||||||
x.axis.angle = 45,
|
x.axis.angle = 45,
|
||||||
hjust = 0.5,
|
hjust = 0.5,
|
||||||
vjust = 0.5,
|
vjust = 0.5,
|
||||||
fontsize.cex = 1.8,
|
fontsize.cex = 1.5,
|
||||||
fontfamily = 'mono',
|
fontfamily = 'Palatino',
|
||||||
fontstyle = "bold")
|
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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue