ipywidgets

How to define the default value of a Slider widget on ipywidgets?

谁说胖子不能爱 提交于 2019-12-11 00:34:57
问题 On a Jupyter Notebook and using ipywidgets I can create sliders using the compact version import ipywidgets as ip def f(x): print(x) ip.interact(f, x = (0, 1, 1)) The slider's default value is 0 but I would like to make it 1. How can I do this? 回答1: The widget abbreviations (using tuples to request sliders, etc.) only expose a small subset of the options that can be passed to a widget. Default values come from the default value in the function definition if available, or the center of the

Execute algorithm step by step in Jupyter

我的梦境 提交于 2019-12-10 10:06:07
问题 I am trying to show the execution of a Python program in Jupyter, step by step. For example, I can visualize the value of a variable in a program as in the following toy program: from IPython.display import display, clear_output from time import sleep def sum_first_integers(n): res = 0 for i in range(n+1): res += i clear_output(wait=True) display(res) sleep(.5) return res This shows the value of res at each step of the algorithm, and I added a sleep(.5) to be able to actually view the

Control of layout ipywidgets in jupyter notebook

本秂侑毒 提交于 2019-12-08 14:19:56
问题 I have some problems understanding how to control the flexbox of ipywidgets in jupyter notebook. According to the docs this should be possible, however my styling code (see below) does not result in the desired layout. I checked on stack and found a good resource that seemed to work for people there, however running the code still does not provide the desired the result. The problem I would like control to build somewhat more complex layouts. In this case particularly the goal is to have the

Using ipywidgets with plotly in jupyter notebook

流过昼夜 提交于 2019-12-08 01:44:35
问题 I want to use the offline plotting of plotly inside a jupyter notebook and want to manipulate or redraw the plot by using widgets from ipywidgets. Unfortunately I do not manage to update the plots appropiately: from ipywidgets import widgets, HBox, Output import plotly as py from plotly.offline import iplot from IPython.display import display %matplotlib inline ip_widget = widgets.FloatSlider( value=6, min=3, max=10, step=1, description='num', continuous_update = True ) ow = Output() def

Uploading files using Browse Button in Jupyter and Using/Saving them

妖精的绣舞 提交于 2019-12-06 08:25:48
问题 I came across this snippet for uploading files in Jupyter however I don't know how to save this file on the machine that executes the code or how to show the first 5 lines of the uploaded file. Basically I am looking for proper commands for accessing the file after it has been uploaded: import io from IPython.display import display import fileupload def _upload(): _upload_widget = fileupload.FileUploadWidget() def _cb(change): decoded = io.StringIO(change['owner'].data.decode('utf-8'))

How to make one slider/widget update multiple plots in Bokeh/Python/Pywidgets?

别等时光非礼了梦想. 提交于 2019-12-06 07:59:05
Using Jupyter notebook, how to have one slider interactively update two independent functions in two figures? There is a link to a similar question without answer here . Using Bokeh Javascript Callback slider power example , I tried adding a second set of variables x and y but keep using the same callback. The graphs do not update anymore. Any suggestions? I also was trying to do the same with Pywidget but did not get anywhere. I would prefer using IPywidget if there is a solution there. The end goal is to have a dashboard with an input composed of multiple slider, and an output composed of

Interactive Timer in Jupyter Notebook

╄→尐↘猪︶ㄣ 提交于 2019-12-06 06:00:33
问题 I have a function which records data and takes a while to complete. While the data is being recorded, I would like to have a button which, upon being pressed, displays how much time has elapsed since the data acquisition has started. Is this possible to do in Jupyter? I'm having issues as the data acquisition blocks the widget from activating, and if I try and run the widget in the background, it doesn't receive the on_click event until the data acquisition has finished. On the other hand, if

Using ipywidgets with plotly in jupyter notebook

筅森魡賤 提交于 2019-12-06 04:09:30
I want to use the offline plotting of plotly inside a jupyter notebook and want to manipulate or redraw the plot by using widgets from ipywidgets. Unfortunately I do not manage to update the plots appropiately: from ipywidgets import widgets, HBox, Output import plotly as py from plotly.offline import iplot from IPython.display import display %matplotlib inline ip_widget = widgets.FloatSlider( value=6, min=3, max=10, step=1, description='num', continuous_update = True ) ow = Output() def response(change): with ow: iplot([{'x':list(range(int(ip_widget.value))), 'y': list(range(int(ip_widget

How to display matplotlib plots in a Jupyter tab widget?

我是研究僧i 提交于 2019-12-06 02:42:08
问题 I am having trouble displaying plots inside of Jupyter tab widgets. Consider the following snippet: import matplotlib.pyplot as plt import pandas as pd import ipywidgets as widgets import numpy as np out1 = widgets.Output() out2 = widgets.Output() data1 = pd.DataFrame(np.random.normal(size = 50)) data2 = pd.DataFrame(np.random.normal(size = 100)) with out1: fig1, axes1 = plt.subplots() data1.hist(ax = axes1) display(fig1) with out2: fig2, axes2 = plt.subplots() data2.hist(ax = axes2) display

How to change multiple interactive plots with a single input in Python

拈花ヽ惹草 提交于 2019-12-06 00:07:20
I am trying to make several interactive plots with the ipywidgets library in Jupyter Notebook. I face however one problem: I try to make multiple plots change when one single input widget changes, for example a slider. In the added MWE this is illustrated with a sine and cosine function that both depend on a single input widget that sets the amplitude of both the sine and the cosine function. Thus, if the value of the input slider is set at the value 2, the amplitude of both the sine and cosine function must inmediately follow suit. If you would run the code yourself then you will see that