You can download this code by clicking the button below.
This code is now available for download.
This function uses the Bokeh library to draw random circles within a specified range. The number of circles can be customized.
Technology Stack : Bokeh, Circle, Range1d
Code Type : Bokeh graphic drawing
Code Difficulty : Intermediate
def random_circles(x_range, y_range, num_circles):
from bokeh.plotting import figure, show
from bokeh.models import Circle, Range1d
p = figure(title="Random Circles", tools="pan,wheel_zoom,box_zoom,reset", x_range=x_range, y_range=y_range)
circles = [Circle(x=0.5 + 0.3 * (1 - 2 * i), y=0.5 + 0.3 * (1 - 2 * i), radius=0.1 + 0.1 * i) for i in range(num_circles)]
p.add_glyph(circles, 'circle')
show(p)