This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def set_bin_size(change): | |
histogram_object.xbins = {"size": change["new"]} | |
# Call set_bin_size whenever the bin slider changes | |
bin_slider.observe(set_bin_size, names="value") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
histogram_object = figure_widget.data[0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bin_slider = widgets.FloatSlider( | |
value=initial_bin_width, | |
min=1, | |
max=30, | |
step=1, | |
description="Bin width:", | |
readout_format=".0f", # display as integer | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
figure_widget = go.FigureWidget( | |
data=[go.Histogram(x=series, xbins={"size": initial_bin_width})] | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def rebinnable_interactive_histogram(series, initial_bin_width=10): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import plotly.graph_objs as go | |
import ipywidgets as widgets | |
def rebinnable_interactive_histogram(series, initial_bin_width=10): | |
figure_widget = go.FigureWidget( | |
data=[go.Histogram(x=series, xbins={"size": initial_bin_width})] | |
) | |
bin_slider = widgets.FloatSlider( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import plotly.graph_objs as go | |
def interactive_histogram(df, column_name): | |
series = df[column_name] | |
# Change size to anything you want in order to adjust the binwidth | |
trace = go.Histogram(x=series, xbins={"size": None}) | |
figure_widget = go.FigureWidget( | |
data=[trace], |