Bokeh – Specialized Curves

Bokeh - Specialized Curves

Bokeh – Specialized Curves. The bokeh. plotting API supports methods for rendering the following specialized curves −

Bokeh Specialized Curves(beizer)

This method adds a Bézier curve to the figure object. A Bézier curve is a parametric curve used in computer graphics. Other uses include the design of computer fonts and animation, user interface design, and smoothing cursor trajectory.

In vector graphics, Bézier curves are used to model smooth curves that can be scaled indefinitely. A “Path” is the combination of linked Bézier curves.

The beizer() method has the following parameters which are defined −

1x0The x-coordinates of the starting points.
2y0The y-coordinates of the starting points..
3x1The x-coordinates of the ending points.
4y1The y-coordinates of the ending points.
5cx0The x-coordinates of first control points.
6cy0The y-coordinates of first control points.
7cx1The x-coordinates of second control points.
8cy1The y-coordinates of second control points.

The default value for all parameters is None.

Example

The following code generates an HTML page showing a Bézier curve and parabola in Bokeh plot −

x = 2
y = 4
xp02 = x+0.4
xp01 = x+0.1
xm01 = x-0.1
yp01 = y+0.2
ym01 = y-0.2
fig = figure(plot_width = 300, plot_height = 300)
fig.bezier(x0 = x, y0 = y, x1 = xp02, y1 = y, cx0 = xp01, cy0 = yp01,
cx1 = xm01, cy1 = ym01, line_color = "red", line_width = 2)

Output

Bokeh - Specialized Curves

quadratic()

This method adds a parabola glyph to the bokeh figure. The function has the same parameters as beizer(), except cx0 and cx1.

Example

The code given below generates a quadratic curve.

x = 2
y = 4
xp02 = x + 0.3
xp01 = x + 0.2
xm01 = x - 0.4
yp01 = y + 0.1
ym01 = y - 0.2
x = x,
y = y,
xp02 = x + 0.4,
xp01 = x + 0.1,
yp01 = y + 0.2,
fig.quadratic(x0 = x, y0 = y, x1 = x + 0.4, y1 = y + 0.01, cx = x + 0.1,
cy = y + 0.2, line_color = "blue", line_width = 3)

Output

Bokeh - Specialized Curves

Next Topic – Click Here

This Post Has One Comment

Leave a Reply