plotly_ipywidget_notebooks's Issues
FigureWidget seems doesn't work on google colab
Hello,
Unless error for my side FigureWidget does not work on google colab. Have you any get around for that ?
error in plotly_ipywidget_notebooks/notebooks/Interact.ipynb
Hello!
just change
scatt=fig.add_scatter()
to
scatt = fig.data[0]
How to export to static HTML page?
Is this possible? specifically, I am interested in the interface at the bottom of the cars_exploration
notebook. Can this be extracted from the Jupyter Notebook into a single page HTML file?
Thanks!
Missing data/nyc_taxi.pkl
Cars exploration but with different colors for subgroups
Hello. First of all thank you for your work. I need to recreate the same layout you showed in the cars expolaration notebook, but the markers on the plot must be colored based on a categorical features, and the subcategories must be selectable on the plot as it always happen with plotly.
Have you any advice for me?
trying to use px.scatter(..., color=category) and extract the plot.data in order to create the FigureWidget doesn't work. It create some problems with the hover function.
No plot show up
Interact.ipynb raises exception
When I execute the cells of the Interact.ipynb
I get an exception after executing the last cell:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
c:\users\florian\.virtualenvs\data-processing-a_m7qh6p\lib\site-packages\ipywidgets\widgets\interaction.py in update(self, *args)
254 value = widget.get_interact_value()
255 self.kwargs[widget._kwarg] = value
--> 256 self.result = self.f(**self.kwargs)
257 show_inline_matplotlib_plots()
258 if self.auto_display and self.result is not None:
<ipython-input-16-8163515321f0> in update(a, b, color)
4 def update(a=3.6, b=4.3, color='blue'):
5 with fig.batch_update():
----> 6 scatt.x=xs
7 scatt.y=np.sin(a*xs-b)
8 scatt.line.color=color
c:\users\florian\.virtualenvs\data-processing-a_m7qh6p\lib\site-packages\plotly\basedatatypes.py in __setattr__(self, prop, value)
349 else:
350 # Raise error on unknown public properties
--> 351 raise AttributeError(prop)
352
353 def __getitem__(self, prop):
AttributeError: x
Package versions:
ipywidgets==7.5.1
numpy==1.17.3
plotly==4.2.1
Figurewidget and Map
Hi. I'm trying to make an interactive map by Plotly. I make a static map by scatter_mapbox successfully. But I fell into trouble when I tried to add an interactive part. I find Figurewidget but I don't know how to combine it with a map. Is someone can help me or give me a demo? I'm very weak in this area. Thankyou!
cars_exploration.ipynb raises exceptions
The notebook raises some exceptions. E.g. cell contour.colorscale = 'Hot'
raises AttributeError: colorscale
. Seems like the code uses outdated API and the requirements file does not pin explicit package versions.
How to run?
I copied the code as below and to understand what this project is doing. It returned with 0 errors when I run it. But how do I view the plot.
import pandas as pd
import numpy as np
import os
from ipywidgets import Image, Layout, HBox, VBox
import plotly.graph_objs as go
from ipywidgets import HTML
import plotly.plotly as py
cars_df = pd.read_csv('data/cars/cars.csv',
usecols=['City mpg',
'Fuel Type',
'Horsepower',
'Model Year',
'Torque', 'Hybrid', 'ID'])
cars_df.sample(5)
image_data = {}
for img_filename in os.listdir('data/cars/images'):
model_year = img_filename.split('.')[0]
with open("data/cars/images/2009_Audi_A3.jpg", "rb") as f:
b = f.read()
image_data[model_year] = b
Image(value=image_data['2012_Chevrolet_Camaro_Coupe'])
fig = go.FigureWidget(
data=[
dict(
type='scattergl',
x=cars_df['Torque'],
y=cars_df['City mpg'],
mode='markers',
)
],
)
fig.layout.title = 'Torque and Fuel Efficience'
fig.layout.titlefont.size = 22
fig.layout.titlefont.family = 'Rockwell'
fig.layout.xaxis.title = 'Torque (foot-pounds)'
fig.layout.yaxis.title = 'City MPG'
scatter = fig.data[0]
N = len(cars_df)
scatter.x = scatter.x + np.random.rand(N) * 10
scatter.y = scatter.y + np.random.rand(N) * 1
scatter.opacity = 0.2
fig.layout.hovermode = 'closest' # Set to 'closest'
contour = fig.add_histogram2dcontour(
x=scatter.x, y=scatter.y)
contour.colorscale = 'Hot'
contour.reversescale = True
contour.hoverinfo = 'skip'
scatter.text = cars_df['ID']
scatter.hoverinfo = 'text'
details = HTML()
def hover_fn(trace, points, state):
ind = points.point_inds[0]
details.value = cars_df.iloc[ind].to_frame().to_html()
scatter.on_hover(hover_fn)
image_widget = Image(
value=image_data['2012_Chevrolet_Camaro_Coupe'],
layout=Layout(height='252px', width='400px')
)
def hover_fn(trace, points, state):
ind = points.point_inds[0]
# Update details HTML widget
details.value = cars_df.iloc[ind].to_frame().to_html()
# Update image widget
model_year = cars_df['Model Year'][ind].replace(' ', '_')
image_widget.value = image_data[model_year]
scatter.on_hover(hover_fn)
VBox([fig, HBox([image_widget, details])])
Images necessary?
Is 100MB of images necessary to demonstrate plotly v3?
It's a bit of a hassle to download such a large repo size just for a demo.
I'd warn anyone about this repo size when recommending this demo ... FYI.
'FigureWidget' object has no attribute 'marker'
on_hover() with callback for multiple traces only displays data for first trace
Hello again, Jon!
Thanks for these helpful notebooks for demonstrating how plotly and ipywidgets can work together for powerful insights during data analysis.
Following the cars exploration example on my own dataset, I noticed the scatter.on_hover(hover_fn)
only seems to work on one trace...(specifically, seemingly only on the first trace designated). Is this a bug, a limitation, or am I missing something to make it work as expected?
For example, if I were to add several traces (e.g., to look at Torque
X City MPG
as a separate trace for each Fuel Type
):
import pandas as pd
import plotly.graph_objs as go
from ipywidgets import widgets
# get the cars data
cars_df = pd.read_csv('data/cars/cars.csv',
usecols=['City mpg', 'Fuel Type', 'Horsepower',
'Hybrid', 'ID', 'Model Year', 'Torque'])
cars_gb = cars_df.groupby(by='Fuel Type')
traces = []
for ftype, df in cars_gb:
trace = dict(type='scattergl',
x=df['Torque'],
y=df['City mpg'],
mode='markers',
name=ftype)
traces.append(trace)
fig = go.FigureWidget(traces)
fig.layout.hovermode = 'closest'
# set a complex tooltip
details = widgets.HTML()
def hover_fn(trace, points, state):
# get the index of the data point being hovered
ind = points.point_inds[0]
# Update details HTML widget
hover_info_df = cars_gb.get_group(str(trace.name)).iloc[ind].to_frame()
details.value = hover_info_df.to_html()
for trace_num in range(len(fig.data)):
fig.data[trace_num].on_hover(hover_fn) # <--- only works when hovering on fig.data[0] points
# display it all together in a mini-dashboard
widgets.HBox([fig, details])
Maybe I'm missing something?
Example from web page runs once, stops working in restarted jupyter lab notebook
I ran the code from https://plot.ly/python/click-events/ in jupyter lab
It works fine, I can mark the points and they change their color.
If close the the jupyter lab window and start it again, I get the following error message in the anaconda prompt:
[IPKernelApp] WARNING | No such comm: f1017aced23e4d9495e2ec9e4a095da3
The error is not completely reproducable. I ran one of the examples from the notebooks here yesterday and it worked yesterday but failed to run today. I created a new notebook with the same example (https://github.com/jonmmease/plotly_ipywidget_notebooks/blob/master/notebooks/Interact.ipynb) and again, it worked, but this time it kept working even after signing out and back into jupyter lab.
conda info gives the following:
active environment : ****
active env location : C:\Users\***\AppData\Local\Continuum\anaconda3\envs\kw_env
shell level : 2
user config file : C:\Users\***\.condarc
populated config files : C:\Users*.condarc
conda version : 4.7.10
conda-build version : 3.18.8
python version : 3.7.3.final.0
virtual packages :
base environment : C:\Users*\AppData\Local\Continuum\anaconda3 (writable)
channel URLs : https://repo.anaconda.com/pkgs/main/win-64
https://repo.anaconda.com/pkgs/main/noarch
https://repo.anaconda.com/pkgs/r/win-64
https://repo.anaconda.com/pkgs/r/noarch
https://repo.anaconda.com/pkgs/msys2/win-64
https://repo.anaconda.com/pkgs/msys2/noarch
package cache : C:\Users*\AppData\Local\Continuum\anaconda3\pkgs
C:\Users*.conda\pkgs
C:\Users*\AppData\Local\conda\conda\pkgs
envs directories : C:\Users*\AppData\Local\Continuum\anaconda3\envs
C:\Users*.conda\envs
C:\Users*\AppData\Local\conda\conda\envs
platform : win-64
user-agent : conda/4.7.10 requests/2.22.0 CPython/3.7.3 Windows/10 Windows/10.0.17763
administrator : False
netrc file : None
offline mode : False
[Alert] Nothing is working here. Don't use this repo. Go home.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.