geomCurve()
¶Specific arguments:
curvature
A numeric value that indicates the amount of curvature. Negative values produce left-hand curves, positive values produce right-hand curves and zero produces a straight line. Default = 0.5.
angle
A numeric value between 0 and 180 that indicates the amount by which the control points of the curve should be skewed. Values less than 90 skew the curve towards the start point and values greater than 90 skew the curve towards the end point. Default = 90.
ncp
The number of control points used to draw the curve. More control points produce a smoother curve. Default = 5.
%useLatestDescriptors
%use lets-plot
%use dataframe
LetsPlot.getInfo()
Lets-Plot Kotlin API v.0.0.0-SNAPSHOT. Frontend: Notebook with dynamically loaded JS. Lets-Plot JS v.4.3.0rc1.
fun curvePlot(curvature: Number = 0.5, angle: Number = 90, ncp: Int = 5) =
letsPlot() +
geomCurve(x = -10, y = 1, xend = 10, yend = -1,
curvature = curvature, angle = angle, ncp = ncp,
arrow = arrow(ends = "both")) +
ggtitle("curvature=$curvature, angle=$angle, ncp=$ncp") +
xlim(-15 to 15)
gggrid(
listOf(
curvePlot(angle = 0),
curvePlot(ncp = 1),
curvePlot(angle = 45),
curvePlot(curvature = -1, angle = 45),
curvePlot(curvature = 0.7, angle = 30),
curvePlot(curvature = -0.7, angle = 30)
),
ncol = 2
)
val mpgDf = DataFrame.readCSV("https://raw.githubusercontent.com/JetBrains/lets-plot-docs/master/data/mpg.csv")
val mpgCyl5 = mpgDf.filter { cyl == 5 && model == "new beetle" }.toMap()
letsPlot(mpgDf.toMap()) { x = "displ"; y = "hwy" } +
geomPoint(data = mpgCyl5, color = "#de77ae", size = 5) +
geomPoint() +
geomText(label = "Five-cylinder engine", x = 4, y = 40, nudgeX = 0.5, color = "#c51b7d", size = 10) +
geomCurve(data = mpgCyl5, xend = 4, yend=40,
sizeStart = 6, sizeEnd = 15,
curvature = 0.3, arrow = arrow(length = 8, ends = "first", angle = 15, type = "closed"),
size = 0.3,
color="#c51b7d")
ggplot(mpgDf.toMap()) +
geomBar() { x = "class" } +
geomCurve(x = 5, y = 55, xend = 3, yend = 6,
sizeStart = 50,
arrow = arrow(length = 10, ends = "last", type = "closed")) +
geomText(label = "Zoom Zoom!", x = 5, y = 55)