draw_loops {ggsem} | R Documentation |
Draw Self-loop Arrows on a ggplot Object
Description
This function overlays self-loop arrows to a ggplot object based on data describing their positions, sizes, orientations, and styles. Self-loop arrows can be drawn in one direction or bidirectionally with customizable parameters such as color, width, and arrow type. The data can come from a CSV file generated by the ggsem Shiny app or custom input.
Usage
draw_loops(p, loops_data, zoom_level = 1)
Arguments
p |
A ggplot object to which the self-loop arrows will be added. |
loops_data |
A data frame containing information about the self-loop arrows. The expected columns include:
|
zoom_level |
Numeric. Adjusts the size of line widths and arrowheads relative to the plot. Default is |
Value
A ggplot object with the specified self-loop arrows added.
Examples
library(ggplot2)
loops_data <- data.frame(
x_center = -5, y_center = 5, radius = 2, color = '#000000', width = 1,
alpha = 1, arrow_type = 'closed', arrow_size = 0.1, gap_size = 0.2,
loop_width = 5, loop_height = 5, orientation = 0,
two_way = FALSE, locked = FALSE
)
p <- ggplot()
draw_loops(p, loops_data, zoom_level = 1.2)