In this post, I show how to toggle a code in a RISE presentation.
Firstly, you have to make "toggle_sing_code.py" described below.
Then put this file in a directory (for me /mnt/c/Users/mnaka/OneDrive/3_code_script/Python/).
%%bash
cat /mnt/c/Users/mnaka/OneDrive/3_code-script/Python/toggle_single_code.py
You import a function to toggle a code like below in a ipynb file.
import sys
sys.path.append("/mnt/c/Users/mnaka/OneDrive/3_code-script/Python")
from toggle_single_code import toggle_code
You put "toggle_code()" in a cell.
If you put it before defining figure, the buttom pops up at upper-right.
If you put it after showing figure, the buttom pops up at lower-right.
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
toggle_code()
fig=plt.figure()
x=np.linspace(0,2*np.pi,1000)
y=np.sin(x)
plt.plot(x,y)
plt.show()
toggle_code()