Play with Julia code and share the fun!
This package is a collection of web-based widgets that you can use to:
The simplest way to use Interact is via the
The syntax of
@manipulate for var1=
<object> can be one of the following:
AbstractRangeof Real numbers): this will create a slider using which you can select one value for the variable from the range.
@manipulate. Note that the result of an
@manipulateis also an observable!
You can also create widgets by themselves using the same input scheme. Just pass the
widget() which has the syntax:
px=widget(0:0.01:.3, label="px") py=widget(0:0.01:.3, label="py") plane = widget(Dict("x=0" => 1, "y=0" => 2), label="Section plane");
Then you can use
map over the widgets to create new interactive output that depends on these widgets!
interactive_plot = map(plotsos, px, py, plane)
And put them all together into a nice little layout:
# stack vertically vbox( hbox(px, py, plane), # stack horizontally interactive_plot)
If you would like even more customization for your widgets, each type of widget has a different set of options you can tweak and different ways of updating it. So head over to the documentation about them!
This demo has color and date pickers!
Interact's output can be displayed either within Jupyter/Jupyterlab notebooks, the Atom text editor, or as a stand-alone web page. Below are the set up instructions for each of these front ends:
To set up Interact to work in Jupyter notebooks, first install Interact, IJulia and WebIO packages. Then install the required Jupyter extension by running:
using WebIO WebIO.install_jupyter_nbextension()
Important: If you performed this step while the Jupyter notebook server is running, you will need to restart it for the extension to take effect.
If you have multiple Jupyter installations: The
WebIO.install_jupyter_nbextension([jupyter])function takes the path to the
jupyterbinary as an optional argument. If omitted, the installation first tries to find
jupyterin your OS's default path. If it does not exist there, it tries to find a version that was installed using Conda.jl (which is the default when IJulia is installed without having an existing Jupyter set up, or by forcing it to install a copy via Conda.) If you have a
jupyterbinary in your OS path but also have a version installed via Conda and want to use the one installed via Conda, then you can set this keyword argument to be
WebIO.find_jupyter_cmd(condajl=true). For more information about the Jupyter integration, see WebIO's documentation. There is more troubleshooting information here.
To set up Interact to work in JupyterLab, first install Interact, IJulia and WebIO packages. Then install the required JupyterLab extension by running:
using WebIO WebIO.install_jupyter_labextension()
Important: If you performed this step while the JupyterLab server is running, you will need to restart it for the extension to take effect.
This function also takes the
jupyter path as an optional argument. See the above subsection on installing on Jupyter notebooks for more description of the default behavior when this argument is omitted and pointers to troubleshooting information. tl;dr: if you launch JupyterLab via
using WebIO WebIO.install_jupyter_labextension(condajl=true)
to force WebIO to be installed to the correct place.
If you have set up the Julia integration provided by Juno, evaluating any expression which returns an Interact-renderable object (such as a widget or the output of
@manipulate) will show up in a plot-pane within the editor. No extra setup steps are required.
Any Julia function that returns an Interact-renderable object (such as a widget or the output of an
@manipulate) can be repurposed to run as a simple web page served by the Mux web app framework.
using Mux, WebIO function app(req) # req is a Mux request dictionary ... end webio_serve(page("/", app), port=8000) # this will serve at http://localhost:8000/
Check out this repository which has a script to publish Interact app to Heroku with a simple command!
A great resource to learn to use the various features of Interact is to try out the example notebooks and the tutorial in the doc/notebooks/ directory. Start up IJulia from doc/notebooks/:
using IJulia notebook(dir=".")
Interact is built using WebIO which is a "hub" package that supports an ecosystem of composable web-based widgets that all share the same availability on the Julia front-ends.
To learn more, check out the documentation.
8 days ago