Tucan.Geometry (tucan v0.7.0)

Copy Markdown View Source

An API for drawing common geometrical shapes.

Tucan.Geometry offers an interface for rendering typical geometric forms, such as lines, circles, and polygons. Unlike the general Tucan API, these functions require only the parameters defining the respective geometric shapes, rather than a dataset and data fields.

You can overlay tucan plots with geometrical shapes through the Tucan.layers/2 function.

Examples

Tucan.layers([
  Tucan.Geometry.circle({3, 3}, 4, line_color: "red", stroke_width: 3),
  Tucan.Geometry.rectangle({-2, 10}, {7, -3}, line_color: "green"),
  Tucan.Geometry.rectangle({-3.5, 0.1}, {8.1, -4.2},
    fill_color: "pink",
    fill_opacity: 0.3
  ),
  Tucan.Geometry.polyline([{1, 1}, {2, 7}, {5, 3}],
    closed: true,
    fill_color: "green",
    fill_opacity: 0.3
  )
])
|> Tucan.Scale.set_xy_domain(-5, 11)
|> Tucan.set_size(400, 400)
|> Tucan.set_title("Tucan.Geometry examples")
{"$schema":"https://vega.github.io/schema/vega-lite/v5.json","height":400,"layer":[{"data":{"sequence":{"as":"theta","start":0,"step":1,"stop":361}},"encoding":{"order":{"field":"theta"},"x":{"field":"x","scale":{"domain":[-5,11]},"type":"quantitative"},"y":{"field":"y","scale":{"domain":[-5,11]},"type":"quantitative"}},"mark":{"color":"red","fillOpacity":1,"strokeOpacity":1,"strokeWidth":3,"type":"line"},"transform":[{"as":"x","calculate":"3 + cos(datum.theta*PI/180) * 4"},{"as":"y","calculate":"3 + sin(datum.theta*PI/180) * 4"}]},{"data":{"values":[{"order":0,"x":-2,"y":-3},{"order":1,"x":-2,"y":10},{"order":2,"x":7,"y":10},{"order":3,"x":7,"y":-3},{"order":4,"x":-2,"y":-3}]},"encoding":{"order":{"field":"order"},"x":{"field":"x","scale":{"domain":[-5,11]},"type":"quantitative"},"y":{"field":"y","scale":{"domain":[-5,11]},"type":"quantitative"}},"mark":{"color":"green","fillOpacity":1,"strokeOpacity":1,"strokeWidth":1,"type":"line"}},{"data":{"values":[{"order":0,"x":-3.5,"y":-4.2},{"order":1,"x":-3.5,"y":0.1},{"order":2,"x":8.1,"y":0.1},{"order":3,"x":8.1,"y":-4.2},{"order":4,"x":-3.5,"y":-4.2}]},"encoding":{"order":{"field":"order"},"x":{"field":"x","scale":{"domain":[-5,11]},"type":"quantitative"},"y":{"field":"y","scale":{"domain":[-5,11]},"type":"quantitative"}},"mark":{"fill":"pink","fillOpacity":0.3,"strokeOpacity":1,"strokeWidth":1,"type":"line"}},{"data":{"values":[{"order":0,"x":1,"y":1},{"order":1,"x":2,"y":7},{"order":2,"x":5,"y":3},{"order":3,"x":1,"y":1}]},"encoding":{"order":{"field":"order"},"x":{"field":"x","scale":{"domain":[-5,11]},"type":"quantitative"},"y":{"field":"y","scale":{"domain":[-5,11]},"type":"quantitative"}},"mark":{"fill":"green","fillOpacity":0.3,"strokeOpacity":1,"strokeWidth":1,"type":"line"}}],"title":{"text":"Tucan.Geometry examples"},"width":400}

Summary

Types

A cartesian point in the form {x, y}

Functions

Draws an arrow from the start to the end point.

Draws a circle with the given center and radius.

Draws an ellipse with the given center, x_radius, y_radius, and rotation_angle.

Draws the curve of the function fun in the {min, max} range of x.

Draws a line segment from the start to the end point.

Draws a polyline defined by the given vertices.

Draws a rectangle defined by the given upper_left and bottom_right points.

Draws a regular polygon with the given number of sides, whose vertices are on a circle with the given center and radius.

Types

point()

@type point() :: {number(), number()}

A cartesian point in the form {x, y}

Functions

arrow(start, end, opts \\ [])

@spec arrow(start :: point(), end_point :: point(), opts :: keyword()) :: VegaLite.t()

Draws an arrow from the start to the end point.

The arrow head points in the direction of the arrow on the screen, taking into account the scales of the plot.

Concatenated plots

Inside concatenated plots, e.g. Tucan.hconcat/2, the scales of the plot cannot be referenced and the direction of the head is computed in data units. It matches the arrow only if the x and y axes have the same scale.

Options

Styling Options

  • :head_size (pos_integer/0) - The size of the arrow head. The default value is 60.
  • :line_color (String.t/0) - The color of the line The default value is "black".
  • :opacity (number/0) - The overall opacity of the mark
  • :stroke_dash (list of pos_integer/0) - An array of alternating stroke, space lengths in pixels for creating dashed or dotted lines.
  • :stroke_width (pos_integer/0) - The stroke width in pixels The default value is 2.

Examples

Pointing to a point of a scatter plot, with an annotation:

Tucan.scatter(:cars, "Horsepower", "Miles_per_Gallon")
|> Tucan.Layers.append(Tucan.Geometry.arrow({180, 35}, {225, 16}, line_color: "red"))
|> Tucan.annotate(180, 37, "The most powerful car", color: "red")
{"$schema":"https://vega.github.io/schema/vega-lite/v5.json","data":{"url":"https://vega.github.io/editor/data/cars.json"},"layer":[{"encoding":{"x":{"field":"Horsepower","scale":{"zero":false},"type":"quantitative"},"y":{"field":"Miles_per_Gallon","scale":{"zero":false},"type":"quantitative"}},"mark":{"fillOpacity":1,"type":"point"}},{"layer":[{"data":{"values":[{}]},"encoding":{"x":{"datum":180,"type":"quantitative"},"x2":{"datum":225},"y":{"datum":35,"type":"quantitative"},"y2":{"datum":16}},"mark":{"color":"red","strokeWidth":2,"type":"rule"}},{"data":{"values":[{}]},"encoding":{"x":{"datum":225,"type":"quantitative"},"y":{"datum":16,"type":"quantitative"}},"mark":{"angle":{"expr":"(isFinite(atan2(scale('x', 225) - scale('x', 180), scale('y', 35) - scale('y', 16))) ? atan2(scale('x', 225) - scale('x', 180), scale('y', 35) - scale('y', 16)) : atan2((225) - (180), (16) - (35))) * 180 / PI"},"color":"red","filled":true,"opacity":1,"shape":"triangle","size":60,"type":"point"}}]},{"data":{"values":[{}]},"encoding":{"x":{"datum":180,"type":"quantitative"},"y":{"datum":37,"type":"quantitative"}},"mark":{"color":"red","text":"The most powerful car","type":"text"}}]}

Arrows in every direction:

arrows =
  for angle <- 0..330//30 do
    radians = angle * :math.pi() / 180
    Tucan.Geometry.arrow({0, 0}, {5 * :math.cos(radians), 5 * :math.sin(radians)})
  end

Tucan.layers(arrows)
|> Tucan.set_size(250, 250)
{"$schema":"https://vega.github.io/schema/vega-lite/v5.json","height":250,"layer":[{"data":{"values":[{}]},"encoding":{"x":{"datum":0,"type":"quantitative"},"x2":{"datum":5.0},"y":{"datum":0,"type":"quantitative"},"y2":{"datum":0.0}},"mark":{"color":"black","strokeWidth":2,"type":"rule"}},{"data":{"values":[{}]},"encoding":{"x":{"datum":5.0,"type":"quantitative"},"y":{"datum":0.0,"type":"quantitative"}},"mark":{"angle":{"expr":"(isFinite(atan2(scale('x', 5.0) - scale('x', 0), scale('y', 0) - scale('y', 0.0))) ? atan2(scale('x', 5.0) - scale('x', 0), scale('y', 0) - scale('y', 0.0)) : atan2((5.0) - (0), (0.0) - (0))) * 180 / PI"},"color":"black","filled":true,"opacity":1,"shape":"triangle","size":60,"type":"point"}},{"data":{"values":[{}]},"encoding":{"x":{"datum":0,"type":"quantitative"},"x2":{"datum":4.330127018922194},"y":{"datum":0,"type":"quantitative"},"y2":{"datum":2.4999999999999996}},"mark":{"color":"black","strokeWidth":2,"type":"rule"}},{"data":{"values":[{}]},"encoding":{"x":{"datum":4.330127018922194,"type":"quantitative"},"y":{"datum":2.4999999999999996,"type":"quantitative"}},"mark":{"angle":{"expr":"(isFinite(atan2(scale('x', 4.330127018922194) - scale('x', 0), scale('y', 0) - scale('y', 2.4999999999999996))) ? atan2(scale('x', 4.330127018922194) - scale('x', 0), scale('y', 0) - scale('y', 2.4999999999999996)) : atan2((4.330127018922194) - (0), (2.4999999999999996) - (0))) * 180 / PI"},"color":"black","filled":true,"opacity":1,"shape":"triangle","size":60,"type":"point"}},{"data":{"values":[{}]},"encoding":{"x":{"datum":0,"type":"quantitative"},"x2":{"datum":2.5000000000000004},"y":{"datum":0,"type":"quantitative"},"y2":{"datum":4.330127018922193}},"mark":{"color":"black","strokeWidth":2,"type":"rule"}},{"data":{"values":[{}]},"encoding":{"x":{"datum":2.5000000000000004,"type":"quantitative"},"y":{"datum":4.330127018922193,"type":"quantitative"}},"mark":{"angle":{"expr":"(isFinite(atan2(scale('x', 2.5000000000000004) - scale('x', 0), scale('y', 0) - scale('y', 4.330127018922193))) ? atan2(scale('x', 2.5000000000000004) - scale('x', 0), scale('y', 0) - scale('y', 4.330127018922193)) : atan2((2.5000000000000004) - (0), (4.330127018922193) - (0))) * 180 / PI"},"color":"black","filled":true,"opacity":1,"shape":"triangle","size":60,"type":"point"}},{"data":{"values":[{}]},"encoding":{"x":{"datum":0,"type":"quantitative"},"x2":{"datum":3.061616997868383e-16},"y":{"datum":0,"type":"quantitative"},"y2":{"datum":5.0}},"mark":{"color":"black","strokeWidth":2,"type":"rule"}},{"data":{"values":[{}]},"encoding":{"x":{"datum":3.061616997868383e-16,"type":"quantitative"},"y":{"datum":5.0,"type":"quantitative"}},"mark":{"angle":{"expr":"(isFinite(atan2(scale('x', 3.061616997868383e-16) - scale('x', 0), scale('y', 0) - scale('y', 5.0))) ? atan2(scale('x', 3.061616997868383e-16) - scale('x', 0), scale('y', 0) - scale('y', 5.0)) : atan2((3.061616997868383e-16) - (0), (5.0) - (0))) * 180 / PI"},"color":"black","filled":true,"opacity":1,"shape":"triangle","size":60,"type":"point"}},{"data":{"values":[{}]},"encoding":{"x":{"datum":0,"type":"quantitative"},"x2":{"datum":-2.499999999999999},"y":{"datum":0,"type":"quantitative"},"y2":{"datum":4.330127018922194}},"mark":{"color":"black","strokeWidth":2,"type":"rule"}},{"data":{"values":[{}]},"encoding":{"x":{"datum":-2.499999999999999,"type":"quantitative"},"y":{"datum":4.330127018922194,"type":"quantitative"}},"mark":{"angle":{"expr":"(isFinite(atan2(scale('x', -2.499999999999999) - scale('x', 0), scale('y', 0) - scale('y', 4.330127018922194))) ? atan2(scale('x', -2.499999999999999) - scale('x', 0), scale('y', 0) - scale('y', 4.330127018922194)) : atan2((-2.499999999999999) - (0), (4.330127018922194) - (0))) * 180 / PI"},"color":"black","filled":true,"opacity":1,"shape":"triangle","size":60,"type":"point"}},{"data":{"values":[{}]},"encoding":{"x":{"datum":0,"type":"quantitative"},"x2":{"datum":-4.330127018922194},"y":{"datum":0,"type":"quantitative"},"y2":{"datum":2.4999999999999996}},"mark":{"color":"black","strokeWidth":2,"type":"rule"}},{"data":{"values":[{}]},"encoding":{"x":{"datum":-4.330127018922194,"type":"quantitative"},"y":{"datum":2.4999999999999996,"type":"quantitative"}},"mark":{"angle":{"expr":"(isFinite(atan2(scale('x', -4.330127018922194) - scale('x', 0), scale('y', 0) - scale('y', 2.4999999999999996))) ? atan2(scale('x', -4.330127018922194) - scale('x', 0), scale('y', 0) - scale('y', 2.4999999999999996)) : atan2((-4.330127018922194) - (0), (2.4999999999999996) - (0))) * 180 / PI"},"color":"black","filled":true,"opacity":1,"shape":"triangle","size":60,"type":"point"}},{"data":{"values":[{}]},"encoding":{"x":{"datum":0,"type":"quantitative"},"x2":{"datum":-5.0},"y":{"datum":0,"type":"quantitative"},"y2":{"datum":6.123233995736766e-16}},"mark":{"color":"black","strokeWidth":2,"type":"rule"}},{"data":{"values":[{}]},"encoding":{"x":{"datum":-5.0,"type":"quantitative"},"y":{"datum":6.123233995736766e-16,"type":"quantitative"}},"mark":{"angle":{"expr":"(isFinite(atan2(scale('x', -5.0) - scale('x', 0), scale('y', 0) - scale('y', 6.123233995736766e-16))) ? atan2(scale('x', -5.0) - scale('x', 0), scale('y', 0) - scale('y', 6.123233995736766e-16)) : atan2((-5.0) - (0), (6.123233995736766e-16) - (0))) * 180 / PI"},"color":"black","filled":true,"opacity":1,"shape":"triangle","size":60,"type":"point"}},{"data":{"values":[{}]},"encoding":{"x":{"datum":0,"type":"quantitative"},"x2":{"datum":-4.330127018922193},"y":{"datum":0,"type":"quantitative"},"y2":{"datum":-2.5000000000000004}},"mark":{"color":"black","strokeWidth":2,"type":"rule"}},{"data":{"values":[{}]},"encoding":{"x":{"datum":-4.330127018922193,"type":"quantitative"},"y":{"datum":-2.5000000000000004,"type":"quantitative"}},"mark":{"angle":{"expr":"(isFinite(atan2(scale('x', -4.330127018922193) - scale('x', 0), scale('y', 0) - scale('y', -2.5000000000000004))) ? atan2(scale('x', -4.330127018922193) - scale('x', 0), scale('y', 0) - scale('y', -2.5000000000000004)) : atan2((-4.330127018922193) - (0), (-2.5000000000000004) - (0))) * 180 / PI"},"color":"black","filled":true,"opacity":1,"shape":"triangle","size":60,"type":"point"}},{"data":{"values":[{}]},"encoding":{"x":{"datum":0,"type":"quantitative"},"x2":{"datum":-2.500000000000002},"y":{"datum":0,"type":"quantitative"},"y2":{"datum":-4.330127018922192}},"mark":{"color":"black","strokeWidth":2,"type":"rule"}},{"data":{"values":[{}]},"encoding":{"x":{"datum":-2.500000000000002,"type":"quantitative"},"y":{"datum":-4.330127018922192,"type":"quantitative"}},"mark":{"angle":{"expr":"(isFinite(atan2(scale('x', -2.500000000000002) - scale('x', 0), scale('y', 0) - scale('y', -4.330127018922192))) ? atan2(scale('x', -2.500000000000002) - scale('x', 0), scale('y', 0) - scale('y', -4.330127018922192)) : atan2((-2.500000000000002) - (0), (-4.330127018922192) - (0))) * 180 / PI"},"color":"black","filled":true,"opacity":1,"shape":"triangle","size":60,"type":"point"}},{"data":{"values":[{}]},"encoding":{"x":{"datum":0,"type":"quantitative"},"x2":{"datum":-9.184850993605148e-16},"y":{"datum":0,"type":"quantitative"},"y2":{"datum":-5.0}},"mark":{"color":"black","strokeWidth":2,"type":"rule"}},{"data":{"values":[{}]},"encoding":{"x":{"datum":-9.184850993605148e-16,"type":"quantitative"},"y":{"datum":-5.0,"type":"quantitative"}},"mark":{"angle":{"expr":"(isFinite(atan2(scale('x', -9.184850993605148e-16) - scale('x', 0), scale('y', 0) - scale('y', -5.0))) ? atan2(scale('x', -9.184850993605148e-16) - scale('x', 0), scale('y', 0) - scale('y', -5.0)) : atan2((-9.184850993605148e-16) - (0), (-5.0) - (0))) * 180 / PI"},"color":"black","filled":true,"opacity":1,"shape":"triangle","size":60,"type":"point"}},{"data":{"values":[{}]},"encoding":{"x":{"datum":0,"type":"quantitative"},"x2":{"datum":2.5000000000000004},"y":{"datum":0,"type":"quantitative"},"y2":{"datum":-4.330127018922193}},"mark":{"color":"black","strokeWidth":2,"type":"rule"}},{"data":{"values":[{}]},"encoding":{"x":{"datum":2.5000000000000004,"type":"quantitative"},"y":{"datum":-4.330127018922193,"type":"quantitative"}},"mark":{"angle":{"expr":"(isFinite(atan2(scale('x', 2.5000000000000004) - scale('x', 0), scale('y', 0) - scale('y', -4.330127018922193))) ? atan2(scale('x', 2.5000000000000004) - scale('x', 0), scale('y', 0) - scale('y', -4.330127018922193)) : atan2((2.5000000000000004) - (0), (-4.330127018922193) - (0))) * 180 / PI"},"color":"black","filled":true,"opacity":1,"shape":"triangle","size":60,"type":"point"}},{"data":{"values":[{}]},"encoding":{"x":{"datum":0,"type":"quantitative"},"x2":{"datum":4.330127018922192},"y":{"datum":0,"type":"quantitative"},"y2":{"datum":-2.500000000000002}},"mark":{"color":"black","strokeWidth":2,"type":"rule"}},{"data":{"values":[{}]},"encoding":{"x":{"datum":4.330127018922192,"type":"quantitative"},"y":{"datum":-2.500000000000002,"type":"quantitative"}},"mark":{"angle":{"expr":"(isFinite(atan2(scale('x', 4.330127018922192) - scale('x', 0), scale('y', 0) - scale('y', -2.500000000000002))) ? atan2(scale('x', 4.330127018922192) - scale('x', 0), scale('y', 0) - scale('y', -2.500000000000002)) : atan2((4.330127018922192) - (0), (-2.500000000000002) - (0))) * 180 / PI"},"color":"black","filled":true,"opacity":1,"shape":"triangle","size":60,"type":"point"}}],"width":250}

circle(center, radius, opts \\ [])

@spec circle(center :: point(), radius :: number(), opts :: keyword()) :: VegaLite.t()

Draws a circle with the given center and radius.

Options

Styling Options

  • :fill_color (String.t/0) - The fill color of the marks. This will override the color encoding if set.
  • :fill_opacity (number/0) - The fill opacity of the plotted elements. The default value is 1.
  • :line_color (String.t/0) - The color of the line
  • :opacity (number/0) - The overall opacity of the mark
  • :stroke_dash (list of pos_integer/0) - An array of alternating stroke, space lengths in pixels for creating dashed or dotted lines.
  • :stroke_opacity (number/0) - The opacity of the stroke. The default value is 1.
  • :stroke_width (pos_integer/0) - The stroke width in pixels The default value is 1.

Examples

Tucan.layers([
  Tucan.Geometry.circle({3, 2}, 5),
  Tucan.Geometry.circle({-1, 6}, 2, line_color: "red"),
  Tucan.Geometry.circle({0, 1}, 4, line_color: "green", stroke_width: 5)
])
|> Tucan.Scale.set_x_domain(-5, 10)
|> Tucan.Scale.set_y_domain(-5, 10)
{"$schema":"https://vega.github.io/schema/vega-lite/v5.json","layer":[{"data":{"sequence":{"as":"theta","start":0,"step":1,"stop":361}},"encoding":{"order":{"field":"theta"},"x":{"field":"x","scale":{"domain":[-5,10]},"type":"quantitative"},"y":{"field":"y","scale":{"domain":[-5,10]},"type":"quantitative"}},"mark":{"fillOpacity":1,"strokeOpacity":1,"strokeWidth":1,"type":"line"},"transform":[{"as":"x","calculate":"3 + cos(datum.theta*PI/180) * 5"},{"as":"y","calculate":"2 + sin(datum.theta*PI/180) * 5"}]},{"data":{"sequence":{"as":"theta","start":0,"step":1,"stop":361}},"encoding":{"order":{"field":"theta"},"x":{"field":"x","scale":{"domain":[-5,10]},"type":"quantitative"},"y":{"field":"y","scale":{"domain":[-5,10]},"type":"quantitative"}},"mark":{"color":"red","fillOpacity":1,"strokeOpacity":1,"strokeWidth":1,"type":"line"},"transform":[{"as":"x","calculate":"-1 + cos(datum.theta*PI/180) * 2"},{"as":"y","calculate":"6 + sin(datum.theta*PI/180) * 2"}]},{"data":{"sequence":{"as":"theta","start":0,"step":1,"stop":361}},"encoding":{"order":{"field":"theta"},"x":{"field":"x","scale":{"domain":[-5,10]},"type":"quantitative"},"y":{"field":"y","scale":{"domain":[-5,10]},"type":"quantitative"}},"mark":{"color":"green","fillOpacity":1,"strokeOpacity":1,"strokeWidth":5,"type":"line"},"transform":[{"as":"x","calculate":"0 + cos(datum.theta*PI/180) * 4"},{"as":"y","calculate":"1 + sin(datum.theta*PI/180) * 4"}]}]}

You can also draw filled circles by setting the :fill_color option. Opacity of the fill color and the stroke color can be configured by :opacity or independently by :fill_opacity and :stroke_opacity.

Tucan.layers([
  Tucan.Geometry.circle({3, 2}, 5, stroke_width: 3, stroke_opacity: 0.4),
  Tucan.Geometry.circle({-1, 6}, 2, line_color: "red", fill_color: "pink", opacity: 0.3),
  Tucan.Geometry.circle({0, 1}, 4,
    line_color: "green",
    stroke_width: 5,
    fill_color: "green",
    fill_opacity: 0.2
  )
])
|> Tucan.Scale.set_x_domain(-5, 10)
|> Tucan.Scale.set_y_domain(-5, 10)
{"$schema":"https://vega.github.io/schema/vega-lite/v5.json","layer":[{"data":{"sequence":{"as":"theta","start":0,"step":1,"stop":361}},"encoding":{"order":{"field":"theta"},"x":{"field":"x","scale":{"domain":[-5,10]},"type":"quantitative"},"y":{"field":"y","scale":{"domain":[-5,10]},"type":"quantitative"}},"mark":{"fillOpacity":1,"strokeOpacity":0.4,"strokeWidth":3,"type":"line"},"transform":[{"as":"x","calculate":"3 + cos(datum.theta*PI/180) * 5"},{"as":"y","calculate":"2 + sin(datum.theta*PI/180) * 5"}]},{"data":{"sequence":{"as":"theta","start":0,"step":1,"stop":361}},"encoding":{"order":{"field":"theta"},"x":{"field":"x","scale":{"domain":[-5,10]},"type":"quantitative"},"y":{"field":"y","scale":{"domain":[-5,10]},"type":"quantitative"}},"mark":{"color":"red","fill":"pink","fillOpacity":1,"opacity":0.3,"strokeOpacity":1,"strokeWidth":1,"type":"line"},"transform":[{"as":"x","calculate":"-1 + cos(datum.theta*PI/180) * 2"},{"as":"y","calculate":"6 + sin(datum.theta*PI/180) * 2"}]},{"data":{"sequence":{"as":"theta","start":0,"step":1,"stop":361}},"encoding":{"order":{"field":"theta"},"x":{"field":"x","scale":{"domain":[-5,10]},"type":"quantitative"},"y":{"field":"y","scale":{"domain":[-5,10]},"type":"quantitative"}},"mark":{"color":"green","fill":"green","fillOpacity":0.2,"strokeOpacity":1,"strokeWidth":5,"type":"line"},"transform":[{"as":"x","calculate":"0 + cos(datum.theta*PI/180) * 4"},{"as":"y","calculate":"1 + sin(datum.theta*PI/180) * 4"}]}]}

Circles and plot dimensions

Notice that the plot must be square with identical scale domains across the two axes for the circle to appear circular. In a different case it will look like an ellipsis.

circle = Tucan.Geometry.circle({0, 0}, 1)

Tucan.hconcat([
  circle
  |> Tucan.set_size(150, 150)
  |> Tucan.set_title("Square frame"),
  circle
  |> Tucan.Scale.set_x_domain(-2, 2)
  |> Tucan.Scale.set_y_domain(-1, 1)
  |> Tucan.set_size(150, 150)
  |> Tucan.set_title("Different domains"),
  circle
  |> Tucan.set_size(200, 150)
  |> Tucan.set_title("Different frame dimensions")
])
{"$schema":"https://vega.github.io/schema/vega-lite/v5.json","hconcat":[{"data":{"sequence":{"as":"theta","start":0,"step":1,"stop":361}},"encoding":{"order":{"field":"theta"},"x":{"field":"x","type":"quantitative"},"y":{"field":"y","type":"quantitative"}},"height":150,"mark":{"fillOpacity":1,"strokeOpacity":1,"strokeWidth":1,"type":"line"},"title":{"text":"Square frame"},"transform":[{"as":"x","calculate":"0 + cos(datum.theta*PI/180) * 1"},{"as":"y","calculate":"0 + sin(datum.theta*PI/180) * 1"}],"width":150},{"data":{"sequence":{"as":"theta","start":0,"step":1,"stop":361}},"encoding":{"order":{"field":"theta"},"x":{"field":"x","scale":{"domain":[-2,2]},"type":"quantitative"},"y":{"field":"y","scale":{"domain":[-1,1]},"type":"quantitative"}},"height":150,"mark":{"fillOpacity":1,"strokeOpacity":1,"strokeWidth":1,"type":"line"},"title":{"text":"Different domains"},"transform":[{"as":"x","calculate":"0 + cos(datum.theta*PI/180) * 1"},{"as":"y","calculate":"0 + sin(datum.theta*PI/180) * 1"}],"width":150},{"data":{"sequence":{"as":"theta","start":0,"step":1,"stop":361}},"encoding":{"order":{"field":"theta"},"x":{"field":"x","type":"quantitative"},"y":{"field":"y","type":"quantitative"}},"height":150,"mark":{"fillOpacity":1,"strokeOpacity":1,"strokeWidth":1,"type":"line"},"title":{"text":"Different frame dimensions"},"transform":[{"as":"x","calculate":"0 + cos(datum.theta*PI/180) * 1"},{"as":"y","calculate":"0 + sin(datum.theta*PI/180) * 1"}],"width":200}]}

ellipse(radius, x_radius, y_radius, rotation_angle, opts \\ [])

@spec ellipse(
  center :: point(),
  x_radius :: number(),
  y_radius :: number(),
  rotation_angle :: number(),
  opts :: keyword()
) :: VegaLite.t()

Draws an ellipse with the given center, x_radius, y_radius, and rotation_angle.

x_radius is expected to be a positive number corresponding to the major semi-axis length, y_radius a positive number corresponding to the minor semi-axis length and rotation_angle the ellipse's rotation angle with respect to the x-axis.

Options

Styling Options

  • :fill_color (String.t/0) - The fill color of the marks. This will override the color encoding if set.
  • :fill_opacity (number/0) - The fill opacity of the plotted elements. The default value is 1.
  • :line_color (String.t/0) - The color of the line
  • :opacity (number/0) - The overall opacity of the mark
  • :stroke_dash (list of pos_integer/0) - An array of alternating stroke, space lengths in pixels for creating dashed or dotted lines.
  • :stroke_opacity (number/0) - The opacity of the stroke. The default value is 1.
  • :stroke_width (pos_integer/0) - The stroke width in pixels The default value is 1.

Examples

Tucan.layers([
  Tucan.Geometry.ellipse({0, 0}, 5, 3, 0),
  Tucan.Geometry.ellipse({3, 4}, 5, 4, 45, line_color: "red"),
  Tucan.Geometry.ellipse({4, 1}, 7, 2, -30, line_color: "green", stroke_width: 2)
])
|> Tucan.Scale.set_x_domain(-5, 10)
|> Tucan.Scale.set_y_domain(-5, 10)
{"$schema":"https://vega.github.io/schema/vega-lite/v5.json","layer":[{"data":{"sequence":{"as":"theta","start":0,"step":1,"stop":361}},"encoding":{"order":{"field":"theta"},"x":{"field":"x","scale":{"domain":[-5,10]},"type":"quantitative"},"y":{"field":"y","scale":{"domain":[-5,10]},"type":"quantitative"}},"mark":{"fillOpacity":1,"strokeOpacity":1,"strokeWidth":1,"type":"line"},"transform":[{"as":"x","calculate":"0 + cos(datum.theta*PI/180) * cos(0*PI/180) * 5 -sin(datum.theta*PI/180) * sin(0*PI/180) * 3"},{"as":"y","calculate":"0 + cos(datum.theta*PI/180) * sin(0*PI/180) * 5 +sin(datum.theta*PI/180) * cos(0*PI/180) * 3"}]},{"data":{"sequence":{"as":"theta","start":0,"step":1,"stop":361}},"encoding":{"order":{"field":"theta"},"x":{"field":"x","scale":{"domain":[-5,10]},"type":"quantitative"},"y":{"field":"y","scale":{"domain":[-5,10]},"type":"quantitative"}},"mark":{"color":"red","fillOpacity":1,"strokeOpacity":1,"strokeWidth":1,"type":"line"},"transform":[{"as":"x","calculate":"3 + cos(datum.theta*PI/180) * cos(45*PI/180) * 5 -sin(datum.theta*PI/180) * sin(45*PI/180) * 4"},{"as":"y","calculate":"4 + cos(datum.theta*PI/180) * sin(45*PI/180) * 5 +sin(datum.theta*PI/180) * cos(45*PI/180) * 4"}]},{"data":{"sequence":{"as":"theta","start":0,"step":1,"stop":361}},"encoding":{"order":{"field":"theta"},"x":{"field":"x","scale":{"domain":[-5,10]},"type":"quantitative"},"y":{"field":"y","scale":{"domain":[-5,10]},"type":"quantitative"}},"mark":{"color":"green","fillOpacity":1,"strokeOpacity":1,"strokeWidth":2,"type":"line"},"transform":[{"as":"x","calculate":"4 + cos(datum.theta*PI/180) * cos(-30*PI/180) * 7 -sin(datum.theta*PI/180) * sin(-30*PI/180) * 2"},{"as":"y","calculate":"1 + cos(datum.theta*PI/180) * sin(-30*PI/180) * 7 +sin(datum.theta*PI/180) * cos(-30*PI/180) * 2"}]}]}

function(fun, range, opts \\ [])

@spec function(
  fun :: (number() -> number()),
  range :: {number(), number()},
  opts :: keyword()
) ::
  VegaLite.t()

Draws the curve of the function fun in the {min, max} range of x.

The function is sampled at :samples equally spaced points. The curve is broken at the points where the function is not defined, i.e. it raises an arithmetic error or it returns a value that is not a number, e.g. :math.sqrt(x * x - 1) is drawn as two separate branches.

Asymptotes

The curve connects consecutive samples, so a vertical asymptote between two samples, e.g. of 1 / x, is drawn as a steep line. Split the range around it, or return nil near it.

Options

  • :samples (pos_integer/0) - The number of points the curve is sampled at. The default value is 200.

Styling Options

  • :line_color (String.t/0) - The color of the line
  • :opacity (number/0) - The overall opacity of the mark
  • :stroke_dash (list of pos_integer/0) - An array of alternating stroke, space lengths in pixels for creating dashed or dotted lines.
  • :stroke_opacity (number/0) - The opacity of the stroke. The default value is 1.
  • :stroke_width (pos_integer/0) - The stroke width in pixels The default value is 2.

Examples

Tucan.layers([
  Tucan.Geometry.function(&:math.sin/1, {-2 * :math.pi(), 2 * :math.pi()}),
  Tucan.Geometry.function(&:math.cos/1, {-2 * :math.pi(), 2 * :math.pi()}, line_color: "red")
])
|> Tucan.set_width(400)
{"$schema":"https://vega.github.io/schema/vega-lite/v5.json","layer":[{"data":{"values":[{"x":-6.283185307179586,"y":2.4492935982947064e-16},{"x":-6.220037716152656,"y":0.06310563131267372},{"x":-6.1568901251257255,"y":0.12595970506771748},{"x":-6.093742534098794,"y":0.18831166648971848},{"x":-6.030594943071864,"y":0.2499129623703088},{"x":-5.967447352044934,"y":0.3105180318741691},{"x":-5.904299761018003,"y":0.36988528541654697},{"x":-5.841152169991073,"y":0.4277780677102096},{"x":-5.778004578964142,"y":0.4839656011428394},{"x":-5.714856987937211,"y":0.538223905724289},{"x":-5.651709396910281,"y":0.5903366919365287},{"x":-5.588561805883351,"y":0.6400962229271073},{"x":-5.52541421485642,"y":0.6873041426091843},{"x":-5.462266623829489,"y":0.7317722663670773},{"x":-5.399119032802559,"y":0.7733233312153395},{"x":-5.335971441775628,"y":0.8117917024210209},{"x":-5.272823850748698,"y":0.847024033772299},{"x":-5.209676259721768,"y":0.8788798788614604},{"x":-5.146528668694837,"y":0.9072322509454813},{"x":-5.083381077667907,"y":0.9319681291524348},{"x":-5.020233486640976,"y":0.9529889090158394},{"x":-4.957085895614045,"y":0.9702107955409863},{"x":-4.893938304587115,"y":0.98356513723637},{"x":-4.830790713560185,"y":0.9929986997786696},{"x":-4.767643122533254,"y":0.9984738782203788},{"x":-4.704495531506323,"y":0.9999688468941563},{"x":-4.641347940479393,"y":0.9974776464163387},{"x":-4.578200349452462,"y":0.9910102074427921},{"x":-4.515052758425532,"y":0.9805923110824041},{"x":-4.451905167398602,"y":0.9662654861260219},{"x":-4.38875757637167,"y":0.9480868435005093},{"x":-4.32560998534474,"y":0.9261288486078411},{"x":-4.26246239431781,"y":0.9004790324567515},{"x":-4.199314803290879,"y":0.8712396427384596},{"x":-4.136167212263949,"y":0.8385272362373775},{"x":-4.073019621237018,"y":0.8024722142015777},{"x":-4.009872030210088,"y":0.7632183025251688},{"x":-3.946724439183157,"y":0.7209219788147162},{"x":-3.8835768481562267,"y":0.6757518486236087},{"x":-3.8204292571292964,"y":0.6278879733408584},{"x":-3.7572816661023656,"y":0.5775211524135885},{"x":-3.6941340750754352,"y":0.5248521627644683},{"x":-3.6309864840485044,"y":0.47009095843600274},{"x":-3.567838893021574,"y":0.41345583365213395},{"x":-3.5046913019946437,"y":0.3551725526334284},{"x":-3.441543710967713,"y":0.2954734496346698},{"x":-3.3783961199407826,"y":0.23459650279236863},{"x":-3.315248528913852,"y":0.1727843854740992},{"x":-3.2521009378869215,"y":0.11028349891127483},{"x":-3.188953346859991,"y":0.04734298997155796},{"x":-3.1258057558330603,"y":-0.015786242013637264},{"x":-3.06265816480613,"y":-0.0788525454074766},{"x":-2.999510573779199,"y":-0.14160451942495203},{"x":-2.936362982752269,"y":-0.20379201629015234},{"x":-2.8732153917253385,"y":-0.2651671383986787},{"x":-2.8100678006984077,"y":-0.32548522651021206},{"x":-2.7469202096714773,"y":-0.384505835032011},{"x":-2.683772618644547,"y":-0.44199369050557913},{"x":-2.620625027617616,"y":-0.4977196294756834},{"x":-2.557477436590686,"y":-0.5514615120031076},{"x":-2.4943298455637555,"y":-0.6030051071796145},{"x":-2.4311822545368247,"y":-0.6521449471151868},{"x":-2.3680346635098943,"y":-0.6986851459933066},{"x":-2.3048870724829635,"y":-0.7424401809292833},{"x":-2.241739481456033,"y":-0.7832356315188905},{"x":-2.178591890429103,"y":-0.8209088751292626},{"x":-2.1154442994021725,"y":-0.8553097351604118},{"x":-2.052296708375242,"y":-0.8863010796932085},{"x":-1.989149117348311,"y":-0.9137593681374369},{"x":-1.9260015263213806,"y":-0.9375751437008252},{"x":-1.8628539352944502,"y":-0.9576534697159296},{"x":-1.7997063442675199,"y":-0.9739143080855377},{"x":-1.7365587532405895,"y":-0.9862928383380026},{"x":-1.6734111622136592,"y":-0.9947397160206569},{"x":-1.610263571186728,"y":-0.9992212694012756},{"x":-1.5471159801597976,"y":-0.9997196336934779},{"x":-1.4839683891328672,"y":-0.9962328222710067},{"x":-1.4208207981059369,"y":-0.9887747345870026},{"x":-1.3576732070790065,"y":-0.9773751007667073},{"x":-1.2945256160520753,"y":-0.9620793630944627},{"x":-1.231378025025145,"y":-0.942948494867437},{"x":-1.1682304339982146,"y":-0.9200587573381745},{"x":-1.1050828429712842,"y":-0.8935013957148742},{"x":-1.041935251944353,"y":-0.8633822754312231},{"x":-0.9787876609174226,"y":-0.8298214601357256},{"x":-0.9156400698904923,"y":-0.7929527330827785},{"x":-0.8524924788635619,"y":-0.752923063833377},{"x":-0.7893448878366316,"y":-0.709892022391333},{"x":-0.7261972968097012,"y":-0.6640311431104314},{"x":-0.66304970578277,"y":-0.6155232409081789},{"x":-0.5999021147558397,"y":-0.5645616825119179},{"x":-0.5367545237289093,"y":-0.5113496156423266},{"x":-0.47360693270197896,"y":-0.45609915920701605},{"x":-0.4104593416750486,"y":-0.3990305577323412},{"x":-0.34731175064811737,"y":-0.3403713034041124},{"x":-0.284164159621187,"y":-0.2803552292170141},{"x":-0.22101656859425667,"y":-0.2192215768476912},{"x":-0.15786897756732632,"y":-0.1572140429672508},{"x":-0.09472138654039597,"y":-0.09457980779484514},{"x":-0.03157379551346473,"y":-0.03156854976481},{"x":0.03157379551346562,"y":0.03156854976481089},{"x":0.09472138654039597,"y":0.09457980779484514},{"x":0.15786897756732632,"y":0.1572140429672508},{"x":0.22101656859425667,"y":0.2192215768476912},{"x":0.2841641596211879,"y":0.28035522921701495},{"x":0.34731175064811826,"y":0.34037130340411326},{"x":0.4104593416750486,"y":0.3990305577323412},{"x":0.47360693270197896,"y":0.45609915920701605},{"x":0.5367545237289093,"y":0.5113496156423266},{"x":0.5999021147558397,"y":0.5645616825119179},{"x":0.6630497057827709,"y":0.6155232409081796},{"x":0.7261972968097012,"y":0.6640311431104314},{"x":0.7893448878366316,"y":0.709892022391333},{"x":0.8524924788635619,"y":0.752923063833377},{"x":0.9156400698904923,"y":0.7929527330827785},{"x":0.9787876609174235,"y":0.8298214601357261},{"x":1.0419352519443539,"y":0.8633822754312236},{"x":1.1050828429712842,"y":0.8935013957148742},{"x":1.1682304339982146,"y":0.9200587573381745},{"x":1.231378025025145,"y":0.942948494867437},{"x":1.2945256160520753,"y":0.9620793630944627},{"x":1.3576732070790065,"y":0.9773751007667073},{"x":1.4208207981059369,"y":0.9887747345870026},{"x":1.4839683891328672,"y":0.9962328222710067},{"x":1.5471159801597976,"y":0.9997196336934779},{"x":1.610263571186728,"y":0.9992212694012756},{"x":1.6734111622136592,"y":0.9947397160206569},{"x":1.7365587532405886,"y":0.9862928383380029},{"x":1.7997063442675199,"y":0.9739143080855377},{"x":1.8628539352944493,"y":0.9576534697159298},{"x":1.9260015263213806,"y":0.9375751437008252},{"x":1.9891491173483118,"y":0.9137593681374365},{"x":2.0522967083752413,"y":0.8863010796932089},{"x":2.1154442994021725,"y":0.8553097351604118},{"x":2.178591890429102,"y":0.820908875129263},{"x":2.241739481456033,"y":0.7832356315188905},{"x":2.3048870724829644,"y":0.7424401809292828},{"x":2.368034663509894,"y":0.6986851459933069},{"x":2.431182254536825,"y":0.6521449471151864},{"x":2.4943298455637546,"y":0.6030051071796152},{"x":2.557477436590686,"y":0.5514615120031076},{"x":2.6206250276176153,"y":0.49771962947568416},{"x":2.6837726186445465,"y":0.4419936905055795},{"x":2.7469202096714778,"y":0.3845058350320106},{"x":2.8100678006984072,"y":0.32548522651021244},{"x":2.8732153917253385,"y":0.2651671383986787},{"x":2.936362982752268,"y":0.20379201629015323},{"x":2.999510573779199,"y":0.14160451942495203},{"x":3.0626581648061304,"y":0.07885254540747616},{"x":3.12580575583306,"y":0.015786242013637708},{"x":3.188953346859991,"y":-0.04734298997155796},{"x":3.2521009378869206,"y":-0.11028349891127395},{"x":3.315248528913852,"y":-0.1727843854740992},{"x":3.378396119940783,"y":-0.23459650279236907},{"x":3.4415437109677125,"y":-0.29547344963466937},{"x":3.5046913019946437,"y":-0.3551725526334284},{"x":3.567838893021573,"y":-0.4134558336521331},{"x":3.6309864840485044,"y":-0.47009095843600274},{"x":3.6941340750754357,"y":-0.5248521627644687},{"x":3.757281666102365,"y":-0.577521152413588},{"x":3.8204292571292964,"y":-0.6278879733408584},{"x":3.883576848156226,"y":-0.675751848623608},{"x":3.946724439183157,"y":-0.7209219788147162},{"x":4.0098720302100865,"y":-0.7632183025251676},{"x":4.073019621237018,"y":-0.8024722142015777},{"x":4.136167212263947,"y":-0.8385272362373765},{"x":4.19931480329088,"y":-0.87123964273846},{"x":4.26246239431781,"y":-0.9004790324567515},{"x":4.325609985344741,"y":-0.9261288486078414},{"x":4.38875757637167,"y":-0.9480868435005093},{"x":4.451905167398602,"y":-0.9662654861260219},{"x":4.515052758425531,"y":-0.980592311082404},{"x":4.578200349452462,"y":-0.9910102074427921},{"x":4.641347940479392,"y":-0.9974776464163387},{"x":4.704495531506323,"y":-0.9999688468941563},{"x":4.7676431225332525,"y":-0.9984738782203789},{"x":4.830790713560184,"y":-0.9929986997786697},{"x":4.893938304587115,"y":-0.98356513723637},{"x":4.957085895614046,"y":-0.9702107955409861},{"x":5.020233486640976,"y":-0.9529889090158394},{"x":5.083381077667907,"y":-0.9319681291524348},{"x":5.146528668694836,"y":-0.9072322509454817},{"x":5.209676259721768,"y":-0.8788798788614604},{"x":5.272823850748697,"y":-0.8470240337722994},{"x":5.335971441775628,"y":-0.8117917024210209},{"x":5.399119032802558,"y":-0.77332333121534},{"x":5.462266623829489,"y":-0.7317722663670773},{"x":5.52541421485642,"y":-0.6873041426091843},{"x":5.5885618058833515,"y":-0.6400962229271067},{"x":5.651709396910281,"y":-0.5903366919365287},{"x":5.714856987937212,"y":-0.5382239057242882},{"x":5.778004578964142,"y":-0.4839656011428394},{"x":5.841152169991073,"y":-0.4277780677102096},{"x":5.904299761018002,"y":-0.3698852854165478},{"x":5.967447352044934,"y":-0.3105180318741691},{"x":6.030594943071863,"y":-0.24991296237030966},{"x":6.093742534098794,"y":-0.18831166648971848},{"x":6.156890125125724,"y":-0.12595970506771922},{"x":6.220037716152657,"y":-0.06310563131267283},{"x":6.283185307179586,"y":-2.4492935982947064e-16}]},"encoding":{"x":{"field":"x","type":"quantitative"},"y":{"field":"y","type":"quantitative"}},"mark":{"strokeOpacity":1,"strokeWidth":2,"type":"line"}},{"data":{"values":[{"x":-6.283185307179586,"y":1.0},{"x":-6.220037716152656,"y":0.9980068533314933},{"x":-6.1568901251257255,"y":0.9920353585932579},{"x":-6.093742534098794,"y":0.9821093199149803},{"x":-6.030594943071864,"y":0.9682683053985071},{"x":-5.967447352044934,"y":0.9505674893877828},{"x":-5.904299761018003,"y":0.9290774325277305},{"x":-5.841152169991073,"y":0.9038838004888236},{"x":-5.778004578964142,"y":0.8750870224785934},{"x":-5.714856987937211,"y":0.8428018909013504},{"x":-5.651709396910281,"y":0.8071571037619851},{"x":-5.588561805883351,"y":0.7682947516379706},{"x":-5.52541421485642,"y":0.7263697512646394},{"x":-5.462266623829489,"y":0.6815492279916333},{"x":-5.399119032802559,"y":0.6340118495722382},{"x":-5.335971441775628,"y":0.5839471139413059},{"x":-5.272823850748698,"y":0.5315545938209012},{"x":-5.209676259721768,"y":0.47704314116488955},{"x":-5.146528668694837,"y":0.42063005461378433},{"x":-5.083381077667907,"y":0.36254021327862473},{"x":-5.020233486640976,"y":0.3030051803068723},{"x":-4.957085895614045,"y":0.24226227980378293},{"x":-4.893938304587115,"y":0.1805536507889021},{"x":-4.830790713560185,"y":0.11812528195890803},{"x":-4.767643122533254,"y":0.05522603110450836},{"x":-4.704495531506323,"y":-0.007893366909713777},{"x":-4.641347940479393,"y":-0.07098129964801624},{"x":-4.578200349452462,"y":-0.13378628010447927},{"x":-4.515052758425532,"y":-0.19605794920397804},{"x":-4.451905167398602,"y":-0.2575480738068965},{"x":-4.38875757637167,"y":-0.3180115362392388},{"x":-4.32560998534474,"y":-0.37720731140357633},{"x":-4.26246239431781,"y":-0.4348994275757932},{"x":-4.199314803290879,"y":-0.49085790705759375},{"x":-4.136167212263949,"y":-0.5448596829350704},{"x":-4.073019621237018,"y":-0.5966894882888565},{"x":-4.009872030210088,"y":-0.6461407143112093},{"x":-3.946724439183157,"y":-0.693016233909332},{"x":-3.8835768481562267,"y":-0.737129187511779},{"x":-3.8204292571292964,"y":-0.7783037279455299},{"x":-3.7572816661023656,"y":-0.8163757214143992},{"x":-3.6941340750754352,"y":-0.8511934017844947},{"x":-3.6309864840485044,"y":-0.882617975568547},{"x":-3.567838893021574,"y":-0.9105241751974622},{"x":-3.5046913019946437,"y":-0.9348007583735983},{"x":-3.441543710967713,"y":-0.9553509515151949},{"x":-3.3783961199407826,"y":-0.972092835524257},{"x":-3.315248528913852,"y":-0.9849596723401105},{"x":-3.2521009378869215,"y":-0.9939001709768879},{"x":-3.188953346859991,"y":-0.9988786919844436},{"x":-3.1258057558330603,"y":-0.9998753895176573},{"x":-3.06265816480613,"y":-0.9968862904477932},{"x":-2.999510573779199,"y":-0.9899233102005571},{"x":-2.936362982752269,"y":-0.9790142052577144},{"x":-2.8732153917253385,"y":-0.9642024625116117},{"x":-2.8100678006984077,"y":-0.945547125913667},{"x":-2.7469202096714773,"y":-0.9231225611078606},{"x":-2.683772618644547,"y":-0.8970181589874635},{"x":-2.620625027617616,"y":-0.8673379793567145},{"x":-2.557477436590686,"y":-0.8342003361179174},{"x":-2.4943298455637555,"y":-0.7977373256375193},{"x":-2.4311822545368247,"y":-0.7580943001712453},{"x":-2.3680346635098943,"y":-0.7154292884473712},{"x":-2.3048870724829635,"y":-0.669912365717855},{"x":-2.241739481456033,"y":-0.6217249757884951},{"x":-2.178591890429103,"y":-0.5710592077306947},{"x":-2.1154442994021725,"y":-0.5181170301580775},{"x":-2.052296708375242,"y":-0.4631094861203481},{"x":-1.989149117348311,"y":-0.40625585182378865},{"x":-1.9260015263213806,"y":-0.34778276253198215},{"x":-1.8628539352944502,"y":-0.28792330913116637},{"x":-1.7997063442675199,"y":-0.22691610896159026},{"x":-1.7365587532405895,"y":-0.16500435461879953},{"x":-1.6734111622136592,"y":-0.10243484451661374},{"x":-1.610263571186728,"y":-0.039456999076252476},{"x":-1.5471159801597976,"y":0.0236781335366241},{"x":-1.4839683891328672,"y":0.08671887816355073},{"x":-1.4208207981059369,"y":0.14941393590426072},{"x":-1.3576732070790065,"y":0.21151338586781865},{"x":-1.2945256160520753,"y":0.27276968143060343},{"x":-1.231378025025145,"y":0.3329386370297613},{"x":-1.1682304339982146,"y":0.39178040155849314},{"x":-1.1050828429712842,"y":0.44906041448292},{"x":-1.041935251944353,"y":0.5045503408691779},{"x":-0.9787876609174226,"y":0.5580289815934405},{"x":-0.9156400698904923,"y":0.6092831551065169},{"x":-0.8524924788635619,"y":0.6581085472380377},{"x":-0.7893448878366316,"y":0.704310525652672},{"x":-0.7261972968097012,"y":0.7477049157117089},{"x":-0.66304970578277,"y":0.7881187346471926},{"x":-0.5999021147558397,"y":0.8253908811219763},{"x":-0.5367545237289093,"y":0.859372777426912},{"x":-0.47360693270197896,"y":0.8899289617551802},{"x":-0.4104593416750486,"y":0.9169376281927887},{"x":-0.34731175064811737,"y":0.9402911122726757},{"x":-0.284164159621187,"y":0.9598963201568571},{"x":-0.22101656859425667,"y":0.9756750997357736},{"x":-0.15786897756732632,"y":0.9875645521655237},{"x":-0.09472138654039597,"y":0.995517282601106},{"x":-0.03157379551346473,"y":0.9995015891261738},{"x":0.03157379551346562,"y":0.9995015891261737},{"x":0.09472138654039597,"y":0.995517282601106},{"x":0.15786897756732632,"y":0.9875645521655237},{"x":0.22101656859425667,"y":0.9756750997357736},{"x":0.2841641596211879,"y":0.9598963201568569},{"x":0.34731175064811826,"y":0.9402911122726754},{"x":0.4104593416750486,"y":0.9169376281927887},{"x":0.47360693270197896,"y":0.8899289617551802},{"x":0.5367545237289093,"y":0.859372777426912},{"x":0.5999021147558397,"y":0.8253908811219763},{"x":0.6630497057827709,"y":0.7881187346471921},{"x":0.7261972968097012,"y":0.7477049157117089},{"x":0.7893448878366316,"y":0.704310525652672},{"x":0.8524924788635619,"y":0.6581085472380377},{"x":0.9156400698904923,"y":0.6092831551065169},{"x":0.9787876609174235,"y":0.5580289815934397},{"x":1.0419352519443539,"y":0.5045503408691772},{"x":1.1050828429712842,"y":0.44906041448292},{"x":1.1682304339982146,"y":0.39178040155849314},{"x":1.231378025025145,"y":0.3329386370297613},{"x":1.2945256160520753,"y":0.27276968143060343},{"x":1.3576732070790065,"y":0.21151338586781865},{"x":1.4208207981059369,"y":0.14941393590426072},{"x":1.4839683891328672,"y":0.08671887816355073},{"x":1.5471159801597976,"y":0.0236781335366241},{"x":1.610263571186728,"y":-0.039456999076252476},{"x":1.6734111622136592,"y":-0.10243484451661374},{"x":1.7365587532405886,"y":-0.16500435461879867},{"x":1.7997063442675199,"y":-0.22691610896159026},{"x":1.8628539352944493,"y":-0.28792330913116554},{"x":1.9260015263213806,"y":-0.34778276253198215},{"x":1.9891491173483118,"y":-0.4062558518237895},{"x":2.0522967083752413,"y":-0.4631094861203473},{"x":2.1154442994021725,"y":-0.5181170301580775},{"x":2.178591890429102,"y":-0.5710592077306941},{"x":2.241739481456033,"y":-0.6217249757884951},{"x":2.3048870724829644,"y":-0.6699123657178556},{"x":2.368034663509894,"y":-0.715429288447371},{"x":2.431182254536825,"y":-0.7580943001712456},{"x":2.4943298455637546,"y":-0.7977373256375189},{"x":2.557477436590686,"y":-0.8342003361179174},{"x":2.6206250276176153,"y":-0.8673379793567141},{"x":2.6837726186445465,"y":-0.8970181589874633},{"x":2.7469202096714778,"y":-0.9231225611078608},{"x":2.8100678006984072,"y":-0.9455471259136669},{"x":2.8732153917253385,"y":-0.9642024625116117},{"x":2.936362982752268,"y":-0.9790142052577143},{"x":2.999510573779199,"y":-0.9899233102005571},{"x":3.0626581648061304,"y":-0.9968862904477932},{"x":3.12580575583306,"y":-0.9998753895176573},{"x":3.188953346859991,"y":-0.9988786919844436},{"x":3.2521009378869206,"y":-0.9939001709768879},{"x":3.315248528913852,"y":-0.9849596723401105},{"x":3.378396119940783,"y":-0.9720928355242568},{"x":3.4415437109677125,"y":-0.955350951515195},{"x":3.5046913019946437,"y":-0.9348007583735983},{"x":3.567838893021573,"y":-0.9105241751974626},{"x":3.6309864840485044,"y":-0.882617975568547},{"x":3.6941340750754357,"y":-0.8511934017844944},{"x":3.757281666102365,"y":-0.8163757214143995},{"x":3.8204292571292964,"y":-0.7783037279455299},{"x":3.883576848156226,"y":-0.7371291875117796},{"x":3.946724439183157,"y":-0.693016233909332},{"x":4.0098720302100865,"y":-0.6461407143112108},{"x":4.073019621237018,"y":-0.5966894882888565},{"x":4.136167212263947,"y":-0.5448596829350718},{"x":4.19931480329088,"y":-0.49085790705759297},{"x":4.26246239431781,"y":-0.4348994275757932},{"x":4.325609985344741,"y":-0.37720731140357555},{"x":4.38875757637167,"y":-0.3180115362392388},{"x":4.451905167398602,"y":-0.2575480738068965},{"x":4.515052758425531,"y":-0.1960579492039789},{"x":4.578200349452462,"y":-0.13378628010447927},{"x":4.641347940479392,"y":-0.07098129964801712},{"x":4.704495531506323,"y":-0.007893366909713777},{"x":4.7676431225332525,"y":0.05522603110450659},{"x":4.830790713560184,"y":0.11812528195890715},{"x":4.893938304587115,"y":0.1805536507889021},{"x":4.957085895614046,"y":0.2422622798037838},{"x":5.020233486640976,"y":0.3030051803068723},{"x":5.083381077667907,"y":0.36254021327862473},{"x":5.146528668694836,"y":0.42063005461378355},{"x":5.209676259721768,"y":0.47704314116488955},{"x":5.272823850748697,"y":0.5315545938209005},{"x":5.335971441775628,"y":0.5839471139413059},{"x":5.399119032802558,"y":0.6340118495722376},{"x":5.462266623829489,"y":0.6815492279916333},{"x":5.52541421485642,"y":0.7263697512646394},{"x":5.5885618058833515,"y":0.7682947516379712},{"x":5.651709396910281,"y":0.8071571037619851},{"x":5.714856987937212,"y":0.8428018909013508},{"x":5.778004578964142,"y":0.8750870224785934},{"x":5.841152169991073,"y":0.9038838004888236},{"x":5.904299761018002,"y":0.9290774325277301},{"x":5.967447352044934,"y":0.9505674893877828},{"x":6.030594943071863,"y":0.9682683053985068},{"x":6.093742534098794,"y":0.9821093199149803},{"x":6.156890125125724,"y":0.9920353585932576},{"x":6.220037716152657,"y":0.9980068533314934},{"x":6.283185307179586,"y":1.0}]},"encoding":{"x":{"field":"x","type":"quantitative"},"y":{"field":"y","type":"quantitative"}},"mark":{"color":"red","strokeOpacity":1,"strokeWidth":2,"type":"line"}}],"width":400}

The probability density of a normal distribution on top of a histogram of samples:

:rand.seed(:exsss, {1, 2, 3})
samples = for _i <- 1..1000, do: %{x: :rand.normal()}

pdf = fn x -> :math.exp(-x * x / 2) / :math.sqrt(2 * :math.pi()) end

Tucan.layers([
  Tucan.histogram(samples, "x", relative: true, extent: [-4, 4], step: 0.25),
  Tucan.Geometry.function(fn x -> pdf.(x) * 0.25 end, {-4, 4}, line_color: "red")
])
{"$schema":"https://vega.github.io/schema/vega-lite/v5.json","layer":[{"__tucan__":{"plot":"histogram","types":{"x":"quantitative"}},"data":{"values":[{"x":1.3701979225129497},{"x":-0.4791401670399548},{"x":0.6374730107805405},{"x":-0.2501880404299785},{"x":0.5727512609749593},{"x":0.45910108275051},{"x":0.2238340534960041},{"x":-0.11180420313893616},{"x":-0.12511847380466934},{"x":1.7952146163740228},{"x":-0.12994936314694408},{"x":-0.4410686813295704},{"x":0.3296701405980617},{"x":-0.046562364645855434},{"x":0.05712666835779042},{"x":-0.7959029195972719},{"x":1.023106778481699},{"x":-2.4703760676523845},{"x":-0.6434645844503831},{"x":-0.08573710377110731},{"x":1.042278716695873},{"x":-0.23550803022956487},{"x":1.5055183023673628},{"x":-1.0313278219103874},{"x":-0.767629710676568},{"x":-0.4554983851654827},{"x":-0.4615485617648312},{"x":0.6131226371009405},{"x":2.194616161023561},{"x":-1.3146335825987687},{"x":1.302207199408869},{"x":3.5147481423387674},{"x":1.3719406542121526},{"x":-0.6633824495512117},{"x":-0.6309072535394753},{"x":-0.19610883855666034},{"x":-2.0523749619241225},{"x":1.770149276803938},{"x":0.9154726224835465},{"x":0.8100909801681376},{"x":-1.316192648231033},{"x":0.36684646166040025},{"x":1.4434425249450271},{"x":-0.6816462015766026},{"x":0.07294375680821547},{"x":2.5508664136700556},{"x":-1.7333479146817616},{"x":-0.5070551023930108},{"x":-1.691299344189073},{"x":1.1935202251618044},{"x":1.2899796741337117},{"x":1.0415984932266351},{"x":-0.4535765866479045},{"x":0.18044332881579553},{"x":-0.4199900442547548},{"x":0.8647097942285099},{"x":-1.708677795822235},{"x":1.2408394270003535},{"x":-1.4466055558139421},{"x":0.645056640822826},{"x":-1.0277157331022404},{"x":-0.19091713006917138},{"x":0.9960141887223527},{"x":-0.6792159532534762},{"x":0.5309718411508015},{"x":-1.4495246700511497},{"x":0.9864771904667895},{"x":-0.1868109063929933},{"x":0.056022987311095854},{"x":0.5678600313047164},{"x":-1.1611818818693196},{"x":-0.0868342478436431},{"x":0.8358113854068172},{"x":-0.05890673105933251},{"x":0.35463122420911847},{"x":-0.8940815558190867},{"x":0.8291843731588342},{"x":1.584534199920412},{"x":-1.1325480392094158},{"x":-2.2058447462971653},{"x":-0.7571964692486773},{"x":-0.5728815468561356},{"x":-0.1627899832002307},{"x":1.0921306393553225},{"x":1.1145213700477539},{"x":0.6871849783835051},{"x":0.49549035297925537},{"x":1.5640356636728001},{"x":-0.3046420388220478},{"x":0.8617809976082902},{"x":0.49978543025436134},{"x":-0.7793125946067441},{"x":-0.4729515245786556},{"x":0.6038176904424202},{"x":0.21509078455446445},{"x":-0.4442453967298079},{"x":-1.7663153071836057},{"x":-1.8176895033357576},{"x":0.48410064998391034},{"x":0.17486683546365547},{"x":0.8833106338865196},{"x":-1.433922136052888},{"x":-1.7855657415972852},{"x":1.529296304030297},{"x":-0.9363779016813901},{"x":0.04010905992625586},{"x":0.4470629617867824},{"x":-0.9864535388714184},{"x":-0.27283502847434976},{"x":-0.8140205654247405},{"x":2.382461680715212},{"x":0.14475846584340915},{"x":-0.003031922017951314},{"x":-1.3646449364155366},{"x":2.6998253750368804},{"x":-0.7028165652548067},{"x":-1.040123496127826},{"x":-0.4495579834583083},{"x":-0.3404604141198811},{"x":-0.5310096559182576},{"x":-1.2935165211287127},{"x":-1.518622818466113},{"x":0.0700775310550424},{"x":0.5115560637589435},{"x":-0.24511120277800336},{"x":-1.522212230621351},{"x":1.3515007210578063},{"x":1.2311444076277251},{"x":0.6587593172519465},{"x":0.896228259610129},{"x":-0.7230100282086914},{"x":-0.5438935612641509},{"x":-1.6683695822463878},{"x":-0.2818986870787806},{"x":1.0212818738569416},{"x":0.013507164063042457},{"x":-0.8189972609444137},{"x":-0.3872834283251137},{"x":-1.1440519481820761},{"x":0.5653545209967762},{"x":0.8027409731469567},{"x":1.4821339108666687},{"x":0.10362990371208648},{"x":0.1117825047077907},{"x":-1.059555687481379},{"x":0.6755413839388611},{"x":0.45588239649827134},{"x":-0.7475798433608865},{"x":-0.8032754215580272},{"x":0.3667778749266763},{"x":1.2474040383467737},{"x":0.4377964383337589},{"x":1.370238022251621},{"x":0.8680406750066817},{"x":0.674983482509018},{"x":0.7841034211684568},{"x":0.406766019840064},{"x":-0.9218437101721597},{"x":2.3748769998989108},{"x":0.19225965907924772},{"x":-0.46367790083729093},{"x":-0.19259327326333922},{"x":-0.23055412929877386},{"x":-1.8061069079872905},{"x":0.5470728894342335},{"x":-0.8005968668873833},{"x":-0.5680093469815681},{"x":0.776758968713136},{"x":0.7872222614398003},{"x":0.7694132072752115},{"x":0.03336110498995437},{"x":0.27673884463992815},{"x":-0.622056561191541},{"x":0.6031927188526623},{"x":-1.2905429930279206},{"x":0.7316690508203871},{"x":-0.8304640934792359},{"x":-0.6032113549753678},{"x":0.32719890164978127},{"x":2.030494908768484},{"x":-0.0634548088162363},{"x":-0.39330405186753076},{"x":-0.18151587947899972},{"x":-0.9339611333319937},{"x":1.1389741307088685},{"x":-0.25355015038423095},{"x":-1.638595423295253},{"x":-0.5818199152621366},{"x":0.30272783318853264},{"x":0.4779215045409801},{"x":0.3503049452738142},{"x":0.8320782510891536},{"x":1.303388818718256},{"x":-1.1069007088854312},{"x":0.6559573700923714},{"x":0.13077105880357714},{"x":0.8776058803228546},{"x":0.5856550953221874},{"x":0.1087258469699818},{"x":0.2619542874558929},{"x":-0.5521732838401773},{"x":0.1612735598031471},{"x":-0.7849737943741993},{"x":1.081775193585558},{"x":-1.5964522966148866},{"x":-0.39355313610964543},{"x":-0.4774965258093042},{"x":0.30620684324785546},{"x":1.8527676498182872},{"x":-0.6539169368657303},{"x":2.212310967376204},{"x":0.0712768276898651},{"x":-1.7809662047104522},{"x":2.3944876989987147},{"x":1.034382545248188},{"x":-1.0129251748765957},{"x":-1.5227581128310435},{"x":0.3942496625830007},{"x":0.7726555495000494},{"x":-0.07901048281716758},{"x":1.4359603942376524},{"x":0.23177688240889516},{"x":0.05386614658207557},{"x":1.6402371841302004},{"x":-0.016360207360993896},{"x":1.2736156240740928},{"x":-0.6959549399999786},{"x":0.9754120541248612},{"x":1.2164855148795044},{"x":0.591911406042547},{"x":0.20030661101557223},{"x":0.22459516732467918},{"x":-0.1220697611468238},{"x":-2.5691873944804606},{"x":0.4232114678956263},{"x":0.11816638206685133},{"x":0.8647237302952302},{"x":-0.08934265054136582},{"x":0.7448020106237564},{"x":-0.4496194845696534},{"x":-0.11390771105979731},{"x":1.0547438459432041},{"x":-0.5037952089659397},{"x":1.685593820530007},{"x":0.2220574054214182},{"x":-1.2519733133268711},{"x":-0.6818946686247551},{"x":-2.7582882383681198},{"x":-0.6729236335430907},{"x":0.8236789258577516},{"x":0.786355520514318},{"x":0.31438419378053534},{"x":-0.9888111616044121},{"x":0.666815214298925},{"x":-0.6846050744174625},{"x":-0.21766827500963332},{"x":0.6555061264642705},{"x":0.12624538076666553},{"x":0.9413819037541594},{"x":0.1344880870592451},{"x":-2.1666762671338855},{"x":1.1543765476658507},{"x":-2.2258490092795458},{"x":-0.018862499073165756},{"x":-0.7292953218103114},{"x":0.5549154132882864},{"x":0.09544123439328797},{"x":-0.41611066359337595},{"x":0.6070523766569828},{"x":0.6345275609773975},{"x":-1.2210885744443614},{"x":-0.08175546851478671},{"x":-0.1579367283614106},{"x":-1.0673686651108323},{"x":-0.8550931495851953},{"x":-0.9390758236669096},{"x":-0.5948953738654349},{"x":0.07204834129316069},{"x":1.7578993623207508},{"x":-1.0544461513376016},{"x":2.4978043938008896},{"x":-0.551289343565263},{"x":0.5461207796212935},{"x":-0.5013357089427323},{"x":0.24171649235736842},{"x":0.09954544177762886},{"x":1.219665300140447},{"x":-0.31430373368670433},{"x":1.1078234181738649},{"x":-1.648392945801348},{"x":-0.6387930913101639},{"x":0.3375232932506025},{"x":-0.3779874008611368},{"x":0.2672141117424142},{"x":-0.7025051731285873},{"x":0.906488880814483},{"x":0.3334768859869908},{"x":-0.7156037760259614},{"x":0.10768655191759546},{"x":-0.5846656347781214},{"x":-1.4325374062049416},{"x":0.2840099010021605},{"x":0.9745736635770235},{"x":0.12903876018457824},{"x":0.2808712164093034},{"x":0.47255904453342756},{"x":-0.8917920264989585},{"x":-0.2725910506554815},{"x":-0.8932567040875105},{"x":-0.47154188067758573},{"x":1.4041001297673144},{"x":-0.602462212123463},{"x":-0.8792042846820631},{"x":1.8562482218420293},{"x":-0.48061258734550744},{"x":0.0856698679071109},{"x":0.12124173438285582},{"x":0.3251409372395636},{"x":-0.9223435342790314},{"x":-1.6234429164365392},{"x":-0.6347168959392157},{"x":-0.8256896912864858},{"x":-0.788580316468621},{"x":-0.3507143930853534},{"x":-1.8671362690093718},{"x":-0.9978931980618616},{"x":0.1247143711952109},{"x":-0.20113540035939795},{"x":-0.8100027783152481},{"x":1.3752220269669595},{"x":0.7494856670456942},{"x":0.25082006637205734},{"x":-0.7667048450078999},{"x":1.3439958341499034},{"x":-0.9770303596189507},{"x":-0.8394842032450526},{"x":-0.7781579546729324},{"x":0.5350872206759562},{"x":-0.6601222220470125},{"x":-1.2245735703068503},{"x":0.043699234100431375},{"x":-0.542817777788033},{"x":0.9225395536343076},{"x":1.1827298797167893},{"x":0.15128061097398482},{"x":0.44956342240423675},{"x":-0.22347034903140725},{"x":-0.6176950255901485},{"x":-0.7551334048458822},{"x":0.11341543445904427},{"x":-0.16536519075460512},{"x":-2.2598009495071794},{"x":0.4227171751813572},{"x":0.8369122163721024},{"x":-0.8919137758161633},{"x":1.6243628969880275},{"x":-2.0047383043028657},{"x":0.8165487669456942},{"x":-0.016489958574821315},{"x":1.2245671858573774},{"x":1.1423021463746792},{"x":-0.6908597575912426},{"x":-0.07278900961660625},{"x":1.000153154098402},{"x":-0.11443652214175824},{"x":-0.8006110390129456},{"x":-0.6173861670113197},{"x":-0.622150598213257},{"x":-0.7552961509448514},{"x":0.33513992147736943},{"x":0.8860783149627993},{"x":1.03377386565195},{"x":-0.40513645131592596},{"x":-3.302102941148077},{"x":0.7253898792539218},{"x":0.06617589035545086},{"x":-0.9980848844676066},{"x":-0.8571152183488364},{"x":1.1442271465192968},{"x":-1.0904618584791903},{"x":0.06126118271230899},{"x":-0.383576460271114},{"x":-0.28614474081537233},{"x":0.11907857836169766},{"x":1.0747683881253727},{"x":1.7842685890924697},{"x":-1.623450072937926},{"x":0.3850197904618536},{"x":-0.31208734528408716},{"x":0.41528149528010966},{"x":0.8516918860522951},{"x":-1.1388961209171156},{"x":-0.5994621685584207},{"x":-0.06511541139231375},{"x":-1.4545374468072383},{"x":-1.0835719313707988},{"x":-1.0253892004388663},{"x":0.9318959519001188},{"x":0.23634633533032043},{"x":-2.053193782923056},{"x":0.3579379867038877},{"x":0.17728356896333994},{"x":2.0995370682374666},{"x":-1.0243638651995781},{"x":0.7674011070681706},{"x":-0.6525721741062807},{"x":1.0666072417570764},{"x":0.2807394393681727},{"x":1.0373228697686079},{"x":-1.9056659601263162},{"x":-0.26430145475552697},{"x":1.1056211527811766},{"x":-0.1255457343903395},{"x":-0.03943031633614205},{"x":-0.4906958104848306},{"x":-1.5761593822572726},{"x":0.2187071111112565},{"x":-0.03618218123660839},{"x":0.3412431508338108},{"x":1.039715237131688},{"x":0.1811443831484754},{"x":-0.5202227486358422},{"x":1.4590707793469027},{"x":-0.8948870409212998},{"x":0.9657655329827445},{"x":-0.8237535060501041},{"x":2.74354704212504},{"x":-0.006196884751690855},{"x":1.2462374142583115},{"x":-1.568660644183731},{"x":-0.7886684281434888},{"x":0.6493143421610642},{"x":0.006365194725511858},{"x":0.021117954304253908},{"x":1.2346848328469515},{"x":0.32537772713705193},{"x":-0.12976437962787385},{"x":-0.1835112869491435},{"x":-0.9444001137209526},{"x":2.547422627095649},{"x":-0.0926620300680233},{"x":0.7526855707776329},{"x":-2.655535738359361},{"x":1.26717019095809},{"x":0.42032887703382926},{"x":-0.367248234966466},{"x":1.5101440795364494},{"x":0.8715274637094333},{"x":0.9957923350778749},{"x":0.4809526130903273},{"x":-0.49400382906227963},{"x":1.1833807902888414},{"x":-0.5229597131415146},{"x":0.34550086316688694},{"x":0.37390988487906496},{"x":-0.8349414274960187},{"x":0.8710955865257725},{"x":0.374869275242461},{"x":0.1734768496599663},{"x":1.4998610445557055},{"x":-0.08281352477794489},{"x":0.012829244344220633},{"x":-1.1771586034283124},{"x":0.14178124179913443},{"x":-0.8893628125584835},{"x":-0.38764395658400375},{"x":0.8361740537704301},{"x":0.1358542540104138},{"x":2.7631455062790318},{"x":1.4806974258784837},{"x":-0.016374950000493424},{"x":0.2890276488845179},{"x":0.8824452954073758},{"x":1.5546179156766178},{"x":-0.4313061820426603},{"x":0.503237021904276},{"x":1.9741744608864453},{"x":-1.3517026016861937},{"x":0.9870285551960719},{"x":0.5627747003020286},{"x":-0.19769076852555384},{"x":-0.93455473542598},{"x":-1.1476326188438972},{"x":-0.6686357322713162},{"x":-1.7674235046326514},{"x":1.0847538175358495},{"x":-0.5338633700256383},{"x":-0.9235602172106071},{"x":0.9579456086299035},{"x":2.8471059829802012},{"x":0.41465144637749607},{"x":-0.6713186664062465},{"x":-0.8318188478081471},{"x":-1.3495610717868083},{"x":-1.0415591435259233},{"x":0.5350842504349769},{"x":-0.2378567934309013},{"x":-0.22371659064753122},{"x":-3.0095275922048743},{"x":-0.41337212886908387},{"x":0.24650698090864068},{"x":-0.5686077124734928},{"x":1.0909611450562715},{"x":-0.9018410204270545},{"x":0.7821617842578652},{"x":-1.2152888646327102},{"x":-0.18603334492285292},{"x":0.1929838940961302},{"x":0.7647992888779581},{"x":1.153618711930098},{"x":0.16034478668525032},{"x":0.8525339958548865},{"x":-0.2027020368430909},{"x":-0.11272880420064828},{"x":1.7264656744508384},{"x":-0.9892956563732267},{"x":-0.6166495471450537},{"x":-0.3240471998209265},{"x":0.7270655783294688},{"x":0.03630611982836427},{"x":-0.8014752094283593},{"x":0.8402538041074942},{"x":-0.6317676767168817},{"x":-1.1074595043749385},{"x":-0.3443270050824893},{"x":0.4147853449090576},{"x":-2.318064989620501},{"x":0.14952114010790957},{"x":-1.9087736563923599},{"x":-1.1477624771794057},{"x":-0.032625130155671395},{"x":0.8113387207829003},{"x":-0.450470568212857},{"x":0.3031786708070423},{"x":-0.48363399337892743},{"x":-1.1998155812742972},{"x":-1.1621585223053166},{"x":-1.9380148514427404},{"x":-1.6178261990261147},{"x":0.6976753596705328},{"x":0.8869032432816961},{"x":-1.8166354021227364},{"x":-0.7868062261450811},{"x":1.097811752159158},{"x":0.33804440938525004},{"x":-1.8143763514615385},{"x":0.4108960203451826},{"x":0.31369303288316636},{"x":-0.4591602418660182},{"x":-1.7130653114264678},{"x":-0.5905360490772315},{"x":1.0891844136707358},{"x":1.23410969753174},{"x":1.0413242567742438},{"x":0.9708501485131734},{"x":0.940314511798558},{"x":-0.2781180778840911},{"x":1.6818243668673711},{"x":-1.1045181355709077},{"x":0.8862371695584047},{"x":-0.4476631123071328},{"x":1.7573121706412729},{"x":0.9813787525395204},{"x":-0.6165034581925176},{"x":-2.0883131497120195},{"x":0.002066331535005266},{"x":0.7998233096719084},{"x":-1.5594513721927332},{"x":1.644628377692217},{"x":1.0485055021128153},{"x":-0.38244474703086867},{"x":0.20431861696294729},{"x":1.3554414907123868},{"x":0.9344156118528598},{"x":-0.77203655102819},{"x":0.4852116169494572},{"x":1.0757765035116555},{"x":-0.862147857124648},{"x":-0.8201811193561863},{"x":1.5964632581339093},{"x":-1.0726918510616665},{"x":-2.7878002070354237},{"x":2.0198748802074813},{"x":0.9231126445785858},{"x":1.454418782801007},{"x":-0.24987693599294802},{"x":-0.5388280761926352},{"x":-0.7951750252019308},{"x":-0.9569825561607507},{"x":-1.34174507084532},{"x":1.6990106511839396},{"x":0.39733925149807686},{"x":-0.39267041101586264},{"x":-0.8432090099865979},{"x":-0.018082320393936962},{"x":1.0969804814725979},{"x":-0.3644484354126527},{"x":-0.3798086887183122},{"x":1.0530764882872239},{"x":0.03419585869449604},{"x":-0.015069921669298781},{"x":0.6795715709558959},{"x":0.8958292631137579},{"x":-0.2117267287279033},{"x":-0.4704622536598848},{"x":-0.7100658002948221},{"x":-1.0720202887380308},{"x":1.4871468417560936},{"x":0.60928045746678},{"x":-0.20401448132679204},{"x":0.5746365608731416},{"x":0.9520244252867436},{"x":-0.10034483280211529},{"x":0.4633210840912397},{"x":0.5459907956975668},{"x":0.18995121233710308},{"x":0.6615567821733275},{"x":-0.852080922945196},{"x":-1.4953961675588157},{"x":-0.33120028782502303},{"x":0.8298490726130885},{"x":-0.2477684038960959},{"x":-0.6719578645755},{"x":-1.047095925779638},{"x":-1.580701402928947},{"x":-0.568116824184171},{"x":-0.6016654035623106},{"x":0.8024146314846341},{"x":0.20173749039670047},{"x":-0.30159283996137626},{"x":1.2659255499828037},{"x":-0.7226550479885913},{"x":-0.16492108468787398},{"x":-0.7104784124911726},{"x":-0.316137958054929},{"x":-0.8760030290611829},{"x":-0.16655413572189798},{"x":-1.3990445158338722},{"x":0.6873946153349595},{"x":0.0012491953056428015},{"x":-0.0034809241407643423},{"x":-0.2388447212799534},{"x":-1.3946462844844199},{"x":-0.35478753189606843},{"x":0.4161496320595876},{"x":0.2415002855136851},{"x":0.7515094174315702},{"x":-0.6830608546524509},{"x":-0.46094499876815015},{"x":-0.8259541373432441},{"x":-0.4276896525069265},{"x":-0.290411178450908},{"x":-0.3941589728906972},{"x":-1.4020260175869341},{"x":2.258675260553456},{"x":1.7630364678455313},{"x":0.18548551300944452},{"x":-0.05700050311384245},{"x":0.5172520686241702},{"x":-1.7703213440047534},{"x":-0.5834860398884416},{"x":1.4138225293337816},{"x":0.48784863647016025},{"x":0.20983117324816405},{"x":0.15744165151570808},{"x":-0.044370005172843494},{"x":1.7514091744021083},{"x":-0.7368379502850895},{"x":0.4881836840162407},{"x":0.36655432178206815},{"x":-0.9189361913975567},{"x":0.3581025163318765},{"x":1.6601801200326623e-4},{"x":1.476213301787196},{"x":0.4523515954970875},{"x":0.2761014151278153},{"x":0.2506954903976377},{"x":-1.4528248881001515},{"x":0.8979750588559912},{"x":0.5305211106985764},{"x":-1.4271518867412125},{"x":-0.8119326846439449},{"x":0.5638442927325257},{"x":1.6405380660636155},{"x":1.2400788370051923},{"x":0.117769575912661},{"x":-0.6323316801286856},{"x":-1.0178151765110504},{"x":1.1507364542296248},{"x":-0.32375580345740845},{"x":0.8755378134869641},{"x":0.9567973219527928},{"x":0.30738873092331204},{"x":0.09270376791642936},{"x":-1.725519870466864},{"x":-1.0175429606394464},{"x":0.15525875175533904},{"x":-0.7320786939749407},{"x":0.06395044142192759},{"x":-0.626334584618839},{"x":-1.9068627182428242},{"x":0.10950609957525799},{"x":-1.0189269503986602},{"x":-0.18369824213323002},{"x":-1.3926497722453608},{"x":-1.0833797305394854},{"x":0.034252566125752414},{"x":0.00907555891168907},{"x":-0.6732209901989182},{"x":-0.7539459943731639},{"x":0.07792652687399548},{"x":1.3090897445195544},{"x":0.04457300100150331},{"x":1.1222995134405271},{"x":1.8921484135963136},{"x":1.7271682744805053},{"x":-0.656410244695461},{"x":0.06033706120528388},{"x":1.0509493997478023},{"x":-1.4813764456866225},{"x":2.305352005700549},{"x":0.6617469585274766},{"x":0.952954608342849},{"x":1.4802085568422112},{"x":-0.2861703028763759},{"x":-1.3917313710646808},{"x":0.0862090316700425},{"x":-2.5156956257852583},{"x":0.2414142717920968},{"x":-1.4568996734818598},{"x":-1.1651432923889686},{"x":0.9444042466268039},{"x":0.152620889616563},{"x":0.8068333238555918},{"x":-0.3648539673928316},{"x":-1.570422263218719},{"x":-1.5802361496140465},{"x":0.3018010471521624},{"x":1.2880085331232696},{"x":0.7718178489464071},{"x":-1.381779295233352},{"x":-1.3017643524413616},{"x":-1.6465820415866783},{"x":-0.32479279311719234},{"x":0.7047009292651791},{"x":0.7975144499898134},{"x":-1.1751401015436307},{"x":0.11367456460851556},{"x":2.3906840573348616},{"x":1.5604321306113962},{"x":-0.22630205226542247},{"x":0.567655426718385},{"x":1.3962326831464578},{"x":1.2603703651372482},{"x":-0.5726441663370317},{"x":-0.8569085631305755},{"x":1.1835847054512945},{"x":0.9412628195017958},{"x":-0.1883689176658591},{"x":0.4654983268339928},{"x":1.3813201004474231},{"x":-0.4967487335249223},{"x":-0.14840261270664057},{"x":-0.0655910840990446},{"x":0.7959186060144114},{"x":0.28098208445395595},{"x":-0.25682616741854114},{"x":0.6249318666150545},{"x":-2.5293390487419165},{"x":-0.31320840530729527},{"x":-0.8381656733349443},{"x":0.6080845623541297},{"x":-0.45310946435732485},{"x":0.7994410453369744},{"x":0.3026730882202151},{"x":0.9219983068908939},{"x":-0.6026046332432748},{"x":0.9027723646936143},{"x":1.4568419055574287},{"x":0.7453021179835777},{"x":0.7896089114446428},{"x":-0.4916850180989059},{"x":-0.7703883836747503},{"x":-0.13272118424329404},{"x":-1.370806551059401},{"x":-0.5621555762048986},{"x":-0.23859488306217116},{"x":-0.13494520569658025},{"x":0.7906306188635019},{"x":0.39948803758925805},{"x":1.5610329176868634},{"x":0.16779795744136844},{"x":-0.40164819322909256},{"x":-0.9835366616180536},{"x":-0.4089638077465277},{"x":-0.4712848479024013},{"x":-1.3293787677845654},{"x":-0.7513594710997392},{"x":3.457332610348872},{"x":-0.5331556323634823},{"x":1.030778832020048},{"x":-0.928371099932407},{"x":1.7605781920371082},{"x":-1.3974143460899635},{"x":-0.5864824474346628},{"x":-0.67775051174894},{"x":0.06384883782545028},{"x":-0.6293644642173489},{"x":-0.5105897913724378},{"x":0.9594435090788401},{"x":0.29019140054884746},{"x":-1.7548030376066004},{"x":0.3151918726102138},{"x":0.5172963328126028},{"x":-1.2938953427649882},{"x":1.017064499740356},{"x":0.5444467608426623},{"x":0.5568504577993882},{"x":0.13808256941177766},{"x":1.109312051306994},{"x":-0.5880121228389185},{"x":0.21259479160840544},{"x":1.147786809596756},{"x":-0.5928616522877965},{"x":-0.06550292746371382},{"x":0.48021674129199177},{"x":-0.21636089077768747},{"x":0.040936252088921064},{"x":0.1738359224600265},{"x":0.07230019031762351},{"x":1.2569523380013274},{"x":-0.5935075399350852},{"x":0.08207630783536193},{"x":1.2197899650445088},{"x":0.5353137155087233},{"x":-0.053339332617436376},{"x":-0.38253862824106283},{"x":1.5467696557240784},{"x":-0.9926132199624454},{"x":0.9480629980853583},{"x":-0.28845697708111634},{"x":-0.45967413989455724},{"x":0.4837099223554063},{"x":1.9671534746044437},{"x":-1.111514418181511},{"x":-0.4286452581745524},{"x":0.8337150733485476},{"x":-1.696354516881071},{"x":-0.45958067600154195},{"x":1.5590224862100646},{"x":-0.7786341719475129},{"x":1.83774433282854},{"x":-0.3450935494206426},{"x":0.8246794357747069},{"x":-0.7222393274107317},{"x":-0.9865468824750985},{"x":0.5020388523570235},{"x":3.1350025219088713},{"x":-0.9179653180655146},{"x":-0.10372441188490336},{"x":-1.2863700629660775},{"x":0.23372935844094272},{"x":-0.1399224552785944},{"x":0.539150787149709},{"x":0.5760824299560345},{"x":-0.5959547954766057},{"x":0.5507877568125459},{"x":0.25464965349166996},{"x":0.7183707118364174},{"x":-0.12291639742228236},{"x":0.01666438622652557},{"x":0.20663096457030014},{"x":-1.0568527675422237},{"x":-0.35355849117769034},{"x":-1.265065183900846},{"x":0.8930524817345235},{"x":-0.1405445347275116},{"x":0.9025945045486947},{"x":-1.6059301653937463},{"x":0.2609062837430695},{"x":-0.19174863870489728},{"x":-1.3190815105180305},{"x":-0.12873147201082039},{"x":1.417066542125428},{"x":-0.8677544949501739},{"x":-0.8197090052336569},{"x":1.0667855812527793},{"x":1.0056157623417334},{"x":-0.013452226601813761},{"x":-0.3171189874039389},{"x":-1.5282505396878683},{"x":0.5591289029788726},{"x":-0.8114346106246734},{"x":0.527317706988372},{"x":-0.33742291160959775},{"x":0.7893109896237739},{"x":0.46969246945423504},{"x":-0.20243489338276985},{"x":-1.3699283981751487},{"x":-0.005331421524963036},{"x":-1.2250284186494311},{"x":0.3979347353087085},{"x":-0.18717902614769205},{"x":0.6571485350416866},{"x":0.0734591372361645},{"x":-1.464873492396883},{"x":-0.6628831110528485},{"x":0.6689442966341937},{"x":1.5641540129963891},{"x":0.1944434747593671},{"x":-2.446093641448062},{"x":-0.7475018042078155},{"x":-0.029903868441966307},{"x":0.17286355559593572},{"x":0.6706161338587804},{"x":-1.5924169552694558},{"x":-0.39693610168748766},{"x":-0.6299356838491321},{"x":1.123588760018478},{"x":0.4520954523477288},{"x":1.0969670411472108},{"x":0.38757911793191874},{"x":1.2974375059454455},{"x":-1.3554883488674079},{"x":0.441359251340657},{"x":0.32767629853207364},{"x":0.2664746566070148},{"x":0.3729535384363234},{"x":-0.9540088402739803},{"x":-0.5286396667112531},{"x":-0.21901580667970375},{"x":-0.8861870696833221},{"x":1.248489442147897},{"x":0.16728517228652812},{"x":1.4732017405574385},{"x":-0.4334928874390756},{"x":1.6373475809819853},{"x":0.38649696243671716},{"x":-0.5757257080611098},{"x":-0.36922887440414254},{"x":0.2823219968043212},{"x":-0.5085078446777979},{"x":0.5392096488996709},{"x":0.6812571480619086},{"x":1.1924839872335136},{"x":-0.9897805504211113},{"x":0.4449370966130726},{"x":0.7863835617011601},{"x":0.8615907229112221},{"x":1.7000661344140395},{"x":1.0486766065332445},{"x":-0.13254275817524092},{"x":1.3823521829677816},{"x":-0.7162014655030482},{"x":0.9695335579799498},{"x":-0.039866121777592085},{"x":-0.880691856206762},{"x":0.14326317775541852},{"x":1.2028747167893699},{"x":0.32844712325028846},{"x":0.7107485394641171},{"x":-0.3311694523009822},{"x":-0.8579695206896448},{"x":-1.9385846508710451},{"x":0.1311021334035849},{"x":0.7537979868874513},{"x":-1.5259632033355788},{"x":0.6733660229532504},{"x":-0.5437360959263698},{"x":-0.6234041816737337},{"x":-0.17344831268481278},{"x":0.14508928097891027},{"x":2.0087886225782428},{"x":-0.6451502643367228},{"x":0.5124336750310555},{"x":1.2375679763557466},{"x":-0.17238369393748304},{"x":0.6129998335808142},{"x":-0.2747972856216468},{"x":1.510009554560785},{"x":-1.0354634228134698},{"x":0.39806900837933173},{"x":1.2999834121090938},{"x":1.1114913288749015},{"x":-0.3675740606288537},{"x":1.7879261469334704},{"x":-0.23062475564359},{"x":0.28153814458095716},{"x":1.2205485073963884},{"x":-0.3806971705097763},{"x":0.39126859137140013},{"x":-0.1205582574834348},{"x":-0.08479329607351115},{"x":0.018147739226265138},{"x":0.06152984634248312},{"x":-0.4883031750474395},{"x":0.6483466947783932},{"x":0.14174338089834193},{"x":-1.488783726734239},{"x":-1.5725701951980529}]},"encoding":{"x":{"bin":{"binned":true},"field":"bin_x","title":"x"},"x2":{"field":"bin_x_end"},"y":{"axis":{"format":".1~%"},"field":"percent_x","stack":null,"title":"Relative Frequency","type":"quantitative"}},"mark":{"fillOpacity":1,"type":"bar"},"transform":[{"as":"bin_x","bin":{"extent":[-4,4],"step":0.25},"field":"x"},{"aggregate":[{"as":"count_x","op":"count"}],"groupby":["bin_x","bin_x_end"]},{"groupby":[],"joinaggregate":[{"as":"total_count_x","field":"count_x","op":"sum"}]},{"as":"percent_x","calculate":"datum.count_x/datum.total_count_x"}]},{"data":{"values":[{"x":-4.0,"y":3.345755644122134e-5},{"x":-3.959798994974874,"y":3.9262647567320883e-5},{"x":-3.919597989949749,"y":4.6000555027460156e-5},{"x":-3.879396984924623,"y":5.380773232312034e-5},{"x":-3.8391959798994977,"y":6.283830109417716e-5},{"x":-3.798994974874372,"y":7.326597069363562e-5},{"x":-3.758793969849246,"y":8.528611047416197e-5},{"x":-3.7185929648241207,"y":9.911797869609691e-5},{"x":-3.678391959798995,"y":1.1500711070657064e-4},{"x":-3.6381909547738696,"y":1.332278675334748e-4},{"x":-3.5979899497487438,"y":1.5408614426949755e-4},{"x":-3.557788944723618,"y":1.779222355750545e-4},{"x":-3.5175879396984926,"y":2.0511385329208615e-4},{"x":-3.477386934673367,"y":2.3607928852359126e-4},{"x":-3.4371859296482414,"y":2.7128070759042277e-4},{"x":-3.3969849246231156,"y":3.1122756802564e-4},{"x":-3.35678391959799,"y":3.564801372109693e-4},{"x":-3.3165829145728645,"y":4.0765309240894883e-4},{"x":-3.2763819095477387,"y":4.654191768137854e-4},{"x":-3.2361809045226133,"y":5.305128818567477e-4},{"x":-3.1959798994974875,"y":6.037341213887619e-4},{"x":-3.1557788944723617,"y":6.85951858562735e-4},{"x":-3.115577889447236,"y":7.781076412989929e-4},{"x":-3.0753768844221105,"y":8.812189971959693e-4},{"x":-3.035175879396985,"y":9.96382633711461e-4},{"x":-2.9949748743718594,"y":0.0011247773844630913},{"x":-2.9547738693467336,"y":0.0012676668376653112},{"x":-2.914572864321608,"y":0.0014264015781282535},{"x":-2.8743718592964824,"y":0.0016024209699934352},{"x":-2.834170854271357,"y":0.001797254403582617},{"x":-2.7939698492462313,"y":0.002012521926505153},{"x":-2.7537688442211055,"y":0.0022499341766274474},{"x":-2.7135678391959797,"y":0.00251129153278014},{"x":-2.6733668341708543,"y":0.0027984823982905816},{"x":-2.633165829145729,"y":0.0031134805327054844},{"x":-2.592964824120603,"y":0.0034583413485334003},{"x":-2.5527638190954773,"y":0.003835197092605504},{"x":-2.5125628140703515,"y":0.004246250835833441},{"x":-2.472361809045226,"y":0.0046937692008308055},{"x":-2.432160804020101,"y":0.005180073764141316},{"x":-2.391959798994975,"y":0.005707531078744655},{"x":-2.351758793969849,"y":0.006278541273132658},{"x":-2.3115577889447234,"y":0.006895525195581122},{"x":-2.271356783919598,"y":0.007560910086276817},{"x":-2.2311557788944723,"y":0.008277113775655995},{"x":-2.190954773869347,"y":0.009046527424597862},{"x":-2.150753768844221,"y":0.009871496840889678},{"x":-2.1105527638190953,"y":0.010754302426496897},{"x":-2.07035175879397,"y":0.011697137831456636},{"x":-2.030150753768844,"y":0.012702087412450436},{"x":-1.9899497487437188,"y":0.013771102617054349},{"x":-1.949748743718593,"y":0.014905977438026512},{"x":-1.9095477386934672,"y":0.016108323105456998},{"x":-1.8693467336683418,"y":0.01737954220782779},{"x":-1.829145728643216,"y":0.018720802455638348},{"x":-1.7889447236180906,"y":0.020133010322853286},{"x":-1.7487437185929648,"y":0.021616784821615574},{"x":-1.708542713567839,"y":0.023172431684021732},{"x":-1.6683417085427137,"y":0.024799918240859437},{"x":-1.6281407035175879,"y":0.026498849300644556},{"x":-1.5879396984924625,"y":0.02826844434266633},{"x":-1.5477386934673367,"y":0.03010751634467632},{"x":-1.507537688442211,"y":0.03201445256898903},{"x":-1.4673366834170856,"y":0.033987197629792715},{"x":-1.4271356783919598,"y":0.03602323915913196},{"x":-1.386934673366834,"y":0.03811959637911377},{"x":-1.3467336683417086,"y":0.040272811873261156},{"x":-1.3065326633165828,"y":0.0424789468305155},{"x":-1.2663316582914574,"y":0.044733580011171566},{"x":-1.2261306532663316,"y":0.047031810655097005},{"x":-1.1859296482412058,"y":0.04936826551909944},{"x":-1.1457286432160805,"y":0.05173711019250984},{"x":-1.1055276381909547,"y":0.05413206479827732},{"x":-1.0653266331658293,"y":0.05654642414153451},{"x":-1.0251256281407035,"y":0.05897308231918898},{"x":-0.9849246231155777,"y":0.06140456175319128},{"x":-0.9447236180904524,"y":0.06383304655736713},{"x":-0.9045226130653266,"y":0.06625042009377302},{"x":-0.8643216080402012,"y":0.06864830652019324},{"x":-0.8241206030150754,"y":0.07101811607642956},{"x":-0.7839195979899496,"y":0.0733510938042518},{"x":-0.7437185929648242,"y":0.07563837134511187},{"x":-0.7035175879396984,"y":0.07787102141179282},{"x":-0.6633165829145731,"y":0.08004011448588083},{"x":-0.6231155778894473,"y":0.0821367772530858},{"x":-0.5829145728643215,"y":0.08415225225372354},{"x":-0.5427135678391961,"y":0.08607795819677917},{"x":-0.5025125628140703,"y":0.08790555036348602},{"x":-0.4623115577889445,"y":0.08962698051078287},{"x":-0.42211055276381915,"y":0.09123455567675912},{"x":-0.38190954773869334,"y":0.09272099528955356},{"x":-0.341708542713568,"y":0.09407948598831915},{"x":-0.3015075376884422,"y":0.09530373357985499},{"x":-0.2613065326633164,"y":0.09638801157726513},{"x":-0.22110552763819102,"y":0.09732720579733348},{"x":-0.18090452261306522,"y":0.09811685453087553},{"x":-0.14070351758793986,"y":0.09875318384469615},{"x":-0.10050251256281406,"y":0.09923313762437869},{"x":-0.06030150753768826,"y":0.09955440202328635},{"x":-0.0201005025125629,"y":0.0997154240441004},{"x":0.020100502512562457,"y":0.0997154240441004},{"x":0.06030150753768826,"y":0.09955440202328635},{"x":0.10050251256281406,"y":0.09923313762437869},{"x":0.14070351758793986,"y":0.09875318384469615},{"x":0.18090452261306567,"y":0.09811685453087553},{"x":0.22110552763819058,"y":0.09732720579733348},{"x":0.2613065326633164,"y":0.09638801157726513},{"x":0.3015075376884422,"y":0.09530373357985499},{"x":0.341708542713568,"y":0.09407948598831915},{"x":0.3819095477386938,"y":0.09272099528955355},{"x":0.4221105527638187,"y":0.09123455567675913},{"x":0.4623115577889445,"y":0.08962698051078287},{"x":0.5025125628140703,"y":0.08790555036348602},{"x":0.5427135678391961,"y":0.08607795819677917},{"x":0.5829145728643219,"y":0.08415225225372351},{"x":0.6231155778894468,"y":0.08213677725308581},{"x":0.6633165829145726,"y":0.08004011448588086},{"x":0.7035175879396984,"y":0.07787102141179282},{"x":0.7437185929648242,"y":0.07563837134511187},{"x":0.78391959798995,"y":0.07335109380425177},{"x":0.824120603015075,"y":0.07101811607642959},{"x":0.8643216080402008,"y":0.06864830652019327},{"x":0.9045226130653266,"y":0.06625042009377302},{"x":0.9447236180904524,"y":0.06383304655736713},{"x":0.9849246231155782,"y":0.06140456175319125},{"x":1.025125628140704,"y":0.05897308231918895},{"x":1.0653266331658289,"y":0.056546424141534546},{"x":1.1055276381909547,"y":0.05413206479827732},{"x":1.1457286432160805,"y":0.05173711019250984},{"x":1.1859296482412063,"y":0.04936826551909942},{"x":1.226130653266332,"y":0.047031810655096984},{"x":1.266331658291457,"y":0.04473358001117159},{"x":1.3065326633165828,"y":0.0424789468305155},{"x":1.3467336683417086,"y":0.040272811873261156},{"x":1.3869346733668344,"y":0.038119596379113746},{"x":1.4271356783919602,"y":0.036023239159131935},{"x":1.4673366834170851,"y":0.033987197629792736},{"x":1.507537688442211,"y":0.03201445256898903},{"x":1.5477386934673367,"y":0.03010751634467632},{"x":1.5879396984924625,"y":0.02826844434266633},{"x":1.6281407035175883,"y":0.02649884930064454},{"x":1.6683417085427132,"y":0.02479991824085945},{"x":1.708542713567839,"y":0.023172431684021732},{"x":1.7487437185929648,"y":0.021616784821615574},{"x":1.7889447236180906,"y":0.020133010322853286},{"x":1.8291457286432165,"y":0.01872080245563833},{"x":1.8693467336683414,"y":0.01737954220782781},{"x":1.9095477386934672,"y":0.016108323105456998},{"x":1.949748743718593,"y":0.014905977438026512},{"x":1.9899497487437188,"y":0.013771102617054349},{"x":2.0301507537688446,"y":0.012702087412450425},{"x":2.0703517587939695,"y":0.011697137831456646},{"x":2.1105527638190953,"y":0.010754302426496897},{"x":2.150753768844221,"y":0.009871496840889678},{"x":2.190954773869347,"y":0.009046527424597862},{"x":2.2311557788944727,"y":0.008277113775655988},{"x":2.2713567839195976,"y":0.007560910086276822},{"x":2.3115577889447234,"y":0.006895525195581122},{"x":2.351758793969849,"y":0.006278541273132658},{"x":2.391959798994975,"y":0.005707531078744655},{"x":2.432160804020101,"y":0.005180073764141316},{"x":2.4723618090452257,"y":0.004693769200830812},{"x":2.5125628140703515,"y":0.004246250835833441},{"x":2.5527638190954773,"y":0.003835197092605504},{"x":2.592964824120603,"y":0.0034583413485334003},{"x":2.633165829145729,"y":0.0031134805327054844},{"x":2.673366834170854,"y":0.0027984823982905855},{"x":2.7135678391959797,"y":0.00251129153278014},{"x":2.7537688442211055,"y":0.0022499341766274474},{"x":2.7939698492462313,"y":0.002012521926505153},{"x":2.834170854271357,"y":0.001797254403582617},{"x":2.874371859296482,"y":0.0016024209699934367},{"x":2.914572864321608,"y":0.0014264015781282535},{"x":2.9547738693467336,"y":0.0012676668376653112},{"x":2.9949748743718594,"y":0.0011247773844630913},{"x":3.035175879396985,"y":9.96382633711461e-4},{"x":3.075376884422111,"y":8.812189971959676e-4},{"x":3.115577889447236,"y":7.781076412989929e-4},{"x":3.1557788944723617,"y":6.85951858562735e-4},{"x":3.1959798994974875,"y":6.037341213887619e-4},{"x":3.2361809045226133,"y":5.305128818567477e-4},{"x":3.276381909547739,"y":4.6541917681378454e-4},{"x":3.316582914572864,"y":4.076530924089495e-4},{"x":3.35678391959799,"y":3.564801372109693e-4},{"x":3.3969849246231156,"y":3.1122756802564e-4},{"x":3.4371859296482414,"y":2.7128070759042277e-4},{"x":3.4773869346733672,"y":2.3607928852359105e-4},{"x":3.517587939698492,"y":2.0511385329208652e-4},{"x":3.557788944723618,"y":1.779222355750545e-4},{"x":3.5979899497487438,"y":1.5408614426949755e-4},{"x":3.6381909547738696,"y":1.332278675334748e-4},{"x":3.6783919597989954,"y":1.1500711070657042e-4},{"x":3.7185929648241203,"y":9.911797869609709e-5},{"x":3.758793969849246,"y":8.528611047416197e-5},{"x":3.798994974874372,"y":7.326597069363562e-5},{"x":3.8391959798994977,"y":6.283830109417716e-5},{"x":3.8793969849246235,"y":5.380773232312026e-5},{"x":3.9195979899497484,"y":4.6000555027460244e-5},{"x":3.959798994974874,"y":3.9262647567320883e-5},{"x":4.0,"y":3.345755644122134e-5}]},"encoding":{"x":{"field":"x","type":"quantitative"},"y":{"field":"y","type":"quantitative"}},"mark":{"color":"red","strokeOpacity":1,"strokeWidth":2,"type":"line"}}]}

line(start, end, opts \\ [])

@spec line(start :: point(), end_point :: point(), opts :: keyword()) :: VegaLite.t()

Draws a line segment from the start to the end point.

Options

Styling Options

  • :line_color (String.t/0) - The color of the line
  • :opacity (number/0) - The overall opacity of the mark
  • :stroke_dash (list of pos_integer/0) - An array of alternating stroke, space lengths in pixels for creating dashed or dotted lines.
  • :stroke_width (pos_integer/0) - The stroke width in pixels The default value is 1.

Examples

Tucan.layers([
  Tucan.Geometry.line({0, 0}, {10, 10}, stroke_dash: [5, 5]),
  Tucan.Geometry.line({0, 10}, {10, 0}, line_color: "red", stroke_width: 3)
])
{"$schema":"https://vega.github.io/schema/vega-lite/v5.json","layer":[{"data":{"values":[{}]},"encoding":{"x":{"datum":0,"type":"quantitative"},"x2":{"datum":10},"y":{"datum":0,"type":"quantitative"},"y2":{"datum":10}},"mark":{"strokeDash":[5,5],"strokeWidth":1,"type":"rule"}},{"data":{"values":[{}]},"encoding":{"x":{"datum":0,"type":"quantitative"},"x2":{"datum":10},"y":{"datum":10,"type":"quantitative"},"y2":{"datum":0}},"mark":{"color":"red","strokeWidth":3,"type":"rule"}}]}

The identity line on top of a scatter plot:

data = for i <- 1..50, do: %{actual: i, predicted: i + 8 * :math.sin(i)}

Tucan.layers([
  Tucan.scatter(data, "actual", "predicted"),
  Tucan.Geometry.line({0, 0}, {50, 50}, line_color: "gray", stroke_dash: [4, 4])
])
{"$schema":"https://vega.github.io/schema/vega-lite/v5.json","layer":[{"__tucan__":{"types":{"actual":"quantitative","predicted":"quantitative"}},"data":{"values":[{"actual":1,"predicted":7.731767878463172},{"actual":2,"predicted":9.274379414605454},{"actual":3,"predicted":4.128960064478938},{"actual":4,"predicted":-2.0544199624634265},{"actual":5,"predicted":-2.6713941973051076},{"actual":6,"predicted":3.764676014408593},{"actual":7,"predicted":12.255892789750312},{"actual":8,"predicted":15.914865972987055},{"actual":9,"predicted":12.296947881934052},{"actual":10,"predicted":5.647831112885042},{"actual":11,"predicted":3.000078347594372},{"actual":12,"predicted":7.7074166559965205},{"actual":13,"predicted":16.361336294613128},{"actual":14,"predicted":21.924858845558962},{"actual":15,"predicted":20.202302721256935},{"actual":16,"predicted":13.696773466679478},{"actual":17,"predicted":9.308820064963545},{"actual":18,"predicted":11.99210202582659},{"actual":19,"predicted":20.19901767730362},{"actual":20,"predicted":27.30356200582102},{"actual":21,"predicted":27.693245108288448},{"actual":22,"predicted":21.92918952567677},{"actual":23,"predicted":16.230236766598637},{"actual":24,"predicted":16.755373103947008},{"actual":25,"predicted":23.941185999217815},{"actual":26,"predicted":32.10046760383682},{"actual":27,"predicted":34.651007427236024},{"actual":28,"predicted":30.167246306462953},{"actual":29,"predicted":23.69092892629626},{"actual":30,"predicted":22.095747007257106},{"actual":31,"predicted":27.76769883741548},{"actual":32,"predicted":36.41141344993353},{"actual":33,"predicted":40.99929488085814},{"actual":34,"predicted":38.23266148896019},{"actual":35,"predicted":31.574538644030792},{"actual":36,"predicted":28.065769172455074},{"actual":37,"predicted":31.851694933144003},{"actual":38,"predicted":40.370948629675084},{"actual":39,"predicted":46.7103630902727},{"actual":40,"predicted":45.96090528383479},{"actual":41,"predicted":39.73101864956233},{"actual":42,"predicted":34.66782761667493},{"actual":43,"predicted":36.345802058971216},{"actual":44,"predicted":44.14161540084331},{"actual":45,"predicted":51.807228196272945},{"actual":46,"predicted":53.21430678119047},{"actual":47,"predicted":47.98858498196179},{"actual":48,"predicted":41.853962709410666},{"actual":49,"predicted":41.369978777924224},{"actual":50,"predicted":47.90100117036857}]},"encoding":{"x":{"field":"actual","scale":{"zero":false},"type":"quantitative"},"y":{"field":"predicted","scale":{"zero":false},"type":"quantitative"}},"mark":{"fillOpacity":1,"type":"point"}},{"data":{"values":[{}]},"encoding":{"x":{"datum":0,"type":"quantitative"},"x2":{"datum":50},"y":{"datum":0,"type":"quantitative"},"y2":{"datum":50}},"mark":{"color":"gray","strokeDash":[4,4],"strokeWidth":1,"type":"rule"}}]}

polyline(vertices, opts \\ [])

@spec polyline(vertices :: [point()], opts :: keyword()) :: VegaLite.t()

Draws a polyline defined by the given vertices.

The order of the vertices defines the order of the line segments that will be generated.

The polyline or polygon will be added as a new layer to the given plot vl.

Options

  • :closed (boolean/0) - Whether a last segment will be added between the last and first points. The default value is false.

Styling Options

  • :fill_color (String.t/0) - The fill color of the marks. This will override the color encoding if set.
  • :fill_opacity (number/0) - The fill opacity of the plotted elements. The default value is 1.
  • :line_color (String.t/0) - The color of the line
  • :opacity (number/0) - The overall opacity of the mark
  • :stroke_dash (list of pos_integer/0) - An array of alternating stroke, space lengths in pixels for creating dashed or dotted lines.
  • :stroke_opacity (number/0) - The opacity of the stroke. The default value is 1.
  • :stroke_width (pos_integer/0) - The stroke width in pixels The default value is 1.

Examples

Tucan.Geometry.polyline([{-1, 1}, {-2, 4}, {-1, 3}, {4, 7}, {8, 2}])
|> Tucan.Scale.set_x_domain(-3, 10)
|> Tucan.Scale.set_y_domain(-1, 9)
{"$schema":"https://vega.github.io/schema/vega-lite/v5.json","data":{"values":[{"order":0,"x":-1,"y":1},{"order":1,"x":-2,"y":4},{"order":2,"x":-1,"y":3},{"order":3,"x":4,"y":7},{"order":4,"x":8,"y":2}]},"encoding":{"order":{"field":"order"},"x":{"field":"x","scale":{"domain":[-3,10]},"type":"quantitative"},"y":{"field":"y","scale":{"domain":[-1,9]},"type":"quantitative"}},"mark":{"fillOpacity":1,"strokeOpacity":1,"strokeWidth":1,"type":"line"}}

If :closed is set to true a line segment is added between the last and first point.

Tucan.Geometry.polyline([{-1, 1}, {-2, 4}, {-1, 3}, {4, 7}, {8, 2}], closed: true)
|> Tucan.Scale.set_x_domain(-3, 10)
|> Tucan.Scale.set_y_domain(-1, 9)
{"$schema":"https://vega.github.io/schema/vega-lite/v5.json","data":{"values":[{"order":0,"x":-1,"y":1},{"order":1,"x":-2,"y":4},{"order":2,"x":-1,"y":3},{"order":3,"x":4,"y":7},{"order":4,"x":8,"y":2},{"order":5,"x":-1,"y":1}]},"encoding":{"order":{"field":"order"},"x":{"field":"x","scale":{"domain":[-3,10]},"type":"quantitative"},"y":{"field":"y","scale":{"domain":[-1,9]},"type":"quantitative"}},"mark":{"fillOpacity":1,"strokeOpacity":1,"strokeWidth":1,"type":"line"}}

You can change the appearance of the polyline/polygon.

points = [{-1, 1}, {-2, 4}, {-1, 3}, {4, 7}, {8, 2}]

Tucan.Geometry.polyline(points,
  closed: true,
  fill_color: "red",
  line_color: "green",
  fill_opacity: 0.3,
  stroke_width: 3,
  stroke_dash: [5, 3]
)
|> Tucan.Scale.set_x_domain(-3, 10)
|> Tucan.Scale.set_y_domain(-1, 9)
{"$schema":"https://vega.github.io/schema/vega-lite/v5.json","data":{"values":[{"order":0,"x":-1,"y":1},{"order":1,"x":-2,"y":4},{"order":2,"x":-1,"y":3},{"order":3,"x":4,"y":7},{"order":4,"x":8,"y":2},{"order":5,"x":-1,"y":1}]},"encoding":{"order":{"field":"order"},"x":{"field":"x","scale":{"domain":[-3,10]},"type":"quantitative"},"y":{"field":"y","scale":{"domain":[-1,9]},"type":"quantitative"}},"mark":{"color":"green","fill":"red","fillOpacity":0.3,"strokeDash":[5,3],"strokeOpacity":1,"strokeWidth":3,"type":"line"}}

rectangle(upper_left, bottom_right, opts \\ [])

@spec rectangle(upper_left :: point(), bottom_right :: point(), opts :: keyword()) ::
  VegaLite.t()

Draws a rectangle defined by the given upper_left and bottom_right points.

Options

See polyline/2

Examples

Tucan.layers([
  Tucan.Geometry.rectangle({1, 5}, {5, 1},
    line_color: "black",
    stroke_width: 2,
    stroke_dash: [5, 5]
  ),
  Tucan.Geometry.rectangle({-2, 10}, {7, -3}, line_color: "green"),
  Tucan.Geometry.rectangle({-3.5, 0.1}, {8.1, -4.2}, fill_color: "pink", fill_opacity: 0.3)
])
|> Tucan.Scale.set_xy_domain(-5, 11)
|> Tucan.set_size(400, 300)
{"$schema":"https://vega.github.io/schema/vega-lite/v5.json","height":300,"layer":[{"data":{"values":[{"order":0,"x":1,"y":1},{"order":1,"x":1,"y":5},{"order":2,"x":5,"y":5},{"order":3,"x":5,"y":1},{"order":4,"x":1,"y":1}]},"encoding":{"order":{"field":"order"},"x":{"field":"x","scale":{"domain":[-5,11]},"type":"quantitative"},"y":{"field":"y","scale":{"domain":[-5,11]},"type":"quantitative"}},"mark":{"color":"black","fillOpacity":1,"strokeDash":[5,5],"strokeOpacity":1,"strokeWidth":2,"type":"line"}},{"data":{"values":[{"order":0,"x":-2,"y":-3},{"order":1,"x":-2,"y":10},{"order":2,"x":7,"y":10},{"order":3,"x":7,"y":-3},{"order":4,"x":-2,"y":-3}]},"encoding":{"order":{"field":"order"},"x":{"field":"x","scale":{"domain":[-5,11]},"type":"quantitative"},"y":{"field":"y","scale":{"domain":[-5,11]},"type":"quantitative"}},"mark":{"color":"green","fillOpacity":1,"strokeOpacity":1,"strokeWidth":1,"type":"line"}},{"data":{"values":[{"order":0,"x":-3.5,"y":-4.2},{"order":1,"x":-3.5,"y":0.1},{"order":2,"x":8.1,"y":0.1},{"order":3,"x":8.1,"y":-4.2},{"order":4,"x":-3.5,"y":-4.2}]},"encoding":{"order":{"field":"order"},"x":{"field":"x","scale":{"domain":[-5,11]},"type":"quantitative"},"y":{"field":"y","scale":{"domain":[-5,11]},"type":"quantitative"}},"mark":{"fill":"pink","fillOpacity":0.3,"strokeOpacity":1,"strokeWidth":1,"type":"line"}}],"width":400}

regular_polygon(center, radius, sides, opts \\ [])

@spec regular_polygon(
  center :: point(),
  radius :: number(),
  sides :: pos_integer(),
  opts :: keyword()
) ::
  VegaLite.t()

Draws a regular polygon with the given number of sides, whose vertices are on a circle with the given center and radius.

Options

  • :rotation - The rotation of the polygon in degrees, counter clockwise. With 0 the first vertex points up. The default value is 0.

Styling Options

  • :fill_color (String.t/0) - The fill color of the marks. This will override the color encoding if set.
  • :fill_opacity (number/0) - The fill opacity of the plotted elements. The default value is 1.
  • :line_color (String.t/0) - The color of the line
  • :opacity (number/0) - The overall opacity of the mark
  • :stroke_dash (list of pos_integer/0) - An array of alternating stroke, space lengths in pixels for creating dashed or dotted lines.
  • :stroke_opacity (number/0) - The opacity of the stroke. The default value is 1.
  • :stroke_width (pos_integer/0) - The stroke width in pixels The default value is 1.

Examples

Tucan.layers([
  Tucan.Geometry.regular_polygon({0, 0}, 1, 3, fill_color: "orange", fill_opacity: 0.4),
  Tucan.Geometry.regular_polygon({3, 0}, 1, 4, rotation: 45, line_color: "red"),
  Tucan.Geometry.regular_polygon({6, 0}, 1, 6, fill_color: "teal", stroke_width: 2)
])
|> Tucan.Scale.set_x_domain(-1.5, 7.5)
|> Tucan.Scale.set_y_domain(-1.5, 1.5)
|> Tucan.set_size(360, 120)
{"$schema":"https://vega.github.io/schema/vega-lite/v5.json","height":120,"layer":[{"data":{"values":[{"order":0,"x":6.123233995736766e-17,"y":1.0},{"order":1,"x":-0.8660254037844386,"y":-0.5000000000000001},{"order":2,"x":0.8660254037844384,"y":-0.5000000000000004},{"order":3,"x":6.123233995736766e-17,"y":1.0}]},"encoding":{"order":{"field":"order"},"x":{"field":"x","scale":{"domain":[-1.5,7.5]},"type":"quantitative"},"y":{"field":"y","scale":{"domain":[-1.5,1.5]},"type":"quantitative"}},"mark":{"fill":"orange","fillOpacity":0.4,"strokeOpacity":1,"strokeWidth":1,"type":"line"}},{"data":{"values":[{"order":0,"x":2.2928932188134525,"y":0.7071067811865476},{"order":1,"x":2.292893218813452,"y":-0.7071067811865475},{"order":2,"x":3.7071067811865475,"y":-0.7071067811865477},{"order":3,"x":3.7071067811865483,"y":0.7071067811865467},{"order":4,"x":2.2928932188134525,"y":0.7071067811865476}]},"encoding":{"order":{"field":"order"},"x":{"field":"x","scale":{"domain":[-1.5,7.5]},"type":"quantitative"},"y":{"field":"y","scale":{"domain":[-1.5,1.5]},"type":"quantitative"}},"mark":{"color":"red","fillOpacity":1,"strokeOpacity":1,"strokeWidth":1,"type":"line"}},{"data":{"values":[{"order":0,"x":6.0,"y":1.0},{"order":1,"x":5.133974596215562,"y":0.49999999999999994},{"order":2,"x":5.133974596215562,"y":-0.5000000000000001},{"order":3,"x":6.0,"y":-1.0},{"order":4,"x":6.866025403784438,"y":-0.5000000000000004},{"order":5,"x":6.866025403784439,"y":0.4999999999999993},{"order":6,"x":6.0,"y":1.0}]},"encoding":{"order":{"field":"order"},"x":{"field":"x","scale":{"domain":[-1.5,7.5]},"type":"quantitative"},"y":{"field":"y","scale":{"domain":[-1.5,1.5]},"type":"quantitative"}},"mark":{"fill":"teal","fillOpacity":1,"strokeOpacity":1,"strokeWidth":2,"type":"line"}}],"width":360}