Ikeda-Map
Sat 17 May 2025
from bokeh.plotting import figure, output_file, show
from bokeh.io import output_notebook
from bokeh.models import ColumnDataSource
# Set Bokeh output to notebook
output_notebook()
import numpy as np
from bokeh.plotting import figure, show
# Ikeda map parameters
u = 0.918 # control parameter
num_points = 10000 # number of iterations
x0, y0 = 0.5, 0.5 # initial condition
# Generate points for the Ikeda map
x, y = [x0], [y0]
for _ in range(num_points - 1):
t = 0.4 - 6 / (1 + x[-1]**2 + y[-1]**2)
x_new = 1 + u * (x[-1] * np.cos(t) - y[-1] * np.sin(t))
y_new = u * (x[-1] * np.sin(t) + y[-1] * np.cos(t))
x.append(x_new)
y.append(y_new)
# Split data into segments for multi-line
num_segments = 7
xs = np.array_split(x, num_segments)
ys = np.array_split(y, num_segments)
# Define a color palette
colors = ["#EDF8FB", "#B3CDE3", "#8C96C6", "#8856A7", "#810F7C", "#4D004B", "#1C0C1E"]
# Create the Bokeh figure
p = figure(title="Ikeda Map Visualization",
background_fill_color="#f9f9f9",
x_axis_label="X",
y_axis_label="Y",
match_aspect=True)
# Add the multi_line glyph
p.multi_line(xs, ys, line_color=colors, line_alpha=0.8, line_width=1.5)
# Show the plot
show(p)
Score: 5
Category: bokeh