Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

curveseg

Draw a curved segment


Description

Draws a curved segment from point (x0,y0) to (x1,y1). The segment is a framgent of a sinusoid, has a defined width and can either have a single color or a color gradient.

Usage

curveseg(
  x0,
  x1,
  y0,
  y1,
  width = 1,
  nsteps = 50,
  col = "#ffcc0066",
  grad = NULL,
  lty = 1,
  form = c("sin", "line"),
  fix.pdf = 0
)

Arguments

x0

X coordinate of the starting point

x1

X coordinate of the end point

y0

X coordinate of the starting point

y1

X coordinate of the end point

width

Width of the segment to plot

nsteps

Number of polygons to use for the segments. The more, the smoother the picture, but at the same time, the more time-consuming to display.

col

Color to use. Ignored if grad is not NULL.

grad

Gradient to use. Can be anything that colorRampPalette can understand.

lty

Line type for drawing of the segment. Use lty=0 for no line.

form

"sin" for a sinusoidal segment. "line" for a straight segment.

fix.pdf

Draw a border around segments with line type lty in a desperate attempt to fix the PDF output.

Value

no value is returned

Examples

# a DNA strand
plot.new()
par( usr= c( 0, 4, -2.5, 2.5 ) )

w    <- 0.4
cols <- c( "blue", "green" )
init <- c( -0.8, -0.5 )
pos  <- c( 1, -1 )
step <- 0.5

for( i in rep( rep( c( 1, 2 ), each= 2 ), 5 ) ) {
  curveseg( init[i], init[i] + step, pos[1], pos[2], width= w, col= cols[i] )
  init[i] <- init[i] + step
  pos <- pos * -1
}

riverplot

Sankey or Ribbon Plots

v0.10
GPL (>= 2.0)
Authors
January Weiner <january.weiner@gmail.com>
Initial release
2021-01-22

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.