bqplot | Plotting library for IPython/Jupyter notebooks | Data Visualization library

 by   bqplot TypeScript Version: 0.13.0rc0 License: Apache-2.0

kandi X-RAY | bqplot Summary

kandi X-RAY | bqplot Summary

bqplot is a TypeScript library typically used in Analytics, Data Visualization, Jupyter applications. bqplot has no bugs, it has no vulnerabilities, it has a Permissive License and it has medium support. You can download it from GitHub.

bqplot is a 2-D visualization system for Jupyter, based on the constructs of the Grammar of Graphics.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              bqplot has a medium active ecosystem.
              It has 3431 star(s) with 472 fork(s). There are 104 watchers for this library.
              There were 2 major release(s) in the last 6 months.
              There are 215 open issues and 364 have been closed. On average issues are closed in 66 days. There are 32 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of bqplot is 0.13.0rc0

            kandi-Quality Quality

              bqplot has no bugs reported.

            kandi-Security Security

              bqplot has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.

            kandi-License License

              bqplot is licensed under the Apache-2.0 License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              bqplot releases are available to install and integrate.
              Installation instructions, examples and code snippets are available.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of bqplot
            Get all kandi verified functions for this library.

            bqplot Key Features

            No Key Features are available at this moment for bqplot.

            bqplot Examples and Code Snippets

            How to remove scientific notation on bqplot?
            Pythondot img1Lines of Code : 4dot img1License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            plt2.plot(x_values, y_values, axes_options={
                y=dict(tick_format='0.2f')
            })
            
            Change plot limits with aspect ratio = 1 in bqplot
            Pythondot img2Lines of Code : 53dot img2License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            from bqplot import pyplot as plt
            from bqplot import LinearScale, Axis, Lines, Figure
            from ipywidgets import HTML
            import pandas as pd
            
            # ---------------------------
            maxy= 3
            maxx = 6
            heightpx = 520
            # ---------------------------
            
            sc_y = Linea
            bqplot filled Lines blocks tooltip
            Pythondot img3Lines of Code : 6dot img3License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            example_fig = Figure(marks=[
                fcst_uncertainty,
                fcst_line,
            
            ], axes=[x_ax_fcst, y_ax_fcst])
            
            Using multiple sliders to create dynamic chart in bqplt/jupyter
            Pythondot img4Lines of Code : 37dot img4License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            from bqplot import DateScale, LinearScale, Axis, Figure, Lines
            
            from ipywidgets import FloatSlider, VBox
            
            import pandas as pd
            
            import numpy as np
            
            slider = FloatSlider(value=1, min = 0, max = 1, step = .01, description = 'Weight A')
            slider
            Plots and widgets not showing on jupyter lab
            Pythondot img5Lines of Code : 6dot img5License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            $ pip install bqplot
            $ jupyter labextension install @jupyter-widgets/jupyterlab-manager 
            $ jupyter labextension install bqplot
            
            import bqplot
            
            How to insert tooltips in a scatter plot with bqplot
            Pythondot img6Lines of Code : 23dot img6License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            def_tt = Tooltip(fields=['index', 'x', 'y'], formats = ['','.2f'],)
            
            from bqplot import pyplot as plt
            from bqplot import Tooltip
            from bqplot import Scatter
            from ipywidgets import Output
            
            fig = plt.figure(title='My t
            Interactive Covid Plot with Multiple iPyWidgets Dropdowns
            Pythondot img7Lines of Code : 133dot img7License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            from ipywidgets.widgets import Dropdown, Button
            from ipywidgets.widgets import Layout, HBox, VBox
            import bqplot as bq
            import pandas as pd
            
            #make example DF
            date_list = ['2020-02-01','2020-02-01','2020-02-01','2020-02-01','2020-02-07','2020
            bqplot - Tick placement outside of plot
            Pythondot img8Lines of Code : 17dot img8License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            x_data = df_ts.columns.values.tolist()
            y_end = df_ts.loc[end_date, :].values.flatten()
            y_start = df_ts.loc[start_date, :].values.flatten()
            
            x_sc = OrdinalScale()
            y_sc = LinearScale()
            ax_x = Axis(label='RIC', scale=x_sc, grid_lines='solid',
            Using bqplot tooltip with a dataframe
            Pythondot img9Lines of Code : 5dot img9License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
                def hover_handler(map, hover_event):
                        out.clear_output()
                        with out:
                            print(hover_event)
            
            Container as tooltip doesn't show contents
            Pythondot img10Lines of Code : 21dot img10License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
                import bqplot as bqp
                import ipywidgets as ipw
                from IPython.display import display, clear_output
            
                xSc = bqp.LinearScale()
                ySc = bqp.LinearScale()
            
            
                out = ipw.Output()
            
                def hover_handler(self, content):
                    ou

            Community Discussions

            QUESTION

            How to prevent recursion with interactive plot in bqplot?
            Asked 2020-Nov-30 at 12:19

            I created an interactive scatterplot using bqplot where you are allowed to drag points around (using enable_move=True).

            I don't want the user to drag points above the line y=x. If they do, I want the point to snap back to where it was most recently.

            The problem is that I'm not sure how to avoid infinite recursion here.

            The scatterplot needs to be aware of when its points are moved in order to check the move and possibly snap back. However, when it begins to snap back, this change (of the point positions) seems to trigger that same callback.

            Can anyone tell me the "correct" way to deal with this basic issue?

            ...

            ANSWER

            Answered 2020-Nov-30 at 12:19

            You can temporarily disable the observe in the on_point_move function. I've changed the logic a bit too.

            Source https://stackoverflow.com/questions/65052497

            QUESTION

            bqplot filled Lines blocks tooltip
            Asked 2020-Oct-06 at 12:12

            I'm trying to plot a time series forecast, surrounded by a shaded uncertainty interval timeseries, and have tooltips work for both the line and the perimeter of the uncertainty.

            ...

            ANSWER

            Answered 2020-Oct-06 at 12:12

            You'll kick yourself...reorder the marks in the Figure call to place the uncertainty first, and the line second. The order of the list functions similarly to zorder in matplotlib.

            Source https://stackoverflow.com/questions/64217942

            QUESTION

            Using multiple sliders to create dynamic chart in bqplt/jupyter
            Asked 2020-Jul-31 at 06:04

            I am trying to plot a dynamic portfolio performance that changes as the weights of the portfolio change

            Assume a portfolio has 2 components with a 50% weighting each. I want to show a chart of the portfolio with sliders representing the weights of the components. I then want to be able to slide the values of the weights around and have the portfolio chart dynamically update.

            I have done this for a portfolio that consists of one weight but cant figure out how to amend for more than 1 weight - maybe I need a different approach.

            Example below substitutes a random df with 1 column in place of my portfolio df - process should be the same.

            In terms of this example if the df had 2 columns - how can I get it working with 2 sliders controlling each weight ?

            from bqplot import DateScale, LinearScale, Axis, Figure, Lines

            from ipywidgets import FloatSlider, VBox

            import pandas as pd

            import numpy as np

            slider = FloatSlider(value=1, min = 0, max = 1, step = .01, description = 'Weight A')

            df = pd.DataFrame(np.random.randint(0,100,size=(100, 1)), columns=list('A'))

            x_sc = LinearScale()

            y_sc = LinearScale()

            ax_x = Axis(label='Date', scale=x_sc, grid_lines='solid')

            ax_y = Axis(label='Price', scale=y_sc, orientation='vertical', grid_lines='solid')

            line = Lines(y=df['A'],x=df.index , scales={'x': x_sc, 'y': y_sc}, colors = ['#FF0000'])

            line2 = Lines(y=df['A'],x=df.index , scales={'x': x_sc, 'y': y_sc})

            fig = Figure(axes=[ax_x, ax_y], marks=[line, line2], title='Price Chart')

            def new_chart(value):

            ...

            ANSWER

            Answered 2020-Jul-31 at 06:04

            Not sure if I have understood you. Do you mean this?

            Source https://stackoverflow.com/questions/63150940

            QUESTION

            Plots and widgets not showing on jupyter lab
            Asked 2020-Jun-16 at 13:48

            If I run this code on a jupyter notebook

            ...

            ANSWER

            Answered 2020-Jun-16 at 13:42

            Hi just type this in a cell and then run it, it should work!

            Source https://stackoverflow.com/questions/62409913

            QUESTION

            Interactive Covid Plot with Multiple iPyWidgets Dropdowns
            Asked 2020-Apr-21 at 17:24

            I'm attempting to put together a Jupyter Notebook that allows a user to input a state in a dropdown, which would change the result in the second dropdown to only show cities from that state. Once the city is selected, a button could be pressed to refresh the graph (I realize there's you can use manual with interact, but was unable to get this to function properly) and show the resultant data (covid cases over time). I've had some success making the widgets, but I can't get the data to plot correctly.

            This is my first time using widgets in Jupyter and I'm a bit lost what with interact, interactivity, display, and observe (not to mention the deprecated on_trait_change). Here's what I have so far...

            ...

            ANSWER

            Answered 2020-Apr-21 at 17:24
            from ipywidgets.widgets import Dropdown, Button
            from ipywidgets.widgets import Layout, HBox, VBox
            import bqplot as bq
            import pandas as pd
            
            #make example DF
            date_list = ['2020-02-01','2020-02-01','2020-02-01','2020-02-01','2020-02-07','2020-02-07','2020-02-07','2020-02-07']
            state_list = ['CA','NY','CA','NY','CA','NY','CA','NY']
            city_list = ['San Fran','NYC','LA','Albany','San Fran','NYC','LA','Albany']
            cases_list = [0,10,0,12,2,6,4,8]
            
            df = pd.DataFrame(index=date_list)
            df['state'] = state_list
            df['city'] = city_list
            df['cases'] = cases_list
            
            df.index = pd.to_datetime(df.index)
            df.rename_axis("date", axis='index', inplace=True)
            
            #getting unique state list sorted in alphabetical order
            state_unique = df['state'].unique()
            state_unique.sort()
            
            #make graphical parts - 2 dropdowns and refresh button
            state = Dropdown(
                options=['All'] + list(state_unique),
                value='All', #indicates default starting value
                description='State:', #this is the label for the dropdown
                layout=Layout(width='200px',
                margin = '0px 0px 0px 0px')
            )
            
            city = Dropdown(
                description='City:',
                layout=Layout(width='200px',
                margin = '0px 0px 0px 0px')
            )
            
            b_refresh = Button(
                description='Refresh',
                icon='fa-refresh',
                button_style='warning',
                layout=Layout(width='100px',
                          margin = '0px 0px 0px 60px')
            )
            
            #make graph parts
            x = list(df.index.unique())
            y = list(df.groupby('date')['cases'].sum())
            
            xs = bq.DateScale()
            ys = bq.LinearScale(min=0)
            
            line = bq.Lines(
                x=x, 
                y=y, 
                scales={'x': xs, 'y': ys}
                )
            
            x_ax = bq.Axis(
                scale=xs, 
                label='Dates', 
                grid_lines='solid', 
                tick_format='%m-%d', 
                tick_rotate=-0, 
                label_location ='middle',
                label_offset = "40px"
            )
            
            y_ax = bq.Axis(
                scale=ys, 
                orientation='vertical', 
                tick_format=',d', 
                label='FillInLater', 
                grid_lines='solid',
                label_offset = "60px"
            )
            
            # function that updates 'city' dropdown depending on value in 'state' dropdown
            def list_cities(x):
                if state.value == 'All':
                    global y
                    city.options = ['']
                    y = list(df.groupby('date')['cases'].sum())
                else:
                    temp = ['All'] + sorted(df.loc[df['state'].eq(state.value),'city'].unique())
                    city.options = temp
                    update_city(x)
            
            
            # function that updates graph's y values depending on value in 'city' dropdown
            def update_city(x):
                global y
                if city.value == 'All':
                    matching_cities = df.loc[(df['state']==state.value),'cases'].to_frame(name='cases')
                    y = list(matching_cities.groupby('date')['cases'].sum())       
                else:
                    y = list(df.loc[\
                    (df['city']==city.value)&\
                    (df['state']==state.value),'cases'])
            
            # update plot function
            def set_plot(b):
                global y
                line.y = [y]
            
            
            #assign widget actions to functions
            state.observe(list_cities, names = 'value') #the names part tells .observe the change name to look for, this is only looking for value changes
            city.observe(update_city, names = 'value')        
            b_refresh.on_click(set_plot)
            
            #display all
            fig = bq.Figure(
                layout=Layout(width='95%', height='400px', border ='solid 1px gray'),
                axes=[x_ax, y_ax],
                marks=[line],
                fig_margin=dict(top=10, bottom=80, left=80, right=20),
                animation_duration=500
            )
            
            box = HBox(
                children=(state, city, b_refresh),
                layout=Layout(margin = '10px 0px 10px 0px')
            )
            
            vert_box  = VBox(
                children=(box, fig),
                layout=Layout(border='solid 1px gray', margin = '0 0 0 0')
            )
            
            display (vert_box)
            

            Source https://stackoverflow.com/questions/60983438

            QUESTION

            Bqplot in jupyter lab returns a string instead of an (interactive) image
            Asked 2020-Apr-09 at 13:55

            Today I've been trying to install the module bqplot and use jupyter lab for the very first time.

            However, I've not been able to obtain the desired output when using the basic examples as shown on their website.

            The code I'm trying to execute is as following:

            ...

            ANSWER

            Answered 2020-Apr-09 at 13:55

            I had the same issue and solved it by installing both the bqplot labextension and the @jupyter-widgets/jupyterlab-manager extension:

            Source https://stackoverflow.com/questions/59571054

            QUESTION

            Using Widgets in Google Colaboratory
            Asked 2020-Mar-04 at 15:40

            Is it possible to use Jupyter Widgets in Google Colaboratory?

            I followed the instructions here, both with ipyleaflet and bqplot

            But I got this error message.

            Failed to display Jupyter Widget of type Map.

            If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean that the widgets JavaScript is still loading. If this message persists, it likely means that the widgets JavaScript library is either not installed or not enabled. See the Jupyter Widgets Documentation for setup instructions.

            If you're reading this message in another frontend (for example, a static rendering on GitHub or NBViewer), it may mean that your frontend doesn't currently support widgets.

            Is it possible to use these widgets? Or did I make a mistake somewhere?

            ...

            ANSWER

            Answered 2017-Dec-07 at 03:29

            It is not currently possible to use them- currently comms messages are not supported, the WidgetManager code is not loaded into outputframes, and multiple output frames on a page is not a configuration that the WidgetManager works with.

            Feel free to open a bug at https://github.com/googlecolab/colabtools/issues

            Source https://stackoverflow.com/questions/47686323

            QUESTION

            Tooltip data shows up NaN in bqplot Lines chart
            Asked 2019-Dec-24 at 10:16

            I am having trouble getting my tooltip data to show up in my line chart. Here is some very simple code that reproduces the error. When I hover over the line all that shows up is NaN. Can someone please help me? Thank you!

            from bqplot import (Axis, LinearScale, Lines, Figure, Tooltip)

            x = [1,2,3,4,5]

            y = [1,2,3,4,5]

            x_sc = LinearScale()

            y_sc = LinearScale()

            def_tt = Tooltip(fields=['x', 'y'], formats=['.1f', '.1f'])

            line_chart = Lines(x=x, y=y, scales= {'x': x_sc, 'y': y_sc}, line_style='solid',default_colors=['dodgerblue'], tooltip=def_tt)

            ax_x = Axis(scale=x_sc)

            ax_y = Axis(scale=y_sc, orientation='vertical', tick_format='0.2f')

            Figure(marks=[line_chart], axes=[ax_x, ax_y])

            ...

            ANSWER

            Answered 2019-Dec-24 at 10:16

            Looks like this is an open issue with bqplot (https://github.com/bloomberg/bqplot/issues/702)

            One workaround I found around this was to create a scatter chart (for which the tooltip works in the expected way), and plot this with invisible, fully transparent markers. Then plot your visible line on top.

            Source https://stackoverflow.com/questions/59431484

            QUESTION

            How to change color back from HSV to RGB
            Asked 2019-Nov-22 at 08:40

            I am doing a little experiment to debug my project. I am trying to manipulate the hue value on HSV colorspace to see the effect on it when I change it back to RGB.

            I have a simple image with whole blue background and a single red circle inside of it. I convert it from RGB to HSV and then change one of the values, and then revert it back to the previous value (please see the code, I can't explain it well by using just words). I was expecting the image to remain the same but to my surprise, when I changed it back from HSV to RGB it gives different image.

            ...

            ANSWER

            Answered 2019-Nov-22 at 07:28

            Basically, you just used the wrong ColorConversionCode for your second conversion. If you use COLOR_BGR2HSV_FULL for the "forward conversion", you need to use COLOR_HSV2BGR_FULL for the "backward conversion". You used COLOR_HSV2RGB, which is indeed wrong in two ways: (1) You convert to RGB instead of BGR, and (2) you don't use the full conversion for the H channel.

            Source https://stackoverflow.com/questions/58988491

            QUESTION

            Using bqplot tooltip with a dataframe
            Asked 2019-Oct-08 at 15:13

            Use widget to display snippets from a csv file/dataframe and feed to tooltip attribute of bqplot

            I am trying to display certain info (statistics such as age group, income, obesity levels etc.) for each state in the US using bqplot. I am able to plot the US map using examples provided on bqplot github. But the tooltip constructor is using columns names from a json file, which is also used to actually display the map. I do not know how to override that so, I decided to use a widget (ideally a container widget) to hold the data I want to display for each state and use the on_hover() method provided in bqplot.map; In fact, I just modified the code in the link below:

            Container as tooltip doesn't show contents

            to display info for a particular state

            ...

            ANSWER

            Answered 2019-Oct-08 at 15:13

            For Point 2:

            In your hover_handler code, you need to capture the information being passed through to the function, and use it to filter your master dataframe (df). Try changing your hover_handler code to the below, and see what info is being passed to the function. Then work out how to use this information to filter your dataframe to just the relevant state.

            Source https://stackoverflow.com/questions/58278783

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install bqplot

            If you are using JupyterLab <=2:.
            In order to install a previous bqplot version, you need to know which front-end version (JavaScript) matches with the back-end version (Python). For example, in order to install bqplot 0.11.9, you need the labextension version 0.4.9.

            Support

            Full documentation is available at https://bqplot.readthedocs.io/.
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            Install
          • PyPI

            pip install bqplot

          • CLONE
          • HTTPS

            https://github.com/bqplot/bqplot.git

          • CLI

            gh repo clone bqplot/bqplot

          • sshUrl

            git@github.com:bqplot/bqplot.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link