Giter Site home page Giter Site logo

aashitak / bubbly Goto Github PK

View Code? Open in Web Editor NEW
46.0 46.0 8.0 57 KB

A python package for plotting animated and interactive bubble charts using Plotly

License: MIT License

Python 100.00%
animated-buttons animated-visualizations bubble-chart bubbles data-science data-science-toolbox data-visualization interactive-visualizations plotly plotting scatter-plot scatterplot-visualization

bubbly's People

Contributors

aashitak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

bubbly's Issues

Categorical color_column

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.

If not all categories are represented in each year, there will be an error

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.