This function overlays points to a ggplot object using data from a CSV file generated by the ggsem Shiny app or any custom dataset. Points can be styled with various shapes, colors, sizes, and orientations.
Arguments
- p
A ggplot object to which the points will be added.
- points_data
A data frame containing information about the points to be drawn. The expected columns include:
x
,y
: Coordinates of the point.shape
: Shape of the point ("circle"
,"square"
,"triangle"
,"rectangle"
,"oval"
, or"diamond"
).color
: Fill color of the point (hexadecimal color code).size
: Size of the point.border_color
: Border color of the point (hexadecimal color code).border_width
: Width of the border.alpha
: Transparency of the point (numeric, 0 to 1).width_height_ratio
: Ratio of width to height (for shapes like rectangles and ovals).orientation
: Rotation angle of the point in degrees (for shapes like rectangles and diamonds).
- zoom_level
Numeric. Adjusts the size of the points relative to the plot. Default is
1
.
Examples
library(ggplot2)
points_data <- data.frame(
x = 20, y = 20, shape = 'rectangle', color = '#D0C5ED', size = 50,
border_color = '#9646D4', border_width = 2, alpha = 1, width_height_ratio = 1.6, orientation = 45,
lavaan = FALSE, lavaan = FALSE, network = FALSE, locked = FALSE
)
p <- ggplot()
draw_points(p, points_data, zoom_level = 1.2) +
scale_x_continuous(limits = c(0,50)) +
scale_y_continuous(limits = c(0,50))