aashitak / bubbly Goto Github PK
View Code? Open in Web Editor NEWA python package for plotting animated and interactive bubble charts using Plotly
License: MIT License
A python package for plotting animated and interactive bubble charts using Plotly
License: MIT License
Aashitak, thanks for sharing Bubbly. I used it and it is amazing :)
Everything works perfectly, except for one thing. I have categorical color_column and I noticed color of items in legend are being repeated. I am so very thankful if you can help me with that issue.
While it's fairly okay to assume that people come here knowing what a bubble chart is. Still a thought that having a gif/image of Bubble chart (even, animated) like you got in Kernel could help.
Scenario:
Define data with the following pattern:
Categories: C1, C2, C3
Items: I1, I2, I3, I4, I5, I6
Year Category Item Value
2010 C3 I6 1
2010 C3 I6 1
2011 C1 I1 3
2011 C2 I3 2
2012 C1 I1 2
2012 C2 I3 1
2012 C3 I5 3
Because Category C1 and C2 are not represented in year 2010, there will be a crash in bubbly, as following:
/opt/conda/lib/python3.6/site-packages/bubbly/bubbly.py in bubbleplot(dataset, x_column, y_column, bubble_column, z_column, time_column, size_column, color_column, x_logscale, y_logscale, z_logscale, x_range, y_range, z_range, x_title, y_title, z_title, title, colorbar_title, scale_bubble, colorscale, marker_opacity, marker_border_width, show_slider, show_button, show_colorbar, show_legend, width, height)
88 bubble_column, z_column, size_column,
89 sizeref, scale_bubble, marker_opacity, marker_border_width,
---> 90 category=category)
91 if z_column:
92 trace['type'] = 'scatter3d'
/opt/conda/lib/python3.6/site-packages/bubbly/bubbly.py in get_trace(grid, col_name_template, x_column, y_column, bubble_column, z_column, size_column, sizeref, scale_bubble, marker_opacity, marker_border_width, color_column, colorscale, show_colorbar, colorbar_title, category)
397
398 trace = {
--> 399 'x': grid.loc[grid['key']==col_name_template.format(x_column, category), 'value'].values[0],
400 'y': grid.loc[grid['key']==col_name_template.format(y_column, category), 'value'].values[0],
401 'text': grid.loc[grid['key']==col_name_template.format(bubble_column, category), 'value'].values[0],
IndexError: index 0 is out of bounds for axis 0 with size 0
Reason:
When the grid is created, this issue appears:
for year in years:
for category in categories:
**dataset_by_year_and_cat = dataset[(dataset[time_column] == int(year)) & (dataset[category_column] == category)]**
for col_name in column_names:
# Each column name is unique
temp = col_name_template.format(year, col_name, category)
if dataset_by_year_and_cat[col_name].size != 0:
grid = grid.append({'value': list(dataset_by_year_and_cat[col_name]), 'key': temp}, ignore_index=True)
Missing category in current year
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.