yt
plots¶This is a simple example of an interactive widget in the IPython notebook. This is shamelessly stolen from Fernando Perez.
%matplotlib inline
Now we create a yt
SlicePlot:
from yt.mods import *
pf = load('HiResIsolatedGalaxy/DD0044/DD0044')
slc = SlicePlot(pf, 2, 'density', width=(20, 'kpc'), center=[0.53, 0.53, 0.53])
slc.set_figure_size(6)
slc.set_font({'size':15, 'family':'stixgeneral'})
Now, we load IPython's facilities for interactive control.
from IPython.html.widgets import interact
from IPython.display import display
And we write a simple decorator that lets us control the two width of the plot:
@interact(width=(1, 100))
def view(width):
slc.set_width((width, 'kpc'))
display(slc)