A Bokeh project developed for learning and teaching Bokeh interactive plotting!

Overview

Bokeh-Python-Visualization

A Bokeh project developed for learning and teaching Bokeh interactive plotting!

See my medium blog posts about making bokeh apps.

Requirements:

  • Python 3.6 (may work on other versions but has not been tested)
  • bokeh 0.12.16 (bokeh is a work in progress so subsequents update may break functionality. I will try to update as I can.)

The main application is located in the bokeh_app folder. To run the application, open a command prompt, change to the directory containing bokeh_app and run bokeh serve --show bokeh_app/. This runs a bokeh server locally and will automatically open the interactive dashboard in your browser at localhost:5006.

Any comments, suggestions, improvements are greatly appreciated!

Comments
  • AttributeError: 'str' object has no attribute 'append' using Python 3.5.3 and bokeh 0.12.16

    AttributeError: 'str' object has no attribute 'append' using Python 3.5.3 and bokeh 0.12.16

    I had to comment out these 2 lines in scripts/draw_map.py

    hover_line.renderers.append(lines_glyph) hover_circle.renderers.append(circles_glyph)

    otherwise I would receive the following error and a blank page in the browser.

    2018-05-24 16:59:06,237 Starting Bokeh server version 0.12.16 (running on Tornado 5.0.2) 2018-05-24 16:59:06,243 Bokeh app running at: http://localhost:5006/bokeh_app 2018-05-24 16:59:06,243 Starting Bokeh server with process id: 18459 [18471:18493:0524/165906.877041:ERROR:browser_gpu_channel_host_factory.cc(119)] Failed to launch GPU process. Created new window in existing browser session. /home/foo/.virtualenvs/BokehDashbord-8BNqqEK8/lib/python3.5/site-packages/pandas/core/frame.py:6201: FutureWarning: Sorting because non-concatenation axis is not aligned. A future version of pandas will change to not sort by default.

    To accept the future behavior, pass 'sort=True'.

    To retain the current behavior and silence the warning, pass sort=False

    sort=sort) 2018-05-24 16:59:10,798 Error running application handler <bokeh.application.handlers.directory.DirectoryHandler object at 0x7fe98e428fd0>: 'str' object has no attribute 'append' File "draw_map.py", line 142, in make_plot: hover_circle.renderers.append(circles_glyph) Traceback (most recent call last): File "/home/foo/.virtualenvs/BokehDashbord-8BNqqEK8/lib/python3.5/site-packages/bokeh/application/handlers/code_runner.py", line 163, in run exec(self._code, module.dict) File "/home/foo/code/BokehDashbord/bokeh_app/main.py", line 34, in tab4 = map_tab(map_data, states) File "/home/foo/code/BokehDashbord/bokeh_app/scripts/draw_map.py", line 208, in map_tab p = make_plot(src, xs, ys) File "/home/foo/code/BokehDashbord/bokeh_app/scripts/draw_map.py", line 142, in make_plot hover_circle.renderers.append(circles_glyph) AttributeError: 'str' object has no attribute 'append'

    opened by dazzag24 3
  • Install Manual / App not starting

    Install Manual / App not starting

    Hi Will, I saw your post on medium and just wanted to take a quick look, before diving deeper. :) So I cloned your project and installed missing dependencies, but it is not starting? A requirements file would be nice too.

    Mabye you have an idea why it is not starting. Tried with python 3.65 (latest) on Win10 to start via "bokeh_app\main.py".

    It looks like it starts and then gives me back the command prompt without any error message. I normally don't use python, so maybe I'm the issue. ;-)

    KR,

    Peter

    opened by peschu123 2
  • Fix for attribute error caused by updated version of Bokeh (2.3.2)

    Fix for attribute error caused by updated version of Bokeh (2.3.2)

    I updated three files in Scripts: density, draw_map, and histogram . Replaced airline_colors.sort() with airline_colors = sorted(airline_colors) in each file. This resolves error: "AttributeError: 'tuple' object has no attribute 'sort'"

    opened by kellystroh 1
  • ImportError: cannot import name 'return_future'

    ImportError: cannot import name 'return_future'

    ImportError: cannot import name 'return_future' when show(app). tornado.concurrent can be imported manually, but fail to from tornado.concurrent import return_future;

    opened by SBFallout 0
  • AttributeError: 'Application' object has no attribute 'references' in Interactive Demo

    AttributeError: 'Application' object has no attribute 'references' in Interactive Demo

    When running the Interactive example in Jupyter, in "Plot with Carrier Select Control" in "show(app)" I get the following error:

    AttributeError: 'Application' object has no attribute 'references' in Interactive Demo

    opened by snollygoster123123 0
  • Add a .gitignore file so that __pycache__ files are not stored in github

    Add a .gitignore file so that __pycache__ files are not stored in github

    e.g a simple .gitignore file in this case would contain

    pycache/

    However it is a good idea to create a more comprehensive file tailored to your IDE. See https://www.gitignore.io/ for examples.

    opened by dazzag24 0
  • CheckboxGroup active list not updating

    CheckboxGroup active list not updating

    Hi,

    I'm trying to replicate the second in your series of tutorials but am having trouble with the CheckboxGroup part. While the initial carriers load and appear, there seems to be a disconnect that's preventing the CheckboxGroup active list from updating data displayed in the histogram. So when I check or uncheck a box, it won't be reflected in the histogram.

    I've removed the binwidth and range sliders to cut down on the problem. Otherwise the code below is essentially as the original in your github.

    def` histogram_bokeh(flights):
        
        def make_dataset(carrier_list, range_start = -60, range_end = 120, bin_width=5):
        
            #check to make sure start is less than end:
            assert range_start < range_end, "Start must be less than end!"
    
            by_carrier = pd.DataFrame(columns=['proportion', 'left', 'right',
                                              'f_proportion', 'f_interval',
                                              'name', 'color'])
            range_extent = range_end - range_start
    
            for i, carrier_name in enumerate(carrier_list):
    
                #subset to the carrier
                subset = flights[flights['name'] == carrier_name]
    
                # Create a histogram
                arr_hist, edges = np.histogram(subset['arr_delay'],
                                              bins = int(range_extent / bin_width),
                                              range = [range_start, range_end])
    
                # Divide the counts by the total to get a proportion and create df
                arr_df = pd.DataFrame({'proportion': arr_hist / np.sum(arr_hist),
                                      'left': edges[:-1],
                                      'right': edges [1:]})
    
                #Format the proportion
                arr_df['f_proportion'] = ['%0.5f' % proportion for proportion in arr_df['proportion']]
    
                #Format the interval
                arr_df['f_interval'] = ['%d to %d minutes' % (left, right) for left,
                                        right in zip(arr_df['left'], arr_df['right'])]
                #Assign the carrier for labels
                arr_df['name'] = carrier_name
                #Colour each carrier differently
                arr_df['color'] = Category20_16[i]
                #Add to the overall dataframe
                by_carrier = by_carrier.append(arr_df)
            
            # Overall dataframe
            by_carrier = by_carrier.sort_values(['name','left'])
            
            #Convert dataframe to column data source
            return ColumnDataSource(by_carrier)
            
        def make_plot(src):
            # Blank plot with correct labels
            p = figure(plot_width = 700, plot_height = 700,
                      title = "Histogram of Arrival Delays by Carrier",
                      x_axis_label = 'Delay (min)', y_axis_label = 'Proportion')
    
            # Quad glyphs to create a histogram
            p.quad(source = src, bottom = 0, top = 'proportion', left = 'left', right = 'right',
                  color = 'color', fill_alpha = 0.7, hover_fill_color = 'color', legend = 'name',
                  hover_fill_alpha = 1.0, line_color = 'black')
    
            # HoverTool
            hover = HoverTool(tooltips=[('Carrier', '@name'),
                                       ('Delay', '@f_interval'),
                                       ('Proportion', '@f_proportion')])
            p.add_tools(hover)
            return p
        
        
        def update(attr, old, new):
            carriers_to_plot = [carrier_selection.labels[i] for i in carrier_selection.active]
            new_src = make_dataset(carriers_to_plot)
            src.data.update(new_src.data)    
        
        carrier_selection = CheckboxGroup(labels = available_carriers, active=[0,1,9])
        carrier_selection.on_change('active', update)
        
        initial_carriers = [carrier_selection.labels[i] for i in carrier_selection.active]
        src = make_dataset(initial_carriers)
        
        p = make_plot(src)
            
        controls = WidgetBox(carrier_selection)
        
        # Create a row layout
        layout = row(controls, p)
        
        # make a tab with the layout
        tab = Panel(title = "histogram", child = layout) 
        tabs = Tabs(tabs=[tab]) #add tab2 to list for additional tabs
        
        return tabs
    
    show(histogram_bokeh(flights))
    

    Note that I found I need Panels in the last section to make it work. Otherwise, essentially the same. I suspect there might be something in the update function that's causing it to not work?

    I am using bokeh 0.12.16.

    Thanks!

    opened by fabhlc 6
  • Failed to load resource: the server responded with a status of 404 (Not Found)

    Failed to load resource: the server responded with a status of 404 (Not Found)

    I followed all the instructions but when I run bokeh serve command the page opens in browser but doesn't display anything, when I inspect element, I see this message. What could be the problem?

    opened by Usama-Aslam23 2
Owner
Will Koehrsen
Data Scientist at Cortex Intel. Data Science communicator for Towards Data Science.
Will Koehrsen
Interactive plotting for Pandas using Vega-Lite

pdvega: Vega-Lite plotting for Pandas Dataframes pdvega is a library that allows you to quickly create interactive Vega-Lite plots from Pandas datafra

Altair 342 Oct 26, 2022
Interactive plotting for Pandas using Vega-Lite

pdvega: Vega-Lite plotting for Pandas Dataframes pdvega is a library that allows you to quickly create interactive Vega-Lite plots from Pandas datafra

Altair 340 Feb 1, 2021
Personal IMDB Graphs with Bokeh

Personal IMDB Graphs with Bokeh Do you like watching movies and also rate all of them in IMDB? Would you like to look at your IMDB stats based on your

null 2 Dec 15, 2021
Resources for teaching & learning practical data visualization with python.

Practical Data Visualization with Python Overview All views expressed on this site are my own and do not represent the opinions of any entity with whi

Paul Jeffries 98 Sep 24, 2022
Python scripts for plotting audiograms and related data from Interacoustics Equinox audiometer and Otoaccess software.

audiometry Python scripts for plotting audiograms and related data from Interacoustics Equinox 2.0 audiometer and Otoaccess software. Maybe similar sc

Hamilton Lab at UT Austin 2 Jun 15, 2022
Analysis and plotting for motor/prop/ESC characterization, thrust vs RPM and torque vs thrust

esc_test This is a Python package used to plot and analyze data collected for the purpose of characterizing a particular propeller, motor, and ESC con

Alex Spitzer 1 Dec 28, 2021
3D plotting and mesh analysis through a streamlined interface for the Visualization Toolkit (VTK)

PyVista Deployment Build Status Metrics Citation License Community 3D plotting and mesh analysis through a streamlined interface for the Visualization

PyVista 1.6k Jan 8, 2023
A high-level plotting API for pandas, dask, xarray, and networkx built on HoloViews

hvPlot A high-level plotting API for the PyData ecosystem built on HoloViews. Build Status Coverage Latest dev release Latest release Docs What is it?

HoloViz 697 Jan 6, 2023
3D plotting and mesh analysis through a streamlined interface for the Visualization Toolkit (VTK)

PyVista Deployment Build Status Metrics Citation License Community 3D plotting and mesh analysis through a streamlined interface for the Visualization

PyVista 692 Feb 18, 2021
A high-level plotting API for pandas, dask, xarray, and networkx built on HoloViews

hvPlot A high-level plotting API for the PyData ecosystem built on HoloViews. Build Status Coverage Latest dev release Latest release Docs What is it?

HoloViz 349 Feb 15, 2021
This is a Cross-Platform Plot Manager for Chia Plotting that is simple, easy-to-use, and reliable.

Swar's Chia Plot Manager A plot manager for Chia plotting: https://www.chia.net/ Development Version: v0.0.1 This is a cross-platform Chia Plot Manage

Swar Patel 1.3k Dec 13, 2022
Plotting data from the landroid and a raspberry pi zero to a influx-db

landroid-pi-influx Plotting data from the landroid and a raspberry pi zero to a influx-db Dependancies Hardware: Landroid WR130E Raspberry Pi Zero Wif

null 2 Oct 22, 2021
A simple code for plotting figure, colorbar, and cropping with python

Python Plotting Tools This repository provides a python code to generate figures (e.g., curves and barcharts) that can be used in the paper to show th

Guanying Chen 134 Jan 2, 2023
Plotting library for IPython/Jupyter notebooks

bqplot 2-D plotting library for Project Jupyter Introduction bqplot is a 2-D visualization system for Jupyter, based on the constructs of the Grammar

null 3.4k Dec 29, 2022
Simple plotting for Python. Python wrapper for D3xter - render charts in the browser with simple Python syntax.

PyDexter Simple plotting for Python. Python wrapper for D3xter - render charts in the browser with simple Python syntax. Setup $ pip install PyDexter

D3xter 31 Mar 6, 2021
An intuitive library to add plotting functionality to scikit-learn objects.

Welcome to Scikit-plot Single line functions for detailed visualizations The quickest and easiest way to go from analysis... ...to this. Scikit-plot i

Reiichiro Nakano 2.3k Dec 31, 2022
🎨 Python3 binding for `@AntV/G2Plot` Plotting Library .

PyG2Plot ?? Python3 binding for @AntV/G2Plot which an interactive and responsive charting library. Based on the grammar of graphics, you can easily ma

hustcc 990 Jan 5, 2023
NorthPitch is a python soccer plotting library that sits on top of Matplotlib

NorthPitch is a python soccer plotting library that sits on top of Matplotlib.

Devin Pleuler 30 Feb 22, 2022
matplotlib: plotting with Python

Matplotlib is a comprehensive library for creating static, animated, and interactive visualizations in Python. Check out our home page for more inform

Matplotlib Developers 16.7k Jan 8, 2023