| draw_lines | R Documentation |
This function overlays lines or arrows to a ggplot object based on line data. It supports straight lines, curved lines, gradient color transitions, and one-way or two-way arrows. The data can come from a CSV file generated by the ggsem Shiny app or custom input.
draw_lines(lines_data, zoom_level = 1, n = 100)
lines_data |
A data frame containing line information. The expected columns include:
|
zoom_level |
Numeric. Adjusts the size of line widths and arrowheads relative to the plot. Default is |
n |
Integer. Number of points for interpolation in gradient or curved lines. Default is |
ggplot2 line layers
library(ggplot2)
lines_df <- data.frame(
x_start = 11, y_start = -2.3, x_end = 21, y_end = 3.5,
ctrl_x = NA, ctrl_y = NA, ctrl_x2 = NA, ctrl_y2 = NA,
curvature_magnitude = NA, rotate_curvature = NA,
curvature_asymmetry = NA, type = 'Straight Line',
color = '#000000', end_color = NA, color_type = 'Single',
gradient_position = NA, width = 1, alpha = 1, arrow = TRUE,
arrow_type = 'closed', arrow_size = 0.1, two_way = FALSE,
lavaan = FALSE, network = FALSE, line_style = 'solid',
locked = FALSE, group = 1
)
p <- ggplot()
p + draw_lines(lines_data = lines_df, zoom_level = 1.2, n = 200)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.