@@ -786,5 +786,44 @@ fig.suptitle("Synchronized versus Asynchronized 2-cycles",
786786plt.show()
787787```
788788
789+ Additionally, instead of just seeing 4 plots at once, we might want to
790+ manually be able to change $\rho$ and see how it affects the plot
791+ in real-time. Below we use an interactive plot to do this.
792+
793+ Note, interactive plotting requires the [ ipywidgets] ( https://github.com/jupyter-widgets/ipywidgets ) module to be installed and enabled.
794+
795+ ``` {note}
796+ This interactive plot is disabled on this static webpage.
797+ In order to use this, we recommend to run this notebook locally.
798+ ```
799+
800+ ``` {code-cell} python3
801+ :class: no-execute
802+
803+ def interact_attraction_basis(ρ=0.2, maxiter=250, npts=250):
804+ # Create the figure and axis that we will plot on
805+ fig, ax = plt.subplots(figsize=(12, 10))
806+ # Create model and attraction basis
807+ s1, θ, δ = 0.5, 2.5, 0.75
808+ model = MSGSync(s1, θ, δ, ρ)
809+ ab = model.create_attraction_basis(maxiter=maxiter, npts=npts)
810+ # Color map with colormesh
811+ unitrange = np.linspace(0, 1, npts)
812+ cf = ax.pcolormesh(unitrange, unitrange, ab, cmap="viridis")
813+ cbar_ax = fig.add_axes([0.95, 0.15, 0.05, 0.7])
814+ plt.colorbar(cf, cax=cbar_ax)
815+ plt.show()
816+ return None
817+ ```
818+
819+ ``` {code-cell} python3
820+ :class: no-execute
821+
822+ fig = interact(interact_attraction_basis,
823+ ρ=(0.0, 1.0, 0.05),
824+ maxiter=(50, 5000, 50),
825+ npts=(25, 750, 25))
826+ ```
827+
789828``` {solution-end}
790829```
0 commit comments