Line (Color Dot)

Authors

[Editor] Hu Zheng;

[Contributors]

Note

Hiplot website

This page is the tutorial for source code version of the Hiplot Line (Color Dot) plugin. You can also use the Hiplot website to achieve no code ploting. For more information please see the following link:

https://hiplot.cn/basic/line-color-dot?lang=en

Setup

  • System Requirements: Cross-platform (Linux/MacOS/Windows)

  • Programming language: R

  • Dependent packages: grafify

# Install packages
if (!requireNamespace("grafify", quietly = TRUE)) {
  install.packages("grafify")
}

# Load packages
library(grafify)

Data Preparation

# Load data
data <- read.delim("files/Hiplot/092-line-color-dot-data.txt", header = T)

# Convert data structure
x <- "Time"
y <- "PI"
group <- "Experiment"
facet <- "Genotype"
data[, x] <- factor(data[, x], levels = unique(data[, x]))
data[, group] <- factor(data[, group], levels = unique(data[, group]))
data[, facet] <- factor(data[, facet], levels = unique(data[, facet]))

# View data
head(data)
  Experiment Time Subject Genotype       PI Time2
1         e1 t100      s1       WT 20.47120   100
2         e2 t100      s2       WT 28.88967   100
3         e3 t100      s3       WT 11.55061   100
4         e4 t100      s4       WT 23.24516   100
5         e5 t100      s5       WT 30.20904   100
6         e6 t100      s6       WT 28.68300   100

Visualization

# Line (Color Dot)
p <- plot_befafter_colours(
  data = data, xcol = get(x), ycol = get(y), match = get(group),
  symsize = 5, symthick = 1, s_alpha = 1) +
  facet_wrap(facet) +
  guides(fill = guide_legend(title = group)) +
  scale_fill_grafify() +
  xlab(x) + ylab(y) +
  ggtitle("Two-way repeated measures") +
  theme(text = element_text(family = "Arial"),
        plot.title = element_text(size = 12, hjust = 0.5),
        axis.title = element_text(size = 12),
        axis.text = element_text(size = 10),
        axis.text.x = element_text(angle = 0, hjust = 0.5,vjust = 1),
        legend.position = "right",
        legend.direction = "vertical",
        legend.title = element_text(size = 10),
        legend.text = element_text(size = 10))

p
FigureΒ 1: Line (Color Dot)