Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Altair Tutorial

Eitan Lees
November 10, 2018

Altair Tutorial

Here are the slides presented at an Altair tutorial and workshop I gave in the Department of Scientific Computing at FSU.

Eitan Lees

November 10, 2018
Tweet

More Decks by Eitan Lees

Other Decks in Technology

Transcript

  1. Exploratory Data
    Visualization with Altair

    View Slide

  2. View Slide

  3. Acknowledgments
    - Altair is developed by Jake
    Vanderplas and Brian Granger in
    close collaboration with the UW
    Interactive Data Lab
    - Much of this tutorial is from Jake
    Vanderplas’ PyCon 2018 tutorial
    - Special thanks to the Altair
    Community on GitHub.

    View Slide

  4. Python Visualization Landscape

    View Slide

  5. Python Visualization Landscape

    View Slide

  6. Building Blocks of
    Visualization
    1. Data
    2. Transformations
    3. Marks
    4. Encoding - mapping from fields to mark
    properties
    5. Scale - functions that map data to visual
    scales
    6. Guides - visualizations of scales (axes,
    legends, etc.)

    View Slide

  7. Key: Visualization concepts should map
    directly to visualization implementation

    View Slide

  8. Hypothesis: Good implementation can
    influence good conceptualization

    View Slide

  9. ~ familiar tools ~

    View Slide

  10. View Slide

  11. View Slide

  12. Strengths:
    - Designed like MatLab: switching was easy
    - Many rendering backends
    - Can reproduce just about any plot (with a bit of effort)
    - Well-tested, standard tool for over a decade
    Weaknesses:
    - API is imperative & often overly verbose
    - Poor support for web/interactive graphics
    - Often slow for large & complicated data

    View Slide

  13. Example: Statistical Data
    Tidy data: i.e. rows are samples, columns are features

    View Slide

  14. Tidy data: i.e. rows are samples, columns are features
    “ I want to scatter petal length vs.
    sepal length, and color by species”
    Example: Statistical Data

    View Slide

  15. View Slide

  16. View Slide

  17. Problem:
    We’re mixing the what with the how

    View Slide

  18. Toward a well-motivated
    Declarative Visualization
    Imperative
    - Specify How something
    should be done.
    - Specification &
    Execution intertwined.
    - “Put a red circle here
    and a blue circle here”
    Declarative
    - Specify What should be
    done.
    - Separates Specification
    from Execution
    - “Map to a position,
    and to a color”
    Declarative visualizations lets you think about the data
    and relationships, rather than incidental details

    View Slide

  19. Toward a well-motivated
    Declarative Visualization
    Imperative
    - Specify How something
    should be done.
    - Specification &
    Execution intertwined.
    - “Put a red circle here
    and a blue circle here”
    Declarative
    - Specify What should be
    done.
    - Separates Specification
    from Execution
    - “Map to a position,
    and to a color”
    Declarative visualizations lets you think about the data
    and relationships, rather than incidental details

    View Slide

  20. Based on the Vega and Vega-Lite grammars
    https://altair-viz.github.io/
    Altair
    Declarative visualization in Python

    View Slide

  21. Altair for Statistical Visualization

    View Slide

  22. Encodings are Flexible:

    View Slide

  23. Altair is Interactive

    View Slide

  24. ...

    View Slide

  25. View Slide

  26. ~ From D3 to Vega to Altair
    ~

    View Slide

  27. D3 is everywhere

    View Slide

  28. But working with D3 can
    be challenging ...

    View Slide

  29. “Simple”
    Barchart

    View Slide

  30. D3 is a Javascript package
    that streamlines the
    manipulation of objects on
    a webpage

    View Slide

  31. Vega is a detailed
    declarative specification
    for visualizations, built on
    D3

    View Slide

  32. Vega-Lite is a simpler
    declarative specification
    aimed at statistical
    visualization

    View Slide

  33. Altair is a Python API for
    creating Vega-Lite
    specifications

    View Slide

  34. View Slide

  35. ~ Thinking about Visualization ~

    View Slide

  36. View Slide

  37. View Slide

  38. View Slide

  39. View Slide

  40. View Slide

  41. View Slide

  42. View Slide

  43. View Slide

  44. View Slide

  45. Key: Visualization concepts should map
    directly to visualization implementation
    Check out Jeff Heer’s class on data visualization https://courses.cs.washington.edu/courses/cse442/17au/

    View Slide