Interactive Dashboards and Data Apps with Plotly and Dash

Book description

Build web-based, mobile-friendly analytic apps and interactive dashboards with Python

Key Features

  • Develop data apps and dashboards without any knowledge of JavaScript
  • Map different types of data such as integers, floats, and dates to bar charts, scatter plots, and more
  • Create controls and visual elements with multiple inputs and outputs and add functionality to the app as per your requirements

Book Description

Plotly's Dash framework is a life-saver for Python developers who want to develop complete data apps and interactive dashboards without JavaScript, but you'll need to have the right guide to make sure you’re getting the most of it. With the help of this book, you'll be able to explore the functionalities of Dash for visualizing data in different ways.

Interactive Dashboards and Data Apps with Plotly and Dash will first give you an overview of the Dash ecosystem, its main packages, and the third-party packages crucial for structuring and building different parts of your apps. You'll learn how to create a basic Dash app and add different features to it.

Next, you’ll integrate controls such as dropdowns, checkboxes, sliders, date pickers, and more in the app and then link them to charts and other outputs. Depending on the data you are visualizing, you'll also add several types of charts, including scatter plots, line plots, bar charts, histograms, and maps, as well as explore the options available for customizing them.

By the end of this book, you'll have developed the skills you need to create and deploy an interactive dashboard, handle complexities and code refactoring, and understand the process of improving your application.

What you will learn

  • Find out how to run a fully interactive and easy-to-use app
  • Convert your charts to various formats including images and HTML files
  • Use Plotly Express and the grammar of graphics for easily mapping data to various visual attributes
  • Create different chart types, such as bar charts, scatter plots, histograms, maps, and more
  • Expand your app by creating dynamic pages that generate content based on URLs
  • Implement new callbacks to manage charts based on URLs and vice versa

Who this book is for

This Plotly Dash book is for data professionals and data analysts who want to gain a better understanding of their data with the help of different visualizations and dashboards – and without having to use JS. Basic knowledge of the Python programming language and HTML will help you to grasp the concepts covered in this book more effectively, but it’s not a prerequisite.

Table of contents

  1. Interactive Dashboards and Data Apps with Plotly and Dash
  2. Contributors
  3. About the author
  4. About the reviewer
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
    4. Download the example code files
    5. Download the color images
    6. Code in Action
    7. Conventions used
    8. Get in touch
    9. Reviews
  6. Section 1: Building a Dash App
  7. Chapter 1: Overview of the Dash Ecosystem
    1. Technical requirements
    2. Setting up your environment
    3. Exploring Dash and other supporting packages
      1. The different packages that Dash contains
    4. Understanding the general structure of a Dash app
    5. Creating and running the simplest app
    6. Adding HTML and other components to the app
      1. Adding HTML components to a Dash app
    7. Learning how to structure the layout and managing themes
      1. Themes
      2. Grid system and responsiveness
      3. Prebuilt components
      4. Encoded colors
      5. Adding Dash Bootstrap components to our app
    8. Summary
  8. Chapter 2: Exploring the Structure of a Dash App
    1. Technical requirements
    2. Using Jupyter Notebooks to run Dash apps
      1. Isolating functionality for better management and debugging
    3. Creating a standalone pure Python function
    4. The id parameter of Dash components
    5. Dash inputs and outputs
      1. Determining your inputs and outputs
      2. Specifying your callback function
      3. Implementing the callback
    6. Incorporating the function into the app
      1. Properties of Dash's callback functions
    7. Summary
  9. Chapter 3: Working with Plotly's Figure Objects
    1. Technical requirements
    2. Understanding the Figure object
    3. Getting to know the data attribute
    4. Getting to know the layout attribute
      1. Interactively exploring the Figure object
      2. Configuration options for the Figure object
    5. Exploring the different ways of converting figures
      1. Converting figures into HTML
      2. Converting figures into images
      3. Plotting using a real dataset
      4. Data manipulation as an essential part of the data visualization process
      5. Making the chart interactive with a callback function
      6. Adding the new functionality to our app
      7. Theming your figures
    6. Summary
  10. Chapter 4: Data Manipulation and Preparation, Paving the Way to Plotly Express
    1. Technical requirements
    2. Understanding long format (tidy) data
      1. Plotly Express example chart
      2. Main attributes of long format (tidy) data
    3. Understanding the role of data manipulation skills
      1. Exploring the data files
      2. Melting DataFrames
      3. Pivoting DataFrames
      4. Merging DataFrames
    4. Learning Plotly Express
      1. Plotly Express and Figure objects
      2. Creating a Plotly Express chart using the dataset
      3. Adding new data and columns to our dataset
    5. Summary
  11. Section 2: Adding Functionality to Your App with Real Data
  12. Chapter 5: Interactively Comparing Values with Bar Charts and Dropdown Menus
    1. Technical requirements
    2. Plotting bar charts vertically and horizontally
      1. Creating vertical bar charts with many values
    3. Linking bar charts and dropdowns
    4. Exploring different ways of displaying multiple bar charts (stacked, grouped, overlaid, and relative)
      1. Creating the income share DataFrame
      2. Incorporating the functionality into our app
    5. Using facets to split charts into multiple sub-charts – horizontally, vertically, or wrapped
    6. Exploring additional features of dropdowns
      1. Adding placeholder text to dropdowns
      2. Modifying the app's theme
      3. Resizing components
    7. Summary
  13. Chapter 6: Exploring Variables with Scatter Plots and Filtering Subsets with Sliders
    1. Technical requirements
    2. Learning about the different ways of using scatter plots: markers, lines, and text
      1. Markers, lines, and text
    3. Creating multiple scatter traces in a single plot
    4. Mapping and setting colors with scatter plots
      1. Discrete and continuous variables
      2. Using color with continuous variables
      3. Manually creating color scales
      4. Using color with discrete variables
    5. Handling over-plotting and outlier values by managing opacity, symbols, and scales
      1. Controlling the opacity and size of markers
      2. Using logarithmic scales
    6. Introducing sliders and range sliders
    7. Customizing the marks and values of sliders
    8. Summary
  14. Chapter 7: Exploring Map Plots and Enriching Your Dashboards with Markdown
    1. Technical requirements
    2. Exploring choropleth maps
    3. Utilizing animation frames to add a new layer to your plots
    4. Using callback functions with maps
    5. Creating a Markdown component
    6. Understanding map projections
    7. Using scatter map plots
    8. Exploring Mapbox maps
    9. Exploring other map options and tools
    10. Incorporating an interactive map into our app
    11. Summary
  15. Chapter 8: Calculating Data Frequency and Building Interactive Tables
    1. Technical requirements
    2. Creating a histogram
    3. Customizing the histogram by modifying its bins and using multiple histograms
      1. Using color to further split the data
      2. Exploring other ways of displaying multiple bars in histograms
    4. Adding interactivity to histograms
    5. Creating a 2D histogram
    6. Creating a DataTable
    7. Controlling the look and feel of the table (cell width, height, text display, and more)
    8. Adding histograms and tables to the app
    9. Summary
    10. What we have covered so far
  16. Section 3: Taking Your App to the Next Level
  17. Chapter 9: Letting Your Data Speak for Itself with Machine Learning
    1. Technical requirements
    2. Understanding clustering
    3. Finding the optimal number of clusters
    4. Clustering countries by population
    5. Preparing data with scikit-learn
      1. Handling missing values
      2. Scaling data with scikit-learn
    6. Creating an interactive KMeans clustering app
    7. Summary
  18. Chapter 10: Turbo-charge Your Apps with Advanced Callbacks
    1. Technical requirements
    2. Understanding State
      1. Understanding the difference between Input and State
    3. Creating components that control other components
    4. Allowing users to add dynamic components to the app
    5. Introducing pattern-matching callbacks
    6. Summary
  19. Chapter 11: URLs and Multi-Page Apps
    1. Technical requirements
    2. Getting to know the Location and Link components
      1. Getting to know the Link component
    3. Parsing URLs and using their components to modify parts of the app
    4. Restructuring your app to cater to multiple layouts
      1. Displaying content based on the URL
    5. Adding dynamically generated URLs to the app
    6. Incorporating the new URL interactivity into the app
    7. Summary
  20. Chapter 12: Deploying Your App
    1. Technical requirements
    2. Establishing the general development, deployment, and update workflow
    3. Creating a hosting account and virtual server
    4. Connecting to your server with SSH
    5. Running the app on the server
    6. Setting up and running the app with a WSGI
    7. Setting up and configuring the web server
    8. Managing maintenance and updates
      1. Fixing bugs and making changes
      2. Updating Python packages
      3. Maintaining your server
    9. Summary
  21. Chapter 13: Next Steps
    1. Technical requirements
    2. Expanding your data manipulation and preparation skills
    3. Exploring more data visualization techniques
    4. Exploring other Dash components
    5. Creating your own Dash component
    6. Operationalizing and visualizing machine learning models
    7. Enhancing performance and using big data tools
    8. Going large scale with Dash Enterprise
    9. Summary
    10. Why subscribe?
  22. Other Books You May Enjoy
    1. Packt is searching for authors like you
    2. Leave a review - let other readers know what you think

Product information

  • Title: Interactive Dashboards and Data Apps with Plotly and Dash
  • Author(s): Elias Dabbas
  • Release date: May 2021
  • Publisher(s): Packt Publishing
  • ISBN: 9781800568914