Skip to content

Commit

Permalink
changed the theme options to bring them closer to theme_gray settings
Browse files Browse the repository at this point in the history
  • Loading branch information
sainathadapa committed Oct 15, 2017
1 parent 75f1acb commit 6a81217
Show file tree
Hide file tree
Showing 38 changed files with 71 additions and 109 deletions.
178 changes: 70 additions & 108 deletions R/get_theme.R
Expand Up @@ -4,10 +4,7 @@ get_theme <- function (palette, layout, spacing, text_size, type, line_weight) {
text_colour <- palette$text[[match.arg(type, names(palette$text))]]
line_colour <- ifelse(inner, palette$line[['inner']], palette$line[['outer']])

# Functions to define axes title distances' from axis (with sensible minimum/maximum values).
x_title_spacing <- function(spacing) max(-1.2, -(spacing / 1.25) + 0.5)

y_title_spacing <- function(spacing) max(0.8, min(2.4, spacing))
half_line <- text_size / 2

theme(

Expand All @@ -24,157 +21,122 @@ get_theme <- function (palette, layout, spacing, text_size, type, line_weight) {
linetype = 1),

text = element_text(
debug = FALSE,
margin = margin(),
family = '',
face = "plain",
colour = text_colour,
size = text_size,
lineheight = 0.9,
hjust = 0.5,
vjust = 0.5,
angle = 0,
lineheight = 0.9),

axis.text = element_text(
debug = FALSE,
margin = margin(),
size = rel(0.8),
colour = text_colour),
margin = margin(),
debug = FALSE),

axis.text.x.top = NULL,
axis.text.y.right = NULL,
axis.line = element_line(colour = line_colour),
axis.line.x = layout$axis.line.x(colour = line_colour),
axis.line.y = layout$axis.line.y(colour = line_colour),

axis.text.x = element_text(
debug = FALSE,
margin = margin(0.1 * spacing, 0.1 * spacing, 0.1 * spacing, 0.1 * spacing, unit = 'cm'),
vjust = 1,
colour = text_colour,
face = 'bold'),

axis.text.y = element_text(
debug = FALSE,
margin = margin(0.1 * spacing, 0.1 * spacing, 0.1 * spacing, 0.1 * spacing, unit = 'cm'),
hjust = 1,
colour = text_colour,
face = 'bold'),

axis.ticks = layout$axis.ticks(colour = line_colour),
axis.title = layout$axis.title(colour = text_colour),
axis.line.x = NULL,
axis.line.y = NULL,
axis.text = element_text(size = rel(0.8), colour = text_colour),
axis.text.x = element_text(margin = margin(t = 0.8 * spacing * half_line / 2), vjust = 1),
axis.text.x.top = element_text(margin = margin(b = 0.8 * spacing * half_line / 2), vjust = 0),
axis.text.y = element_text(margin = margin(r = 0.8 * spacing * half_line / 2), hjust = 1),
axis.text.y.right = element_text(margin = margin(l = 0.8 * spacing * half_line / 2), hjust = 0),
axis.ticks = element_line(colour = line_colour),
axis.ticks.length = unit(half_line * spacing / 2, "pt"),

axis.title.x = element_text(
debug = FALSE,
margin = margin(0.1 * spacing, 0.1 * spacing, 0.1 * spacing, 0.1 * spacing, unit = 'cm'),
vjust = x_title_spacing(spacing)),

axis.title.x.top = NULL,

margin = margin(t = half_line*spacing),
vjust = 1
),
axis.title.x.top = element_text(
margin = margin(b = half_line*spacing),
vjust = 0
),
axis.title.y = element_text(
debug = FALSE,
margin = margin(0.1 * spacing, 0.1 * spacing, 0.1 * spacing, 0.1 * spacing, unit = 'cm'),
angle = 90,
vjust = y_title_spacing(spacing)),

axis.title.y.right = NULL,
axis.ticks.length = grid::unit(0.15, "cm"),

legend.background = element_rect(
angle = 90,
margin = margin(r = half_line*spacing),
vjust = 1
),
axis.title.y.right = element_text(
angle = -90,
margin = margin(l = half_line*spacing),
vjust = 0
),

legend.background = element_rect(
colour = ifelse(inner, 'white', palette$background),
fill = ifelse(inner, 'white', palette$background)),

legend.margin = NULL,
legend.spacing = grid::unit(0.2 * spacing, "cm"),

legend.key = element_rect(
colour = ifelse(inner, 'white', palette$background),
fill = palette$background),

legend.spacing.x = NULL,
legend.spacing.y = NULL,
legend.key.size = grid::unit(1.2, "lines"),
legend.key.height = NULL,
legend.key.width = NULL,

legend.text = element_text(
debug = FALSE,
margin = margin(),
size = rel(0.8)),

legend.text.align = NULL,

legend.title = element_text(
debug = FALSE,
margin = margin(),
size = rel(0.8),
face = "bold",
hjust = 0),

legend.spacing = unit(0.4*spacing, "cm"),
legend.spacing.x = NULL,
legend.spacing.y = NULL,
legend.margin = margin(0, 0, 0, 0, "cm"),
legend.key = element_rect(colour = ifelse(inner, 'white', palette$background),fill = palette$background),
legend.key.size = grid::unit(1.2, "lines"),
legend.key.height = NULL,
legend.key.width = NULL,
legend.text = element_text(size = rel(0.8)),
legend.text.align = NULL,
legend.title = element_text(hjust = 0),
legend.title.align = NULL,
legend.position = "right",
legend.direction = NULL,
legend.justification = "center",
legend.box = NULL,
legend.box.margin = NULL,
legend.box.background = NULL,
legend.box.spacing = NULL,
legend.box.margin = margin(0, 0, 0, 0, "cm"),
legend.box.background = element_blank(),
legend.box.spacing = unit(0.4*spacing, "cm"),

panel.background = element_rect(fill = palette$background, colour = NA),
panel.border = element_blank(),
panel.grid.major = layout$panel.grid.major(colour = palette$gridline),
panel.grid.minor = layout$panel.grid.minor(colour = palette$gridline),
panel.spacing = grid::unit(0.5 * spacing, 'cm'),
panel.spacing = unit(half_line*spacing, "pt"),
panel.spacing.x = NULL,
panel.spacing.y = NULL,
panel.ontop = FALSE,

strip.background = element_rect(
fill = ifelse(inner, 'white', palette$background),
colour = NA),
strip.background = element_rect(fill = ifelse(inner, 'white', palette$background),colour = NA),

strip.text = layout$strip.text(colour=text_colour),
strip.text = element_text(
colour = text_colour,
size = rel(0.8),
margin = margin(half_line*spacing, half_line*spacing, half_line*spacing, half_line*spacing)
),

strip.text.x = element_text(
debug = FALSE,
margin = margin(),
size = rel(1.1),
face = 'bold'),
strip.text.x = NULL,
strip.text.y = element_text(angle = -90),

strip.text.y = element_text(
debug = FALSE,
margin = margin(),
angle = -90,
face = 'bold',
size = rel(1.1)),
strip.placement = "inside",
strip.placement.x = NULL,
strip.placement.y = NULL,

strip.switch.pad.grid = grid::unit(0, 'cm'),
strip.switch.pad.wrap = grid::unit(0, 'cm'),
strip.placement = NULL,
strip.switch.pad.grid = unit(0.1, "cm"),
strip.switch.pad.wrap = unit(0.1, "cm"),

plot.background = element_rect(
colour = ifelse(inner, 'white', palette$background),
fill = ifelse(inner, 'white', palette$background)),

plot.title = element_text(
debug = FALSE,
margin = margin(0.1 * spacing, 0.1 * spacing, 0.1 * spacing, 0.1 * spacing, unit = 'cm'),
size = rel(1.2),
margin = margin(b = half_line * 1.2 * spacing),
hjust = 0,
vjust = spacing,
face = 'bold'),

plot.subtitle = element_text(
debug = FALSE,
margin = margin(0.1 * spacing, 0.1 * spacing, 0.1 * spacing, 0.1 * spacing, unit = 'cm'),
size = rel(1),
size = rel(0.9),
margin = margin(b = half_line * 0.9 * spacing),
hjust = 0,
vjust = spacing),

plot.caption = element_text(
debug = FALSE,
margin = margin(0.1 * spacing, 0.1 * spacing, 0.1 * spacing, 0.1 * spacing, unit = 'cm'),
size = rel(1),
size = rel(0.9),
margin = margin(t = half_line * 0.9 * spacing),
hjust = spacing,
vjust = spacing),

plot.margin = grid::unit(c(0.625, 0.625, 0.625, 0.625) * spacing, 'cm'),
plot.margin = margin(half_line*spacing, half_line*spacing, half_line*spacing, half_line*spacing),

complete = TRUE
)

Expand Down
2 changes: 1 addition & 1 deletion R/ggthemr.R
Expand Up @@ -16,7 +16,7 @@
#' ggthemr('pale', layout = 'scientific', spacing = 2, type = 'inner')
ggthemr <- function(palette = 'dust',
layout = 'clear',
spacing = 1.6,
spacing = 1,
text_size = 12,
type = 'inner',
line_weight = 0.5,
Expand Down
Binary file modified README_files/figure-markdown_github/unnamed-chunk-10-1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-11-1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-12-1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-13-1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-14-1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-15-1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-16-1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-17-1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-18-1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-19-1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-20-1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-21-1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-22-1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-23-1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-24-1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-25-1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-26-1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-27-1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-28-1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-29-1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-30-1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-31-1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-32-1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-33-1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-34-1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-markdown_github/unnamed-chunk-35-1.png
Binary file modified README_files/figure-markdown_github/unnamed-chunk-37-1.png
Binary file modified README_files/figure-markdown_github/unnamed-chunk-38-1.png
Binary file modified README_files/figure-markdown_github/unnamed-chunk-38-2.png
Binary file modified README_files/figure-markdown_github/unnamed-chunk-38-3.png
Binary file modified README_files/figure-markdown_github/unnamed-chunk-38-4.png
Binary file modified README_files/figure-markdown_github/unnamed-chunk-5-1.png
Binary file modified README_files/figure-markdown_github/unnamed-chunk-6-1.png
Binary file modified README_files/figure-markdown_github/unnamed-chunk-7-1.png
Binary file modified README_files/figure-markdown_github/unnamed-chunk-8-1.png
Binary file modified README_files/figure-markdown_github/unnamed-chunk-9-1.png

0 comments on commit 6a81217

Please sign in to comment.