knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
fig_path <- if (!(exists("README"))) "../man/figures/" else "man/figures/"
library(ggmnmlab)
library(palmerpenguins)

Example plots

An example of the 8 color palette and theme is shown here, applied to the cell-types data from https://github.com/zachbrehm/celltypes.

ggplot(tsneDf, aes(x = X, y = Y, color = Z, text = Project, alpha = 0.8)) + 
  geom_point() + 
  labs(title = "Cell-type data with dimension reduction by TSNE", 
       x = "First Dimension", 
       y = "Second Dimension", 
       color = "Cell-Type",
       text = rse$study) + 
  guides(alpha = FALSE) + 
  scale_color_mnmlab(palette = "martink8",
                         labels = c("Cardiac Muscle", 
                                   "Endothelial", 
                                   "Erythrocyte", 
                                   "Adipocyte", 
                                   "Lymphocyte", 
                                   "Macrophage", 
                                   "Smooth Muscle"),
                        ) +
  theme_mnmlab()

r knitr::include_graphics(paste0(fig_path, "gg_tsne.png"), error = FALSE)

As another example, we recreate the Bill length vs. depth example from the palmerpenguins article, this time using the high contrast palette from Paul Tol: https://allisonhorst.github.io/palmerpenguins/articles/examples.html

ggplot(
  penguins,
  aes(x = bill_length_mm, y = bill_depth_mm, color = species, group = species)
) +
  geom_point(
    shape = 19, size = 2
  ) +
  geom_smooth(method = "lm", se = FALSE) +
  scale_color_mnmlab(palette = "highContrast") +
  labs(
    title = "Penguin bill dimensions at Palmer Station",
    x = "Bill length (mm)", y = "Bill depth (mm)", color = "Species"
  ) +
  theme_mnmlab()

r knitr::include_graphics(paste0(fig_path, "penguins.png"), error = FALSE)



zachbrehm/ggmnmlab documentation built on Dec. 23, 2021, 9:11 p.m.