barplot_theme <- function (base_size = 16, base_family = "")
## Generic theme
{
half_line <- base_size/2
theme(line = element_line(colour = "#333333", size = 0.5, linetype = 1, lineend = "butt"),
rect = element_rect(fill = "white", colour = "black", size = 0.5, linetype = 1),
text = element_text(family = base_family, face = "plain", colour = "#222222", size = base_size,
lineheight = 0.9, hjust = 0.5, vjust = 0.5, angle = 0, margin = margin(),
debug = F),
## axis.line.x = element_line(color="#333333", size = 1),
## axis.line.y = element_line(color="#cccccc", size = 0.4),
axis.text.x = element_text(margin = margin(t = 0.8 * half_line/2), vjust = 1),
axis.text.x.top = element_text(margin = margin(b = 0.8 * half_line/2), vjust = 0),
axis.text.y = element_text(margin = margin(r = 0.8 * half_line/2), hjust = 1),
axis.text.y.right = element_text(margin = margin(l = 0.8 * half_line/2), hjust = 0),
## axis.ticks.x = element_line(color="#333333", size = 1), #adding ticks to x
## axis.ticks.y = element_line(color="#cccccc", size = 0.4), #adding ticks to y
## RC> I think the style is to have the ticks match the gridlines on the top
## RC> and not to have any on the left
## axis.ticks.x = element_blank(),
axis.ticks.y = element_blank(),
axis.ticks.x = element_line(colour = "#cccccc", size=.35),
axis.ticks.length = unit(8, "pt"), # adding ticks lenght
# axis.ticks.length = unit(half_line/2, "pt"),
axis.title.x = element_text(margin = margin(t = half_line), vjust = 1),
axis.title.x.top = element_text(margin = margin(b = half_line), vjust = 0),
axis.title.y = element_text(angle = 90, margin = margin(r = half_line), vjust = 1), # change angle to see it diffently - deleted hjust to center title of y axes
axis.title.y.right = element_text(angle = 90, margin = margin(l = half_line), vjust = 0, hjust = -1),
legend.background = element_blank(),
legend.spacing = unit(0, "cm"), legend.spacing.x = NULL,
legend.spacing.y = NULL,
## legend.margin = margin(0.2, 0.2, 0.2, 0.2, "cm"),
# legend.key = element_rect(fill = "grey95", colour = "white"),
legend.key = element_blank(),
legend.key.size = unit(0.5, "lines"),
legend.key.height = NULL, legend.key.width = unit(2, "lines"),
legend.text = element_text(size = rel(0.8)),
legend.text.align = NULL, legend.title = element_text(hjust = 0),
legend.title.align = NULL,
legend.position = "top",
legend.direction = NULL, legend.justification = "left",
legend.box = NULL,
legend.box.margin = margin(0, 0, 0, 0, "cm"),
legend.box.background = element_blank(),
legend.box.spacing = unit(0.4, "cm"),
panel.background = element_blank(),
panel.border = element_blank(),
panel.grid.major.y = element_blank(), #deleted what is now in x because I flipped the chart
panel.grid.minor.y = element_blank(), #deleted what is now in x because I flipped the chart
panel.grid.major.x = element_line(colour = "#cbcbcb", size=0.35), #adding x axis lines to panel and plot - increased size for better visibility
panel.grid.minor.x = element_line(colour = "#cbcbcb", size=0.35), #adding x axis lines to panel and plot - increased size for better visibility
panel.spacing = unit(half_line, "pt"), panel.spacing.x = NULL,
panel.spacing.y = NULL, panel.ontop = FALSE,
strip.background = element_rect(fill = "grey85", colour = NA),
strip.text = element_text(colour = "grey10", size = rel(0.8)),
strip.text.x = element_text(margin = margin(t = half_line, b = half_line)),
strip.text.y = element_text(angle = -90, margin = margin(l = half_line, r = half_line)),
strip.placement = "inside",
strip.placement.x = NULL, strip.placement.y = NULL, strip.switch.pad.grid = unit(0.1, "cm"),
strip.switch.pad.wrap = unit(0.1, "cm"),
plot.background = element_rect(colour = "white"),
plot.title = element_text(size = 26, hjust = 0, vjust = 1, face="bold", family="Helvetica",
margin = margin(l=half_line*10, b = half_line * 1.25)),
plot.subtitle = element_text(size = 20, family="Helvetica", hjust = 0, vjust = 1,
margin = margin(b = half_line * 1.125)),
plot.caption = element_text(size = 14, hjust = 0, vjust = 1, margin = margin(t = half_line * 2)),
plot.margin = margin(half_line, half_line, half_line, half_line), complete = TRUE)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.