Learn R Programming

ggsem (version 0.9.9)

draw_points: Draw Points on a ggplot Object

Description

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.

Usage

draw_points(points_data, zoom_level = 1)

Value

ggplot2 point layers

Arguments

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

Run this code
library(ggplot2)

points_data <- data.frame(
x = 0, y = 0, shape = 'square', color = '#1262B3', size = 12,
border_color = '#FFFFFF', border_width = 1, alpha = 1,
width_height_ratio = 1.6, orientation = 0,
lavaan = FALSE, network = FALSE, locked = FALSE,
group = 1
)

p <- ggplot()

p + draw_points(points_data, zoom_level = 1.2) +
scale_x_continuous(limits = c(0,50)) +
scale_y_continuous(limits = c(0,50))

Run the code above in your browser using DataLab