Title: | Object-Oriented Diagram Plots with ggplot2 |
---|---|
Description: | The ggdiagram package creates path diagrams with an object-oriented approach and plots diagrams with ggplot2. |
Authors: | W. Joel Schneider [aut, cre] |
Maintainer: | W. Joel Schneider <[email protected]> |
License: | CC0 |
Version: | 0.0.0.9000 |
Built: | 2025-02-03 23:29:21 UTC |
Source: | https://github.com/wjschne/ggdiagram |
Converts a ggdiagram shape to a ggplot2 geom
as.geom(x, ...)
as.geom(x, ...)
x |
a shape |
... |
< |
Usually the as.geom
function is not necessary to call explicitly because it is called whenever a ggdiagram shape is added to a ggplot. However, in complex situations (e.g., making a function that assembles many objects), it is sometimes necessary to make the call explicitly.
geom
library(ggplot2) c1 <- ob_circle(radius = 3) ggplot() + as.geom(c1, fill = "black") + coord_equal()
library(ggplot2) c1 <- ob_circle(radius = 3) ggplot() + as.geom(c1, fill = "black") + coord_equal()
bind method
bind(x, ...)
bind(x, ...)
x |
list of objects to bind |
... |
< |
a bound object of same class as x (or list of objects if x contains objects of different types)
bind(c(ob_point(1,2), ob_point(3,4))) bind(c(ob_circle(ob_point(0,0), radius = 1), ob_circle(ob_point(1,1), radius = 2)))
bind(c(ob_point(1,2), ob_point(3,4))) bind(c(ob_circle(ob_point(0,0), radius = 1), ob_circle(ob_point(1,1), radius = 2)))
Get a circle from 3 points
circle_from_3_points(p1, p2 = NULL, p3 = NULL, ...)
circle_from_3_points(p1, p2 = NULL, p3 = NULL, ...)
p1 |
an ob_point of length 1 or length 3 |
p2 |
an ob_point of length 1 or NULL |
p3 |
an ob_point of length 1 or NULL |
ob_point object
p1 <- ob_point(1,1) p2 <- ob_point(2,4) p3 <- ob_point(5,3) circle_from_3_points(p1,p2, p3)
p1 <- ob_point(1,1) p2 <- ob_point(2,4) p3 <- ob_point(5,3) circle_from_3_points(p1,p2, p3)
color class
class_color( color = character(0), hue = NULL, saturation = NULL, brightness = NULL, alpha = NULL )
class_color( color = character(0), hue = NULL, saturation = NULL, brightness = NULL, alpha = NULL )
color |
character (R color or hex code) |
hue |
get or set the hue of a color (i.e., the h in the hsv model) |
saturation |
get or set the saturation of a color (i.e., the s in the hsv model) |
brightness |
get or set the brightness of a color (i.e., the v in the hsv model) |
alpha |
get or set the transparency of a color |
class_color object
transparentize
function to return the color with a new transparency (i.e., alpha)
lighten
function to return a lighter color
darken
function to return a darker color
mycolor <- class_color("blue") mycolor # Display html hexcode c(mycolor) # Set transparency mycolor@transparentize(.5) # Lighten color mycolor@lighten(.5) # Darken color mycolor@darken(.5)
mycolor <- class_color("blue") mycolor # Display html hexcode c(mycolor) # Set transparency mycolor@transparentize(.5) # Lighten color mycolor@lighten(.5) # Darken color mycolor@darken(.5)
Arrow connect one shape to another
connect(x, y, ...)
connect(x, y, ...)
x |
first shape object |
y |
second shape object |
... |
< |
ob_segment
Calculate distance between 2 points
distance(x, y, ...)
distance(x, y, ...)
x |
a point, line, segment, or circle object |
y |
a point, line, or circle object |
... |
< |
numeric
# Distance between two objects p1 <- ob_point(0, 0) p2 <- ob_point(3, 4) distance(p1, p2) # Distance between the endpoints of a segment s1 <- ob_segment(p1, p2) distance(s1) # Distance between a point and a line l1 <- ob_line(slope = 0, intercept = 1) distance(p1, l1) # Shortest distance between the edges of 2 circles c1 <- ob_circle(p1, radius = 1) c2 <- ob_circle(p2, radius = 2) distance(c1, c2)
# Distance between two objects p1 <- ob_point(0, 0) p2 <- ob_point(3, 4) distance(p1, p2) # Distance between the endpoints of a segment s1 <- ob_segment(p1, p2) distance(s1) # Distance between a point and a line l1 <- ob_line(slope = 0, intercept = 1) distance(p1, l1) # Shortest distance between the edges of 2 circles c1 <- ob_circle(p1, radius = 1) c2 <- ob_circle(p2, radius = 2) distance(c1, c2)
Get equation for object
equation(x, type = c("y", "general", "parametric"), digits = 2)
equation(x, type = c("y", "general", "parametric"), digits = 2)
x |
object |
type |
equation type. Can be |
digits |
rounding digits |
string
Get object data with styles in a tibble
Get object data in a tibble, filling in any missing styles with defaults
get_tibble(x) get_tibble_defaults(x)
get_tibble(x) get_tibble_defaults(x)
x |
object |
a tibble
tibble
This is a convenient way to specify geom defaults
ggdiagram( font_family = "sans", font_size = 11, linewidth = 0.5, point_size = 1.5, rect_linewidth = linewidth, theme_function = ggplot2::theme_void, ... )
ggdiagram( font_family = "sans", font_size = 11, linewidth = 0.5, point_size = 1.5, rect_linewidth = linewidth, theme_function = ggplot2::theme_void, ... )
font_family |
font family |
font_size |
font size in points |
linewidth |
line width |
point_size |
point size |
rect_linewidth |
line with of rectangles |
theme_function |
ggplot2 theme |
... |
< |
ggplot function
ggdiagram() + ob_circle()
ggdiagram() + ob_circle()
is an ob_point inside a shape ?
inside(x, y)
inside(x, y)
x |
object |
y |
object |
logical
intersection of 2 objects (e.g., lines)
intersection(x, y, ...)
intersection(x, y, ...)
x |
object |
y |
object |
... |
< |
shape object
Compute the angle of the intersection of two objects
intersection_angle(x, y)
intersection_angle(x, y)
x |
an object (point, segment, line) |
y |
an object (point, segment, line) |
ob_angle object
Automatic label for objects
label_object(object, ...)
label_object(object, ...)
object |
object |
... |
< |
string
Surround TeX expression with a color command
latex_color(x, color)
latex_color(x, color)
x |
TeX expression |
color |
color |
string
latex_color("X^2", "red")
latex_color("X^2", "red")
A wrapper for purrr::map. It takes a ggdiagram object with multiple elements, applies a function to each element within the object, and returns a ggdiagram object
map_ob(.x, .f, ..., .progress = FALSE)
map_ob(.x, .f, ..., .progress = FALSE)
.x |
a ggdiagram object |
.f |
a function that returns a ggdiagram object |
... |
< |
.progress |
display progress if TRUE |
a ggdiagram object
Average across colors
mean_color(x)
mean_color(x)
x |
color |
string
mean_color(c("red", "violet"))
mean_color(c("red", "violet"))
It is possible to get more than one midpoint by specifying a position vector with a length greater than 1. Position values outside 0 and 1 will usually work, but will be outside the object.
midpoint(x, y, position = 0.5, ...)
midpoint(x, y, position = 0.5, ...)
x |
object |
y |
object (can be omitted for segments and arcs) |
position |
numeric vector. 0 is start, 1 is end. Defaults to .5 |
... |
< |
ob_point
Move an object
nudge(object, x, y, ...)
nudge(object, x, y, ...)
object |
object |
x |
nudge right and left |
y |
nudge up and down |
... |
< |
object of same class as object
ob_circle() |> nudge(x = 2) # Alternative to nudge: ob_circle() + ob_point(2, 0)
ob_circle() |> nudge(x = 2) # Alternative to nudge: ob_circle() + ob_point(2, 0)
Creates an angle in the metric of radians, degrees, and turns.
ob_angle( .data = numeric(0), degree = integer(0), radian = integer(0), turn = integer(0) ) degree(degree = numeric(0)) radian(radian = numeric(0)) turn(turn = numeric(0))
ob_angle( .data = numeric(0), degree = integer(0), radian = integer(0), turn = integer(0) ) degree(degree = numeric(0)) radian(radian = numeric(0)) turn(turn = numeric(0))
.data |
a real number indicating the number of turns. |
degree |
degrees |
radian |
radians |
turn |
proportion of full turns of a circle (1 turn = 2 * pi radians) |
positive |
if angle is negative, adds a full turn to ensure the angle is positive |
negative |
if angle is positive, subtracts a full turn to ensure the angle is negative |
Angles turns can be any real number, but degrees are displayed as values between -360 and +360, and radians are between -2pi and +2pi.
ob_angle
# Three Different ways to make a right angle ## 90 degrees degree(90) ## half pi radians radian(.5 * pi) ## A quarter turn turn(.25) # Operations degree(30) + degree(20) degree(350) + degree(20) degree(30) - degree(30) degree(30) - degree(50) degree(30) * 2 degree(30) / 3 radian(1) + 1 # added or subtracted numbers are radians degree(10) + 10 # added or subtracted numbers are degrees turn(.25) + .25 # added or subtracted numbers are turns # Trigonometric functions work as normal sin(degree(30)) cos(degree(30)) tan(degree(30))
# Three Different ways to make a right angle ## 90 degrees degree(90) ## half pi radians radian(.5 * pi) ## A quarter turn turn(.25) # Operations degree(30) + degree(20) degree(350) + degree(20) degree(30) - degree(30) degree(30) - degree(50) degree(30) * 2 degree(30) / 3 radian(1) + 1 # added or subtracted numbers are radians degree(10) + 10 # added or subtracted numbers are degrees turn(.25) + .25 # added or subtracted numbers are turns # Trigonometric functions work as normal sin(degree(30)) cos(degree(30)) tan(degree(30))
Create arcs and wedges
ob_arc( center = ob_point(0, 0), radius = 1, start = 0, end = 0, label = character(0), start_point = S7::class_missing, end_point = S7::class_missing, n = 360, type = "arc", alpha = numeric(0), arrow_head = list(), arrow_fins = list(), arrowhead_length = numeric(0), length_head = numeric(0), length_fins = numeric(0), color = character(0), fill = character(0), lineend = numeric(0), linejoin = numeric(0), linewidth = numeric(0), linewidth_fins = numeric(0), linewidth_head = numeric(0), linetype = numeric(0), resect = numeric(0), resect_fins = numeric(0), resect_head = numeric(0), stroke_color = character(0), stroke_width = numeric(0), style = S7::class_missing, x0 = numeric(0), y0 = numeric(0), ... ) ob_wedge( center = ob_point(0, 0), radius = 1, start = 0, end = 0, label = character(0), start_point = S7::class_missing, end_point = S7::class_missing, n = 360, type = "wedge", alpha = numeric(0), arrow_head = list(), arrow_fins = list(), arrowhead_length = numeric(0), length_head = numeric(0), length_fins = numeric(0), color = NA, fill = "black", lineend = numeric(0), linejoin = numeric(0), linewidth = numeric(0), linewidth_fins = numeric(0), linewidth_head = numeric(0), linetype = numeric(0), resect = numeric(0), resect_fins = numeric(0), resect_head = numeric(0), stroke_color = character(0), stroke_width = numeric(0), style = S7::class_missing, x0 = numeric(0), y0 = numeric(0), ... ) ob_circular_segment( center = ob_point(0, 0), radius = 1, start = 0, end = 0, label = character(0), start_point = S7::class_missing, end_point = S7::class_missing, n = 360, type = "segment", alpha = numeric(0), arrow_head = list(), arrow_fins = list(), arrowhead_length = numeric(0), length_head = numeric(0), length_fins = numeric(0), color = NA, fill = "black", lineend = numeric(0), linejoin = numeric(0), linewidth = numeric(0), linewidth_fins = numeric(0), linewidth_head = numeric(0), linetype = numeric(0), resect = numeric(0), resect_fins = numeric(0), resect_head = numeric(0), stroke_color = character(0), stroke_width = numeric(0), style = S7::class_missing, x0 = numeric(0), y0 = numeric(0), ... )
ob_arc( center = ob_point(0, 0), radius = 1, start = 0, end = 0, label = character(0), start_point = S7::class_missing, end_point = S7::class_missing, n = 360, type = "arc", alpha = numeric(0), arrow_head = list(), arrow_fins = list(), arrowhead_length = numeric(0), length_head = numeric(0), length_fins = numeric(0), color = character(0), fill = character(0), lineend = numeric(0), linejoin = numeric(0), linewidth = numeric(0), linewidth_fins = numeric(0), linewidth_head = numeric(0), linetype = numeric(0), resect = numeric(0), resect_fins = numeric(0), resect_head = numeric(0), stroke_color = character(0), stroke_width = numeric(0), style = S7::class_missing, x0 = numeric(0), y0 = numeric(0), ... ) ob_wedge( center = ob_point(0, 0), radius = 1, start = 0, end = 0, label = character(0), start_point = S7::class_missing, end_point = S7::class_missing, n = 360, type = "wedge", alpha = numeric(0), arrow_head = list(), arrow_fins = list(), arrowhead_length = numeric(0), length_head = numeric(0), length_fins = numeric(0), color = NA, fill = "black", lineend = numeric(0), linejoin = numeric(0), linewidth = numeric(0), linewidth_fins = numeric(0), linewidth_head = numeric(0), linetype = numeric(0), resect = numeric(0), resect_fins = numeric(0), resect_head = numeric(0), stroke_color = character(0), stroke_width = numeric(0), style = S7::class_missing, x0 = numeric(0), y0 = numeric(0), ... ) ob_circular_segment( center = ob_point(0, 0), radius = 1, start = 0, end = 0, label = character(0), start_point = S7::class_missing, end_point = S7::class_missing, n = 360, type = "segment", alpha = numeric(0), arrow_head = list(), arrow_fins = list(), arrowhead_length = numeric(0), length_head = numeric(0), length_fins = numeric(0), color = NA, fill = "black", lineend = numeric(0), linejoin = numeric(0), linewidth = numeric(0), linewidth_fins = numeric(0), linewidth_head = numeric(0), linetype = numeric(0), resect = numeric(0), resect_fins = numeric(0), resect_head = numeric(0), stroke_color = character(0), stroke_width = numeric(0), style = S7::class_missing, x0 = numeric(0), y0 = numeric(0), ... )
center |
point at center of the arc (default = ob_point(0,0)) |
radius |
distance between center and edge arc (default = 1) |
start |
start angle (default = 0 degrees) |
end |
end angle (default = 0 degrees) |
label |
A character, angle, or label object |
start_point |
Specify where arc starts. Overrides |
end_point |
Specify where arc ends Overrides |
n |
number of points in arc (default = 360) |
type |
Type of object to drawn. Can be "arc", "wedge", or "segment" |
alpha |
numeric value for alpha transparency |
arrow_head |
A 2-column matrix of polygon points |
arrow_fins |
A 2-column matrix of polygon points |
arrowhead_length |
Determines the size of the arrow ornaments. This parameter becomes the |
length_head |
Determines the size of the arrow head. Numeric values set the ornament size relative to the linewidth. A unit value sets the ornament size in an absolute manner. From ggarrow. |
length_fins |
Determines the size of the arrow fins. Numeric values set the ornament size relative to the linewidth. A unit value sets the ornament size in an absolute manner. From ggarrow. |
color |
character string for color |
fill |
character string for fill color |
lineend |
Line end style (round, butt, square). |
linejoin |
Line join style (round, mitre, bevel). |
linewidth |
Width of lines |
linewidth_fins |
Line width for arrow fins |
linewidth_head |
Line width for arrow fins |
linetype |
type of lines |
resect |
A numeric(1) denoting millimeters or |
resect_fins |
A numeric(1) denoting millimeters or |
resect_head |
A numeric(1) denoting millimeters or |
stroke_color |
Color of point border line |
stroke_width |
Stroke width in arrows |
style |
a style object |
x0 |
x-coordinate of center point. If specified, overrides x-coordinate of |
y0 |
x-coordinate of center point. If specified, overrides y-coordinate of |
... |
< |
ob_arc object
aesthetics
A list of information about the arc's aesthetic properties
angle_at
A function that finds the angle of the specified point in relation to the arc's center
apothem
Distance from center to the chord's midpoint
arc_length
Distance along arc from start_point
to end_point
auto_label
Places a label at the arc's midpoint
chord
ob_segment
from start_point
to end_point
geom
A function that converts the object to a geom. Any additional parameters are passed to ggarrow::geom_arrow
.
hatch
A function that puts hatch (tally) marks on arcs. Often used to indicate which arcs have the same angle. The k
parameter controls how many hatch marks to display. The height
parameter controls how long the hatch mark segment is. The sep
parameter controls the separation between hatch marks when k > 2
. Additional parameters sent to ob_segment
.
length
The number of arcs in the arc object
midpoint
A function that selects 1 or more midpoints of the ob_arc. The position
argument can be between 0 and 1. Additional arguments are passed to ob_point
.
point_at
A function that finds a point on the arc at the specified angle.
sagitta
ob_segment
from chord
midpoint to ob_arc
midpoint
tangent_at
A function that finds the tangent line at the specified angle.
theta
interior angle (end - start)
tibble
Gets a tibble (data.frame) containing parameters and styles used by ggarrow::geom_arrow
.
library(ggplot2) # center point p_center <- ob_point(0,0) # 90-degree arc a_90 <- ob_arc( center = p_center, radius = 6, start = degree(0), end = degree(90) ) # Print arc a_90 # Plot arc and its center point ggplot() + coord_equal() + theme_minimal() + p_center + a_90
library(ggplot2) # center point p_center <- ob_point(0,0) # 90-degree arc a_90 <- ob_arc( center = p_center, radius = 6, start = degree(0), end = degree(90) ) # Print arc a_90 # Plot arc and its center point ggplot() + coord_equal() + theme_minimal() + p_center + a_90
make an array of shapes along a line
ob_array(x, k = 2, sep = 1, where = "east", anchor = "center", ...)
ob_array(x, k = 2, sep = 1, where = "east", anchor = "center", ...)
x |
shape |
k |
number of duplicate shapes to make |
sep |
separation distance between shapes |
where |
angle or named direction (e.g.,northwest, east, below, left) |
anchor |
bounding box anchor |
... |
< |
An array of shapes of the same class as object passed to x
The ob_bezier is specified with an ob_point object that contains at least 2 points, the start and the end. Such a "curve" would actually be a straight line segment. If three points are specified, the middle point is a control point, and a quadratic bezier curve will result. Higher-order bezier curves can be created by having more control points in the middle.
ob_bezier( p = S7::class_missing, label = character(0), label_sloped = TRUE, n = 360, alpha = numeric(0), arrow_head = S7::class_missing, arrow_fins = S7::class_missing, arrowhead_length = numeric(0), length_head = numeric(0), length_fins = numeric(0), color = character(0), fill = character(0), lineend = numeric(0), linejoin = numeric(0), linewidth = numeric(0), linewidth_fins = numeric(0), linewidth_head = numeric(0), linetype = numeric(0), resect = numeric(0), resect_fins = numeric(0), resect_head = numeric(0), stroke_color = character(0), stroke_width = numeric(0), style = S7::class_missing, ... )
ob_bezier( p = S7::class_missing, label = character(0), label_sloped = TRUE, n = 360, alpha = numeric(0), arrow_head = S7::class_missing, arrow_fins = S7::class_missing, arrowhead_length = numeric(0), length_head = numeric(0), length_fins = numeric(0), color = character(0), fill = character(0), lineend = numeric(0), linejoin = numeric(0), linewidth = numeric(0), linewidth_fins = numeric(0), linewidth_head = numeric(0), linetype = numeric(0), resect = numeric(0), resect_fins = numeric(0), resect_head = numeric(0), stroke_color = character(0), stroke_width = numeric(0), style = S7::class_missing, ... )
p |
ob_point or list of ob_points |
label |
A character, angle, or label object |
label_sloped |
A logical value indicating whether the label should be sloped with the curve |
n |
Number of points in a polygon, circle, arc, or ellipse |
alpha |
numeric value for alpha transparency |
arrow_head |
A 2-column matrix of polygon points |
arrow_fins |
A 2-column matrix of polygon points |
arrowhead_length |
Determines the size of the arrow ornaments. This parameter becomes the |
length_head |
Determines the size of the arrow head. Numeric values set the ornament size relative to the linewidth. A unit value sets the ornament size in an absolute manner. From ggarrow. |
length_fins |
Determines the size of the arrow fins. Numeric values set the ornament size relative to the linewidth. A unit value sets the ornament size in an absolute manner. From ggarrow. |
color |
character string for color |
fill |
character string for fill color |
lineend |
Line end style (round, butt, square). |
linejoin |
Line join style (round, mitre, bevel). |
linewidth |
Width of lines |
linewidth_fins |
Line width for arrow fins |
linewidth_head |
Line width for arrow fins |
linetype |
type of lines |
resect |
A numeric(1) denoting millimeters or |
resect_fins |
A numeric(1) denoting millimeters or |
resect_head |
A numeric(1) denoting millimeters or |
stroke_color |
Color of point border line |
stroke_width |
Stroke width in arrows |
style |
Gets and sets the styles associated with ob_beziers |
... |
< |
If you wish to specify multiple bezier curves, you must supply a list of ob_point objects. When plotted, the ob_bezier function uses the bezier::bezier function to create the point coordinates of the curve and the ggarrow::geom_arrow function to create the geom.
ob_bezier object
length
The number of curves in the ob_bezier object
tibble
Gets a tibble (data.frame) containing parameters and styles used by ggarrow::geom_arrow
.
geom
A function that converts the object to a geom. Any additional parameters are passed to ggarrow::geom_arrow
.
midpoint
A function that selects 1 or more midpoints of the ob_bezier. The position
argument can be between 0 and 1. Additional arguments are passed to ob_point
.
aesthetics
A list of information about the ob_bezier's aesthetic properties
library(ggplot2) control_points <- ob_point(c(0,1,2,4), c(0,4,0,0)) ggplot() + coord_equal() + ob_bezier(control_points, color = "blue") + ob_path(control_points, linetype = "dashed", linewidth = .5) + control_points
library(ggplot2) control_points <- ob_point(c(0,1,2,4), c(0,4,0,0)) ggplot() + coord_equal() + ob_bezier(control_points, color = "blue") + ob_path(control_points, linetype = "dashed", linewidth = .5) + control_points
ob_circle class
ob_circle( center = ob_point(0, 0), radius = 1, label = character(0), alpha = numeric(0), color = character(0), fill = character(0), linewidth = numeric(0), linetype = numeric(0), n = numeric(0), style = S7::class_missing, x0 = numeric(0), y0 = numeric(0), ... )
ob_circle( center = ob_point(0, 0), radius = 1, label = character(0), alpha = numeric(0), color = character(0), fill = character(0), linewidth = numeric(0), linetype = numeric(0), n = numeric(0), style = S7::class_missing, x0 = numeric(0), y0 = numeric(0), ... )
center |
point at center of the circle |
radius |
distance between center and edge circle |
label |
A character, angle, or label object |
alpha |
numeric value for alpha transparency |
color |
character string for color |
fill |
character string for fill color |
linewidth |
Width of lines |
linetype |
type of lines |
n |
number of points in circle (default = 360) |
style |
an ob_style object |
x0 |
x-coordinate of center point. If specified, overrides x-coordinate of |
y0 |
x-coordinate of center point. If specified, overrides y-coordinate of |
... |
< |
ob_circle object
aesthetics
A list of information about the circle's aesthetic properties
angle_at
A function that finds the angle of the specified point in relation to the circle's center
area
area of the circle
bounding_box
a rectangle that contains all the circles
circumference
circumference of the circle
geom
A function that converts the object to a geom. Any additional parameters are passed to ggforce::geom_circle
.
length
The number of circles in the circle object
normal_at
A function that finds a point that is perpendicular from the circle and at a specified distance
point_at
A function that finds a point on the circle at the specified angle.
polygon
a tibble containing information to create all the polygon points in a circle.
tangent_at
A function that finds the tangent line at the specified angle.
tibble
Gets a tibble (data.frame) containing parameters and styles used by ggforce::geom_cirlce
.
# specify center point and radius p <- ob_point(0,0) ob_circle(p, radius = 6)
# specify center point and radius p <- ob_point(0,0) ob_circle(p, radius = 6)
create double-headed arrow paths indicating variance
ob_covariance( x, y, where = NULL, bend = 0, looseness = 1, arrow_head = arrowheadr::arrow_head_deltoid(d = 2.3, n = 100), resect = 2, ... )
ob_covariance( x, y, where = NULL, bend = 0, looseness = 1, arrow_head = arrowheadr::arrow_head_deltoid(d = 2.3, n = 100), resect = 2, ... )
x |
object |
y |
object |
where |
exit angle |
bend |
Angle by which the control points are rotated |
looseness |
distance of control points as a ratio of the distance to the object's center (e.g., in a circle of radius 1, looseness = 1.5 means that that the control points will be 1.5 units from the start and end points.) |
arrow_head |
A 2-column matrix of polygon points |
resect |
A numeric(1) denoting millimeters or |
... |
< |
An ob_bezier
object
Makes ellipses and superellipses
ob_ellipse( center = ob_point(0, 0), a = 1, b = a, angle = 0, m1 = numeric(0), m2 = numeric(0), label = character(0), alpha = numeric(0), color = character(0), fill = character(0), linewidth = numeric(0), linetype = numeric(0), n = numeric(0), style = S7::class_missing, x0 = numeric(0), y0 = numeric(0), ... )
ob_ellipse( center = ob_point(0, 0), a = 1, b = a, angle = 0, m1 = numeric(0), m2 = numeric(0), label = character(0), alpha = numeric(0), color = character(0), fill = character(0), linewidth = numeric(0), linetype = numeric(0), n = numeric(0), style = S7::class_missing, x0 = numeric(0), y0 = numeric(0), ... )
center |
point at center of ellipse. Settable. |
a |
distance of semi-major axis. Settable. |
b |
distance of semi-minor axis. Settable. |
angle |
ellipse rotation. Settable. |
m1 |
exponent of semi-major axis. Settable. Controls roundedness of superellipse |
m2 |
exponent of semi-minor axis. Settable. By default equal to |
label |
A character, angle, or label object |
alpha |
numeric value for alpha transparency |
color |
character string for color |
fill |
character string for fill color |
linewidth |
Width of lines |
linetype |
type of lines |
n |
number of points in ellipse (default = 360). Settable. |
style |
gets and sets style parameters |
x0 |
x-coordinate of center point. If specified, overrides x-coordinate of |
y0 |
x-coordinate of center point. If specified, overrides y-coordinate of |
... |
< |
ob_ellipse object
length
Gets the number of ellipses
tibble
Gets a tibble (data.frame) containing parameters and styles used by ggforce::geom_ellipse
.
geom
A function that converts the object to a geom. Any additional parameters are passed to ggforce::geom_ellipse
.
normal_at
A function that finds a point perpendicular to the ellipse at angle theta
at the specified distance
. The definitional
parameter is passed to the point_at
function. If a point is supplied instead of an angle, the point is projected onto the ellipse and then the normal is calculated found from the projected point.
point_at
A function that finds a point on the ellipse at an angle theta
. If definitional
is FALSE
(default), then theta
is interpreted as an angle. If TRUE
, then theta
is the parameter in the definition of the ellipse in polar coordinates.
tangent_at
A function that finds a tangent line on the ellipse. Uses point_at
to find the tangent point at angle theta
and then returns the tangent line at that point. If a point is supplied instead of an angle, the point is projected onto the ellipse and then the tangent line is found from there.
# specify center point and semi-major axes p <- ob_point(0,0) ob_ellipse(p, a = 2, b = 3)
# specify center point and semi-major axes p <- ob_point(0,0) ob_ellipse(p, a = 2, b = 3)
Triangle polygons used in path diagrams.
ob_intercept( center = ob_point(0, 0), width = 1, label = character(0), top = S7::class_missing, left = S7::class_missing, right = S7::class_missing, vertex_radius = numeric(0), alpha = numeric(0), color = character(0), fill = character(0), linewidth = numeric(0), linetype = numeric(0), x0 = numeric(0), y0 = numeric(0), style = S7::class_missing, ... )
ob_intercept( center = ob_point(0, 0), width = 1, label = character(0), top = S7::class_missing, left = S7::class_missing, right = S7::class_missing, vertex_radius = numeric(0), alpha = numeric(0), color = character(0), fill = character(0), linewidth = numeric(0), linetype = numeric(0), x0 = numeric(0), y0 = numeric(0), style = S7::class_missing, ... )
center |
point at center |
width |
length of side |
label |
A character, angle, or label object |
top |
Top vertex of triangle |
left |
Left vertex of triangle |
right |
Right vertex of triangle |
vertex_radius |
A numeric or unit vector of length one, specifying the vertex radius |
alpha |
numeric value for alpha transparency |
color |
character string for color |
fill |
character string for fill color |
linewidth |
Width of lines |
linetype |
type of lines |
x0 |
overrides x-coordinate in |
y0 |
overrides x-coordinate in |
style |
Gets and sets the styles associated with polygons |
... |
< |
ob_polygon object
length
The number of polygons in the ob_polygon object
tibble
Gets a tibble (data.frame) containing parameters and styles used by ggplot2::geom_polygon
.
ob_label class
ob_label( label = character(0), center = S7::class_missing, angle = numeric(0), alpha = numeric(0), color = character(0), family = character(0), fill = character(0), fontface = character(0), hjust = numeric(0), label.color = character(0), label.margin = class_margin(ggplot2::margin(1, 1, 1, 1, "pt")), label.padding = class_margin(ggplot2::margin(2, 2, 2, 2, "pt")), label.r = numeric(0), label.size = numeric(0), lineheight = numeric(0), polar_just = numeric(0), nudge_x = numeric(0), nudge_y = numeric(0), size = numeric(0), straight = logical(0), text.color = character(0), vjust = numeric(0), style = S7::class_missing, plot_point = FALSE, position = 0.5, spacing = numeric(0), x = S7::class_missing, y = S7::class_missing, ... )
ob_label( label = character(0), center = S7::class_missing, angle = numeric(0), alpha = numeric(0), color = character(0), family = character(0), fill = character(0), fontface = character(0), hjust = numeric(0), label.color = character(0), label.margin = class_margin(ggplot2::margin(1, 1, 1, 1, "pt")), label.padding = class_margin(ggplot2::margin(2, 2, 2, 2, "pt")), label.r = numeric(0), label.size = numeric(0), lineheight = numeric(0), polar_just = numeric(0), nudge_x = numeric(0), nudge_y = numeric(0), size = numeric(0), straight = logical(0), text.color = character(0), vjust = numeric(0), style = S7::class_missing, plot_point = FALSE, position = 0.5, spacing = numeric(0), x = S7::class_missing, y = S7::class_missing, ... )
label |
text label |
center |
ob_point indicating the center of the label |
angle |
angle of text |
alpha |
numeric value for alpha transparency |
color |
character string for color |
family |
font family |
fill |
character string for fill color |
fontface |
Can be plain, bold, italic, or bold.italic |
hjust |
horizontal justification. 0 means left justified, 1 means right justified, 0.5 means horizontally centered |
label.color |
Color of label outline. |
label.margin |
Amount of distance around label. Unit vector of length four. Usually created with |
label.padding |
Amount of padding around label. Unit vector of length four. Usually created with |
label.r |
Radius of rounded corners. Defaults to 0.15 lines. |
label.size |
Width of label outline. |
lineheight |
Height of line of text |
polar_just |
an angle, polar point, or point that alters hjust and vjust (polar polar_just not stored in style) |
nudge_x |
Horizontal adjustment to nudge labels by. |
nudge_y |
Vertical adjustment to nudge labels by. |
size |
numeric size |
straight |
logical. If TRUE, make bzpath label text straight instead of curved. |
text.color |
Color of label text. |
vjust |
vertical justification. 0 means bottom aligned, 1 means top aligned, 0.5 means vertically centered |
style |
a style list |
plot_point |
plot ob_point (default = FALSE) |
position |
position (used in conjunction with the |
spacing |
letter spacing for labels used with ob_path and ob_bezier |
x |
x-coordinate of center point. If specified, overrides x-coordinate of |
y |
x-coordinate of center point. If specified, overrides y-coordinate of |
... |
< |
ob_label object
make a latex equation
ob_latex( tex = character(0), center = ob_point(0, 0), width = numeric(0), height = numeric(0), hjust = 0.5, vjust = 0.5, angle = 0, aspect_ratio = 1, border = numeric(0), family = character(0), math_mode = TRUE, filename = character(0), color = character(0), fill = "white", density = 300, latex_packages = character(0), preamble = character(0), force_recompile = TRUE, delete_files = TRUE )
ob_latex( tex = character(0), center = ob_point(0, 0), width = numeric(0), height = numeric(0), hjust = 0.5, vjust = 0.5, angle = 0, aspect_ratio = 1, border = numeric(0), family = character(0), math_mode = TRUE, filename = character(0), color = character(0), fill = "white", density = 300, latex_packages = character(0), preamble = character(0), force_recompile = TRUE, delete_files = TRUE )
tex |
LaTeX equation |
center |
ob_point |
width |
width (specify width or height but not both) |
height |
height (specify width or height but not both) |
hjust |
horizontal adjustment. 0 means left justified, 1 means right justified, 0.5 means centered |
vjust |
vertical justification. 0 means bottom aligned, 1 means top aligned, 0.5 means vertically centered |
angle |
angle of text |
aspect_ratio |
alters the aspect ratio of the image |
border |
border space (in points) around image |
family |
font family (installed on system) of plain text |
math_mode |
include dollar signs automatically. Set to |
filename |
bare file name without extension (e.g., |
color |
set color of equation text |
fill |
set color of background rectangle |
density |
image quality (dots per inch) |
latex_packages |
load latex packages |
preamble |
additional latex commands to load in preamble |
force_recompile |
Will re-run xelatex even if .pdf file exists already |
ob_latex object
rectangle
gets or sets rectangle that contains the image
image
raster bitmap
Creates a line
ob_line( slope = numeric(0), intercept = numeric(0), xintercept = numeric(0), a = numeric(0), b = numeric(0), c = numeric(0), alpha = numeric(0), color = character(0), lineend = numeric(0), linejoin = numeric(0), linewidth = numeric(0), linetype = numeric(0), style = S7::class_missing, ... )
ob_line( slope = numeric(0), intercept = numeric(0), xintercept = numeric(0), a = numeric(0), b = numeric(0), c = numeric(0), alpha = numeric(0), color = character(0), lineend = numeric(0), linejoin = numeric(0), linewidth = numeric(0), linetype = numeric(0), style = S7::class_missing, ... )
slope |
coefficient in y = slope * x + intercept |
intercept |
value of y when x is 0 |
xintercept |
value of x when y is 0 |
a |
coefficient in general form: a * x + b * y + c = 0 |
b |
coefficient in general form: a * x + b * y + c = 0 |
c |
constant in general form: a * x + b * y + c = 0 |
alpha |
numeric value for alpha transparency |
color |
character string for color |
lineend |
Line end style (round, butt, square). |
linejoin |
Line join style (round, mitre, bevel). |
linewidth |
Width of lines |
linetype |
type of lines |
style |
a style list |
... |
< |
ob_line object
An ngon is a regular polygon, meaning that each side is of equal length. The ob_ngon
object can be specified with a center, n (number of sides), radius, and angle. Instead of specifying a radius, one can specify either the side_length
or the length of the apothem
(i.e., the distance from the center to a side's midpoint.
ob_ngon( center = ob_point(0, 0), n = 3L, radius = numeric(0), angle = 0, label = character(0), side_length = numeric(0), apothem = numeric(0), vertex_radius = numeric(0), alpha = numeric(0), color = character(0), fill = character(0), linewidth = numeric(0), linetype = numeric(0), style = S7::class_missing, x0 = numeric(0), y0 = numeric(0), ... )
ob_ngon( center = ob_point(0, 0), n = 3L, radius = numeric(0), angle = 0, label = character(0), side_length = numeric(0), apothem = numeric(0), vertex_radius = numeric(0), alpha = numeric(0), color = character(0), fill = character(0), linewidth = numeric(0), linetype = numeric(0), style = S7::class_missing, x0 = numeric(0), y0 = numeric(0), ... )
center |
point at center of the ngon |
n |
Number of sides |
radius |
Distance from center to a vertex |
angle |
description |
label |
A character, angle, or label object |
side_length |
Distance of each side |
apothem |
Distance from center to a side's midpoint |
vertex_radius |
A numeric or unit vector of length one, specifying the corner radius |
alpha |
numeric value for alpha transparency |
color |
character string for color |
fill |
character string for fill color |
linewidth |
Width of lines |
linetype |
type of lines |
style |
Gets and sets the styles associated with ob_ngon |
... |
< |
ob_ngon object
area
The area of the ngons in the ob_ngon object
length
The number of ngons in the ob_ngon object
normal_at
A function that finds a point that is perpendicular from the ngon and at a specified distance
perimeter
The length of all the side segments
point_at
A function that finds a point on the ngon at the specified angle.
segments
side segments of the regular polygon
tangent_at
A function that finds the tangent line at the specified angle.
tibble
Gets a tibble (data.frame) containing parameters and styles used by ggforce::geom_shape
.
vertices
points on the regular polygon
A ob_path
is specified with an ob_point
object that contains at least 2 points, the start and the end. Any number of intermediate points are possible.
ob_path( p = S7::class_missing, label = character(0), alpha = numeric(0), arrow_head = S7::class_missing, arrow_fins = S7::class_missing, arrowhead_length = numeric(0), length_head = numeric(0), length_fins = numeric(0), color = character(0), fill = character(0), lineend = numeric(0), linejoin = numeric(0), linewidth = numeric(0), linewidth_fins = numeric(0), linewidth_head = numeric(0), linetype = numeric(0), resect = numeric(0), resect_fins = numeric(0), resect_head = numeric(0), stroke_color = character(0), stroke_width = numeric(0), style = S7::class_missing, ... )
ob_path( p = S7::class_missing, label = character(0), alpha = numeric(0), arrow_head = S7::class_missing, arrow_fins = S7::class_missing, arrowhead_length = numeric(0), length_head = numeric(0), length_fins = numeric(0), color = character(0), fill = character(0), lineend = numeric(0), linejoin = numeric(0), linewidth = numeric(0), linewidth_fins = numeric(0), linewidth_head = numeric(0), linetype = numeric(0), resect = numeric(0), resect_fins = numeric(0), resect_head = numeric(0), stroke_color = character(0), stroke_width = numeric(0), style = S7::class_missing, ... )
p |
|
label |
A character, angle, or label object |
alpha |
numeric value for alpha transparency |
arrow_head |
A 2-column matrix of polygon points |
arrow_fins |
A 2-column matrix of polygon points |
arrowhead_length |
Determines the size of the arrow ornaments. This parameter becomes the |
length_head |
Determines the size of the arrow head. Numeric values set the ornament size relative to the linewidth. A unit value sets the ornament size in an absolute manner. From ggarrow. |
length_fins |
Determines the size of the arrow fins. Numeric values set the ornament size relative to the linewidth. A unit value sets the ornament size in an absolute manner. From ggarrow. |
color |
character string for color |
fill |
character string for fill color |
lineend |
Line end style (round, butt, square). |
linejoin |
Line join style (round, mitre, bevel). |
linewidth |
Width of lines |
linewidth_fins |
Line width for arrow fins |
linewidth_head |
Line width for arrow fins |
linetype |
type of lines |
resect |
A numeric(1) denoting millimeters or |
resect_fins |
A numeric(1) denoting millimeters or |
resect_head |
A numeric(1) denoting millimeters or |
stroke_color |
Color of point border line |
stroke_width |
Stroke width in arrows |
style |
Gets and sets the styles associated with paths |
... |
< |
If you wish to specify multiple paths, you must supply a list of ob_point
objects. When plotted, the ob_path
function uses the ggarrow::geom_arrow function to create the geom.
ob_path object
length
The number of paths in the ob_path object
tibble
Gets a tibble (data.frame) containing parameters and styles used by ggarrow::geom_arrow
.
Points are specified with x and y coordinates.
Polar points are ordinary points but are specified with an angle (theta) and a radial distance (r)
ob_point( x = 0, y = 0, alpha = numeric(0), color = character(0), fill = character(0), shape = numeric(0), size = numeric(0), stroke = numeric(0), style = S7::class_missing, ... ) ob_polar( theta = S7::class_missing, r = numeric(0), alpha = numeric(0), color = character(0), fill = character(0), shape = numeric(0), size = numeric(0), stroke = numeric(0), style = S7::class_missing )
ob_point( x = 0, y = 0, alpha = numeric(0), color = character(0), fill = character(0), shape = numeric(0), size = numeric(0), stroke = numeric(0), style = S7::class_missing, ... ) ob_polar( theta = S7::class_missing, r = numeric(0), alpha = numeric(0), color = character(0), fill = character(0), shape = numeric(0), size = numeric(0), stroke = numeric(0), style = S7::class_missing )
x |
Vector of coordinates on the x-axis (also can take a tibble/data.frame or 2-column matrix as input.) |
y |
Vector of coordinates on the y-axis |
alpha |
numeric value for alpha transparency |
color |
character string for color |
fill |
character string for fill color |
shape |
Point shape type. Can be specified with an integer (between 0 and 25), a single character (which uses that character as the plotting symbol), a . to draw the smallest rectangle that is visible (i.e., about one pixel), an NA to draw nothing, or a mapping to a discrete variable. |
size |
numeric size |
stroke |
Width of point border line |
style |
Gets and sets the styles associated with points |
... |
< |
theta |
Angle of the vector from the origin to the ob_point |
r |
Radius = Distance from the origin to the ob_point |
ob_point object
auto_label
Gets x and y coordinates and makes a label "(x,y)"
length
The number of points in the ob_point object
tibble
Gets a tibble (data.frame) containing parameters and styles used by ggplot2::geom_point
.
xy
Gets a 2-column matrix of the x and y coordinates of the ob_point object.
geom
A function that converts the object to a geom. Any additional parameters are passed to ggplot2::geom_point
.
A polygon is specified with an ob_point that contains at least 3 points, the start and the end. Any number of intermediate points are possible.
ob_polygon( p = S7::class_missing, label = character(0), vertex_radius = numeric(0), alpha = numeric(0), color = character(0), fill = character(0), linewidth = numeric(0), linetype = numeric(0), style = S7::class_missing, ... )
ob_polygon( p = S7::class_missing, label = character(0), vertex_radius = numeric(0), alpha = numeric(0), color = character(0), fill = character(0), linewidth = numeric(0), linetype = numeric(0), style = S7::class_missing, ... )
p |
ob_point or list of ob_point objects |
label |
A character, angle, or label object |
vertex_radius |
A numeric or unit vector of length one, specifying the corner radius |
alpha |
numeric value for alpha transparency |
color |
character string for color |
fill |
character string for fill color |
linewidth |
Width of lines |
linetype |
type of lines |
style |
Gets and sets the styles associated with polygons |
... |
< |
If you wish to specify multiple polygons, you must supply a list of ob_points. When plotted, the ob_polygon function uses the ggforce::geom_shape function to create the geom.
ob_polygon object
length
The number of polygons in the ob_polygon object
tibble
Gets a tibble (data.frame) containing parameters and styles used by ggforce::geom_shape
.
ob_rectangle class
ob_rectangle( center = S7::class_missing, width = numeric(0), height = numeric(0), east = S7::class_missing, north = S7::class_missing, west = S7::class_missing, south = S7::class_missing, northeast = S7::class_missing, northwest = S7::class_missing, southwest = S7::class_missing, southeast = S7::class_missing, angle = numeric(0), vertex_radius = numeric(0), label = character(0), alpha = numeric(0), color = character(0), fill = character(0), linewidth = numeric(0), linetype = numeric(0), style = S7::class_missing, x0 = numeric(0), y0 = numeric(0), ... )
ob_rectangle( center = S7::class_missing, width = numeric(0), height = numeric(0), east = S7::class_missing, north = S7::class_missing, west = S7::class_missing, south = S7::class_missing, northeast = S7::class_missing, northwest = S7::class_missing, southwest = S7::class_missing, southeast = S7::class_missing, angle = numeric(0), vertex_radius = numeric(0), label = character(0), alpha = numeric(0), color = character(0), fill = character(0), linewidth = numeric(0), linetype = numeric(0), style = S7::class_missing, x0 = numeric(0), y0 = numeric(0), ... )
center |
point at center of the rectangle |
width |
width |
height |
height |
east |
right middle point |
north |
top middle point |
west |
left middle point |
south |
top middle point |
northeast |
upper right point |
northwest |
upper left point |
southwest |
lower left point |
southeast |
lower right point |
angle |
angle of text |
vertex_radius |
A numeric or unit vector of length one, specifying the corner radius for rounded corners |
label |
A character, angle, or label object |
alpha |
numeric value for alpha transparency |
color |
character string for color |
fill |
character string for fill color |
linewidth |
Width of lines |
linetype |
type of lines |
style |
a style object |
x0 |
overrides x-coordinate in |
y0 |
overrides y-coordinate in |
... |
< |
ob_rectangle object
# specify center point p <- ob_point(0,0) ob_rectangle(p, width = 2, height = 2)
# specify center point p <- ob_point(0,0) ob_rectangle(p, width = 2, height = 2)
Reuleaux polygon
ob_reuleaux( center = ob_point(0, 0), n = 5, radius = 1, angle = 90, label = character(0), vertex_radius = numeric(0), alpha = numeric(0), color = "black", fill = character(0), linewidth = numeric(0), linetype = numeric(0), style = S7::class_missing, ... )
ob_reuleaux( center = ob_point(0, 0), n = 5, radius = 1, angle = 90, label = character(0), vertex_radius = numeric(0), alpha = numeric(0), color = "black", fill = character(0), linewidth = numeric(0), linetype = numeric(0), style = S7::class_missing, ... )
center |
point at center of the rectangle |
n |
Number of sides. True Reuleaux polygons have an odd number of sides, but Reauleaux-like shapes with an even number of sides are possible. |
radius |
Distance from center to a vertex |
angle |
angle of text |
alpha |
numeric value for alpha transparency |
color |
character string for color |
fill |
character string for fill color |
linewidth |
Width of lines |
linetype |
type of lines |
... |
< |
ob_reuleaux object
ob_segment class
ob_segment( p1 = S7::class_missing, p2 = S7::class_missing, label = character(0), alpha = numeric(0), arrow_head = ggarrow::arrow_head_minimal(90), arrow_fins = list(), arrowhead_length = 4, length_head = numeric(0), length_fins = numeric(0), color = character(0), lineend = numeric(0), linejoin = numeric(0), linewidth = numeric(0), linewidth_fins = numeric(0), linewidth_head = numeric(0), linetype = numeric(0), resect = numeric(0), resect_fins = numeric(0), resect_head = numeric(0), stroke_color = character(0), stroke_width = numeric(0), style = S7::class_missing, x = S7::class_missing, xend = S7::class_missing, y = S7::class_missing, yend = S7::class_missing, ... )
ob_segment( p1 = S7::class_missing, p2 = S7::class_missing, label = character(0), alpha = numeric(0), arrow_head = ggarrow::arrow_head_minimal(90), arrow_fins = list(), arrowhead_length = 4, length_head = numeric(0), length_fins = numeric(0), color = character(0), lineend = numeric(0), linejoin = numeric(0), linewidth = numeric(0), linewidth_fins = numeric(0), linewidth_head = numeric(0), linetype = numeric(0), resect = numeric(0), resect_fins = numeric(0), resect_head = numeric(0), stroke_color = character(0), stroke_width = numeric(0), style = S7::class_missing, x = S7::class_missing, xend = S7::class_missing, y = S7::class_missing, yend = S7::class_missing, ... )
p1 |
starting point |
p2 |
end point |
label |
A character, angle, or label object |
alpha |
numeric value for alpha transparency |
arrow_head |
A 2-column matrix of polygon points |
arrow_fins |
A 2-column matrix of polygon points |
arrowhead_length |
Determines the size of the arrow ornaments. This parameter becomes the |
length_head |
Determines the size of the arrow head. Numeric values set the ornament size relative to the linewidth. A unit value sets the ornament size in an absolute manner. From ggarrow. |
length_fins |
Determines the size of the arrow fins. Numeric values set the ornament size relative to the linewidth. A unit value sets the ornament size in an absolute manner. From ggarrow. |
color |
character string for color |
lineend |
Line end style (round, butt, square). |
linejoin |
Line join style (round, mitre, bevel). |
linewidth |
Width of lines |
linewidth_fins |
Line width for arrow fins |
linewidth_head |
Line width for arrow fins |
linetype |
type of lines |
resect |
A numeric(1) denoting millimeters or |
resect_fins |
A numeric(1) denoting millimeters or |
resect_head |
A numeric(1) denoting millimeters or |
stroke_color |
Color of point border line |
stroke_width |
Stroke width in arrows |
style |
a style list |
x |
overrides the x-coordinate of p1 |
xend |
overrides the y-coordinate of p1 |
y |
overrides the x-coordinate of p2 |
yend |
overrides the y-coordinate of p2 |
... |
< |
ob_segment object
geom
A function that converts the object to a geom. Any additional parameters are passed to ggarrow::geom_arrow_segment
.
hatch
A function that puts hatch (tally) marks on segments. Often used to indicate which segments have the same length. The k
parameter controls how many hatch marks to display. The height
parameter controls how long the hatch mark segment is. The sep
parameter controls the separation between hatch marks when k > 2
. Additional parameters sent to ob_segment
.
midpoint
A function that selects 1 or more midpoints of the ob_segment. The position
argument can be between 0 and 1. Additional arguments are passed to ob_point
.
nudge
A function to move the segment by x and y units.
makes a heterogeneous list of different ggdiagram objects
ob_shape_list(.data = list())
ob_shape_list(.data = list())
.data |
a list of objects |
An object of ob_shape_list
class. List of objects that can be converted to geoms
ob_style class
ob_style( alpha = numeric(0), angle = numeric(0), arrow_head = list(), arrow_fins = list(), arrow_mid = list(), color = character(0), family = character(0), fill = character(0), fontface = character(0), hjust = numeric(0), justify = numeric(0), label.color = character(0), label.margin = list(), label.padding = list(), label.r = numeric(0), label.size = numeric(0), arrowhead_length = numeric(0), length_head = numeric(0), length_fins = numeric(0), length_mid = numeric(0), lineend = numeric(0), lineheight = numeric(0), linejoin = numeric(0), linewidth_fins = numeric(0), linewidth_head = numeric(0), linewidth = numeric(0), linetype = numeric(0), n = numeric(0), nudge_x = numeric(0), nudge_y = numeric(0), polar_just = numeric(0), resect = numeric(0), resect_fins = numeric(0), resect_head = numeric(0), shape = numeric(0), size = numeric(0), size.unit = numeric(0), straight = logical(0), stroke = numeric(0), stroke_color = character(0), stroke_width = numeric(0), text.color = character(0), vjust = numeric(0), ... )
ob_style( alpha = numeric(0), angle = numeric(0), arrow_head = list(), arrow_fins = list(), arrow_mid = list(), color = character(0), family = character(0), fill = character(0), fontface = character(0), hjust = numeric(0), justify = numeric(0), label.color = character(0), label.margin = list(), label.padding = list(), label.r = numeric(0), label.size = numeric(0), arrowhead_length = numeric(0), length_head = numeric(0), length_fins = numeric(0), length_mid = numeric(0), lineend = numeric(0), lineheight = numeric(0), linejoin = numeric(0), linewidth_fins = numeric(0), linewidth_head = numeric(0), linewidth = numeric(0), linetype = numeric(0), n = numeric(0), nudge_x = numeric(0), nudge_y = numeric(0), polar_just = numeric(0), resect = numeric(0), resect_fins = numeric(0), resect_head = numeric(0), shape = numeric(0), size = numeric(0), size.unit = numeric(0), straight = logical(0), stroke = numeric(0), stroke_color = character(0), stroke_width = numeric(0), text.color = character(0), vjust = numeric(0), ... )
alpha |
numeric value for alpha transparency |
angle |
angle of text |
arrow_head |
A 2-column matrix of polygon points |
arrow_fins |
A 2-column matrix of polygon points |
arrow_mid |
A 2-column matrix of polygon points |
color |
character string for color |
family |
font family |
fill |
character string for fill color |
fontface |
Can be plain, bold, italic, or bold.italic |
hjust |
horizontal justification. 0 means left justified, 1 means right justified, 0.5 means horizontally centered |
justify |
A numeric(1) between 0 and 1 to control where the arrows should be drawn relative to the path's endpoints. A value of 0 sets the arrow's tips at the path's end, whereas a value of 1 sets the arrow's base at the path's end. From ggarrow. |
label.color |
Color of label outline. |
label.margin |
Amount of distance around label. Unit vector of length four. Usually created with |
label.padding |
Amount of padding around label. Unit vector of length four. Usually created with |
label.r |
Radius of rounded corners. Defaults to 0.15 lines. |
label.size |
Width of label outline. |
arrowhead_length |
Determines the size of the arrow ornaments. This parameter becomes the |
length_head |
Determines the size of the arrow head. Numeric values set the ornament size relative to the linewidth. A unit value sets the ornament size in an absolute manner. From ggarrow. |
length_fins |
Determines the size of the arrow fins. Numeric values set the ornament size relative to the linewidth. A unit value sets the ornament size in an absolute manner. From ggarrow. |
length_mid |
Determines the size of the middle arrows. Numeric values set the ornament size relative to the linewidth. A unit value sets the ornament size in an absolute manner. From ggarrow. |
lineend |
Line end style (round, butt, square). |
lineheight |
Height of line of text |
linejoin |
Line join style (round, mitre, bevel). |
linewidth_fins |
Line width for arrow fins |
linewidth_head |
Line width for arrow fins |
linewidth |
Width of lines |
linetype |
type of lines |
n |
Number of points in a polygon, circle, arc, or ellipse |
nudge_x |
Horizontal adjustment to nudge labels by. |
nudge_y |
Vertical adjustment to nudge labels by. |
polar_just |
an angle, polar point, or point that alters hjust and vjust (polar polar_just not stored in style) |
resect |
A numeric(1) denoting millimeters or |
resect_fins |
A numeric(1) denoting millimeters or |
resect_head |
A numeric(1) denoting millimeters or |
shape |
Point shape type. Can be specified with an integer (between 0 and 25), a single character (which uses that character as the plotting symbol), a . to draw the smallest rectangle that is visible (i.e., about one pixel), an NA to draw nothing, or a mapping to a discrete variable. |
size |
numeric size |
size.unit |
How the size aesthetic is interpreted: as points ("pt"), millimeters ("mm"), centimeters ("cm"), inches ("in"), or picas ("pc"). |
straight |
logical. If TRUE, make bzpath label text straight instead of curved. |
stroke |
Width of point border line |
stroke_color |
Color of point border line |
stroke_width |
Stroke width in arrows |
text.color |
Color of label text. |
vjust |
vertical justification. 0 means bottom aligned, 1 means top aligned, 0.5 means vertically centered |
... |
< |
ob_style object
create double-headed arrow paths indicating variance
ob_variance( x, where = "north", theta = 50, bend = 0, looseness = 1, arrow_head = arrowheadr::arrow_head_deltoid(d = 2.3, n = 100), resect = 2, ... )
ob_variance( x, where = "north", theta = 50, bend = 0, looseness = 1, arrow_head = arrowheadr::arrow_head_deltoid(d = 2.3, n = 100), resect = 2, ... )
x |
object |
where |
angle or named direction (e.g.,northwest, east, below, left) |
theta |
angle width |
bend |
Angle by which the control points are rotated |
looseness |
distance of control points as a ratio of the distance to the object's center (e.g., in a circle of radius 1, looseness = 1.5 means that that the control points will be 1.5 units from the start and end points.) |
arrow_head |
A 2-column matrix of polygon points |
resect |
A numeric(1) denoting millimeters or |
... |
< |
Returns an object of type ob_bezier
Find point perpendicular to 2 points
e1 %|-% e2 e1 %-|% e2
e1 %|-% e2 e1 %-|% e2
e1 |
first ob_point |
e2 |
second ob_point |
ob_point object
ob_point object
x <- ob_point(0,0) y <- ob_point(1,1) # Find point perpendicular to x and y going vertically first x %|-% y # Find point perpendicular to x and y going horizontally first x %-|% y
x <- ob_point(0,0) y <- ob_point(1,1) # Find point perpendicular to x and y going vertically first x %|-% y # Find point perpendicular to x and y going horizontally first x %-|% y
Place an object a specified distance from another object
place(x, from, where = "right", sep = 1, ...)
place(x, from, where = "right", sep = 1, ...)
x |
shape object |
from |
shape that x is placed in relation to |
where |
named direction, angle, or number (degrees) |
sep |
separation distance |
... |
< |
object of same class as x
Convert hjust and vjust parameters from polar coordinates
polar2just(x, multiplier = 1.2, axis = c("h", "v"))
polar2just(x, multiplier = 1.2, axis = c("h", "v"))
x |
angle |
multiplier |
distance |
axis |
vertical (v) or horizontal (h) |
ob_angle object
Find projection of a point on an object (e.g., line or segment)
projection(p, object, ...)
projection(p, object, ...)
p |
ob_point |
object |
object (e.g., line or segment) |
... |
< |
ob_point
Makes a copy of a function with new defaults. Similar to purrr::partial
except that arguments with new defaults still accept input.
redefault(.f, ...)
redefault(.f, ...)
.f |
function |
... |
< |
function
squircle <- redefault(ob_ellipse, m1 = 4) squircle(a = 3)
squircle <- redefault(ob_ellipse, m1 = 4) squircle(a = 3)
Shorten segments
resect(x, distance, ...)
resect(x, distance, ...)
x |
object |
distance |
resect distance |
... |
< |
resect |
a numeric distance |
object of same class as x
Rotate an object in 2 dimensions
rotate(x, theta, ..., origin = ob_point(0, 0))
rotate(x, theta, ..., origin = ob_point(0, 0))
x |
object |
theta |
angle |
... |
< |
origin |
length 2 vector or point about which rotation occurs |
shape object
Rounds to significant digits, removing leading zeros.
round_probability( p, accuracy = 0.01, digits = NULL, max_digits = NULL, remove_leading_zero = TRUE, round_zero_one = TRUE, phantom_text = NULL, phantom_color = NULL )
round_probability( p, accuracy = 0.01, digits = NULL, max_digits = NULL, remove_leading_zero = TRUE, round_zero_one = TRUE, phantom_text = NULL, phantom_color = NULL )
p |
probability |
accuracy |
smallest increment |
digits |
significant digits |
max_digits |
maximum rounding digits |
remove_leading_zero |
remove leading zero |
round_zero_one |
round 0 and 1 |
phantom_text |
invisible text inserted on the right |
phantom_color |
color of phantom text |
a character vector
round_probability(c(0, .0012, .012, .12, .99, .992, .9997, 1), digits = 2)
round_probability(c(0, .0012, .012, .12, .99, .992, .9997, 1), digits = 2)
A wrapper function for the signs::signs function. It adds a space to the right side of negative numbers so that it appear as if the minus sign does not affect the number's centering.
signs_centered(x, space = " ", encoding = "UTF-8", ...)
signs_centered(x, space = " ", encoding = "UTF-8", ...)
x |
a numeric vector |
space |
a character to be added to negative numbers (defaults to a UTF-8 figure space) |
encoding |
type of encoding (defaults to UTF-8) |
... |
parameters passed to signs:signs |
a vector of numbers converted to characters
library(ggplot2) d <- data.frame(x = -4:0, y = -4:0) # In these 2 plots, Compare the centering of the negative numbers on the x-axis ggplot(d, aes(x,y)) ggplot(d, aes(x,y)) + scale_x_continuous(labels = signs_centered)
library(ggplot2) d <- data.frame(x = -4:0, y = -4:0) # In these 2 plots, Compare the centering of the negative numbers on the x-axis ggplot(d, aes(x,y)) ggplot(d, aes(x,y)) + scale_x_continuous(labels = signs_centered)
Create subscripts
Create superscript
subscript(x, subscript = seq(length(x))) superscript(x, superscript = seq(length(x)))
subscript(x, subscript = seq(length(x))) superscript(x, superscript = seq(length(x)))
x |
string |
subscript |
subscript |
superscript |
superscript |
text
string
subscript("X", 1:3) superscript(c("A", "B"), 2)
subscript("X", 1:3) superscript(c("A", "B"), 2)
Converts an object with k elements into a list of k objects
unbind(x, ...)
unbind(x, ...)
x |
object |
a list of objects, each of length 1