Book Image

Interactive Data Visualization with Python - Second Edition

By : Abha Belorkar, Sharath Chandra Guntuku, Shubhangi Hora, Anshu Kumar
Book Image

Interactive Data Visualization with Python - Second Edition

By: Abha Belorkar, Sharath Chandra Guntuku, Shubhangi Hora, Anshu Kumar

Overview of this book

With so much data being continuously generated, developers, who can present data as impactful and interesting visualizations, are always in demand. Interactive Data Visualization with Python sharpens your data exploration skills, tells you everything there is to know about interactive data visualization in Python. You'll begin by learning how to draw various plots with Matplotlib and Seaborn, the non-interactive data visualization libraries. You'll study different types of visualizations, compare them, and find out how to select a particular type of visualization to suit your requirements. After you get a hang of the various non-interactive visualization libraries, you'll learn the principles of intuitive and persuasive data visualization, and use Bokeh and Plotly to transform your visuals into strong stories. You'll also gain insight into how interactive data and model visualization can optimize the performance of a regression model. By the end of the course, you'll have a new skill set that'll make you the go-to person for transforming data visualizations into engaging and interesting stories.
Table of Contents (9 chapters)

5. Interactive Visualization of Data across Time

Activity 5: Create an Interactive Temporal Visualization using RangeTool and Aggregator

  1. Import required libraries:
    from bokeh.io import show
    from bokeh.layouts import column
    from bokeh.models import ColumnDataSource, RangeTool
    from bokeh.plotting import figure
    from bokeh.io import push_notebook, show, output_notebook
    from pathlib import Path
    import pandas as pd
    import numpy as np
    from ipywidgets import interact
    %matplotlib inline
  2. Setup the output to Jupyter Notebook:
    DATA_PATH = Path(“../datasets/chap5_data/”)
    output_notebook()
  3. Create a DataFrame microsoft_df and parse the date column:
    microsoft_df = pd.read_csv(DATA_PATH / “microsoft_stock.csv”, parse_dates=[‘date’])
  4. Set the index as date:
    microsoft_df.index = microsoft_df.date
  5. Create date numpy array and source as ColumnDataSource. We will use these to draw line plot:
    dates = np.array(microsoft_df...