ggdiagram

Object-oriented diagram plots with ggplot2

https://github.com/wjschne/ggdiagram

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (13.9%) to scientific vocabulary

Keywords

diagrams factor-analysis ggplot2 path-analysis r s7 structural-equation-modeling
Last synced: 6 months ago · JSON representation

Repository

Object-oriented diagram plots with ggplot2

Basic Info
Statistics
  • Stars: 33
  • Watchers: 2
  • Forks: 0
  • Open Issues: 1
  • Releases: 0
Topics
diagrams factor-analysis ggplot2 path-analysis r s7 structural-equation-modeling
Created over 1 year ago · Last pushed 6 months ago
Metadata Files
Readme Changelog License

README.md

ggdiagram ggdiagram website

Lifecycle:
stable CRAN
status ggdiagram status
badge <!-- badges: end -->

The ggdiagram package takes an object-oriented approach to making diagrams and plots the results using ggplot2.

My motivation in making ggdiagram was to find a way to approach the functionality of TikZ but with the flexibility and convenience of R. The ggdiagram package is built atop S7 and is integrated with ggplot2, making heavy use of ggtext, ggforce, and ggarrow.

The ggdiagram package is not a replacement for the standard ggplot2 functions. The underlying grammar of ggplot2 is well designed for visualizing data. The ggdiagram functions are best suited for creating a small number of visual objects that interrelate. If anything, they can be thought of as extensions of ggplot2::annotate.

Installation

To install the published version from CRAN:

r install.packages("ggdiagram")

You can install the development version of ggdiagram from R-universe like so:

r install.packages("ggdiagram", repos = "https://wjschne.r-universe.dev")

Example

In Figure 1, we create a circle object with ob_circle and a rectangle object with ob_rectangle, placing the rectangle such that there is .5 units of separation between the two objects.

The ggdiagram function is a a wrapper for ggplot, that sets some defaults (e.g., theme_void, coord_equal, fonts, line size, etc.).

The ob_* functions have methods such that they can be added to any ggplot. Under the hood, they are first converted to an appropriate geom and then added to the ggplot object. In this case, an ob_circle is converted to a ggforce:geom_circle, and an ob_rectangle is converted to a ggforce::geom_shape.

The connect function connects the circle and rectangle at their edges with an arrow (drawn with ggarrow::geom_arrow_segment).

``` r library(ggdiagram) c1 <- obcircle(radius = 1 / sqrt(pi)) r2 <- obrectangle() |> place(from = c1, where = "right", sep = .5)

ggdiagram() + c1 + r2 + connect(c1, r2, resect = 1) ```

Figure 1: Connecting a circle and a square with an arrow.

Owner

  • Name: W. Joel Schneider
  • Login: wjschne
  • Kind: user
  • Company: Temple University

Professor in School Psychology and Educational Leadership at Temple University

GitHub Events

Total
  • Issues event: 3
  • Watch event: 19
  • Issue comment event: 1
  • Push event: 32
  • Fork event: 1
Last Year
  • Issues event: 3
  • Watch event: 19
  • Issue comment event: 1
  • Push event: 32
  • Fork event: 1

Packages

  • Total packages: 1
  • Total downloads: unknown
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 1
  • Total maintainers: 1
cran.r-project.org: ggdiagram

Object-Oriented Diagram Plots with 'ggplot2'

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 0 Last month
Rankings
Dependent packages count: 25.7%
Dependent repos count: 31.6%
Average: 47.6%
Downloads: 85.4%
Maintainers (1)
Last synced: 6 months ago

Dependencies

DESCRIPTION cran
  • S7 * imports
  • arrowheadr * imports
  • dplyr * imports
  • ggarrow * imports
  • ggplot2 * imports
  • ggtext * imports
  • glue * imports
  • magrittr * imports
  • purrr * imports
  • rlang * imports
  • tibble * imports
  • tidyr * imports
  • knitr * suggests
  • quarto * suggests
  • rmarkdown * suggests
  • spelling * suggests
  • testthat >= 3.0.0 suggests