Anatomy of Matplotlib -- tutorial developed for the SciPy conference

Overview

Introduction

This tutorial is a complete re-imagining of how one should teach users the matplotlib library. Hopefully, this tutorial may serve as inspiration for future restructuring of the matplotlib documentation. Plus, I have some ideas of how to improve this tutorial.

Please fork and contribute back improvements! Feel free to use this tutorial for conferences and other opportunities for training.

The tutorial can be viewed on nbviewer:

Installation

All you need is matplotlib (v1.5 or greater) and jupyter installed. You can use your favorite Python package installer for this:

conda install matplotlib jupyter
git clone https://github.com/matplotlib/AnatomyOfMatplotlib.git
cd AnatomyOfMatplotlib
jupyter notebook

A browser window should appear and you can verify that everything works as expected by clicking on the Test Install.ipynb notebook. There, you will see a "code cell" that you can execute. Run it, and you should see a very simple line plot, indicating that all is well.

Comments
  • Updated the categorical example

    Updated the categorical example

    switched code in example to:

    data = [('apples', 2), ('oranges', 3), ('peaches', 1)]
    fruit, value = zip(*data)
    
    fig, ax = plt.subplots()
    ax.bar(fruit, value, align='center', color='gray')
    plt.show()
    
    opened by story645 7
  • Interactive example demo

    Interactive example demo

    This example is inspired from my severe usage of MATLAB overlay plotting where I plot on a figure and based on its distribution/look I do some operation in backend like moving the image to another directory etc. Hoping this example would become handy for someone like me(who moved from MATLAB plotting)
    Discussion : Twitter Link

    opened by nithinraok 6
  • Fixes #26

    Fixes #26

    • /mpl-data/sample_data/axes_grid folder appears to no longer exists as of matplotlib v2.2.2
    • added /assets folder in repo containing dependent numpy pickle, 'bivariate_normal.npy' file
    • revised load of data in AnatomyOfMatplotlib-Part2-Plotting_Methods_Overview.ipynb to reflect this change
    • tested successfully with matplotlib v2.2.2 and python v3.6.6
    opened by ggodreau 4
  • Add knot to Ugly Tie shape

    Add knot to Ugly Tie shape

    Added geometry to the Ugly Tie polygon to look like a knot.

    It remains a single polygon so color will affect both visible parts.

    At large zooms/resolutions a connection between the right side of the knot and the main tie is visible because the points on right side of the knot are not perfectly in-line with the upper right corner of the tie where the two larger parts of the shape are visible. If this becomes an issue, doing some math to find evenly dividing, aligned points near the current values would make the connecting section of the polygon zero width.

    opened by TheAtomicOption 3
  • New plotting overview

    New plotting overview

    I realize this is a bit last-minute and a big change, but I really feel like we were missing a good overview of the various plotting methods.

    I've added a new Part 2 (and renamed the other sections) to cover this: http://nbviewer.ipython.org/url/geology.beer/scipy2015/tutorial/AnatomyOfMatplotlib-Part2-Plotting_Methods_Overview.ipynb

    I've tried to make a lot of nice summary images of the most commonly-used plotting methods. The "full" gallery can be very overwhelming, so it's useful to give people a condensed version. Also, these

    80% of the new Part 2 is just quickly looking those images so that people are vaguely aware of what's out there. The code to generate them is also there to serve as an example.

    The new section only goes over bar, fill_between and imshow in more detail. It's not anywhere near as long as it looks at first glance.

    opened by joferkington 3
  • Convert to new ipynb format

    Convert to new ipynb format

    The ipython notebook format has changed slightly in recent versions. Notebooks in the old format are automatically converted when they're opened with a more recent version, but I wanted to go ahead and commit the new format versions.

    Otherwise the diffs will be very difficult to read.

    I also added a .gitignore to ignore the hidden checkpoint folder IPython adds, if ipython notebook is run from the source directory.

    opened by joferkington 3
  • imshow color bar

    imshow color bar

    Hello matplotlib developers,

    I was watching the Youtube recording: Anatomy of Matplotlib from SciPy 2018, and I have a question about AnatomyOfMatplotlib/solutions/2.2-vmin_vmax_imshow_and_colorbars.py

    From line 17 to 18...

    for ax, data in zip(axes, [data1, data2, data3]): im = ax.imshow(data, vmin=0, vmax=3, interpolation='nearest')

    I am assuming data3 has bigger values, followed by data2 and data2, since data3 is multiplied by 3. Suppose if I switch the order of the list in line 17 from:

    for ax, data in zip(axes, [data1, data2, data3]):

    to:

    for ax, data in zip(axes, [data3, data2, data1]):

    So, the last im object would data1 which has a 10 by 10 array with max value of 1. Since we are giving the last im object to make the colorbar, would that mean the range color bar spans from 0 to around 1? Or does matplotlib somehow manage to look at all three plotted imshows and perceive that the maximum value amongst the three imshows is around 3?

    Thank you!

    opened by ZarulHanifah 2
  • Chapter 2 subsec colorbars example data missing

    Chapter 2 subsec colorbars example data missing

    Seems like the example data used in chapter 2 at the colorbar example is no longer supported as of py 3.1. bivariate_normal.npy is not in any folder and has apparantly been discontinued.

    opened by Nafalem231 2
  • Overhaul of Part 1

    Overhaul of Part 1

    First off, IPython/Jupyter has recently had a .ipynb format change, so these diffs are rather messy. If I'd thought about it more, I would have made that a separate commit, but I didn't realize until edits were underway.

    At any rate, I've changed Part1 rather significantly. I pruned some things out and expanded others. I'm intending to add another section detailing basic categories of plotting functions, so I removed several of the references to those in this section.

    Even after these changes, Part1 is still rather long. I might split it (particularly the part after the second exercise and before the third) into another section.

    At any rate hopefully you can see where I'm going with this. Thanks, and looking forward to teaching here in a few weeks!

    opened by joferkington 1
  • from __future__ import print_function so print works same for Python 2&3

    from __future__ import print_function so print works same for Python 2&3

    Just finished going through the notebooks with Python3 and everything worked fine except for having to manually modify all the print statements. Figured it could be made to seamlessly work with both Python 2 and 3 by simply using a from __future__ import print_function.

    opened by jarthurgross 1
  • Fix some typos, and cleared cell outputs.

    Fix some typos, and cleared cell outputs.

    Also threw out some extraneous sentences. Keep things simple and straight-forward. Resist the temptation to reveal everything at once. I will leave this up for a little bit for comment and then merge later today.

    opened by WeatherGod 0
  • Remove backend and add resolve nteract: matplotlib.use('nbagg')

    Remove backend and add resolve nteract: matplotlib.use('nbagg')

    Backend is no longer necessary IMO. Using a backend results in the following error on Jupyter.

    Javascript Error: IPython is not defined
    

    Also adding %matplotlib inline before importing matplotlib resolves the displaying of graphs.

    Should I fix them in the notebooks and send a PR?

    Thanks.

    opened by hasibzunair 8
  • make examples progressive

    make examples progressive

    In part 2, the example is too much to do at once. Rather, it would make sense to build up that example as more is taught. Perhaps a new feature for IPython notebooks would be useful (floating cells?)

    opened by WeatherGod 2
Releases(v2.0)
  • v2.0(Jul 25, 2014)

Owner
Matplotlib Developers
Matplotlib Developers
Codebase of deep learning models for inferring stability of mRNA molecules

Kaggle OpenVaccine Models Codebase of deep learning models for inferring stability of mRNA molecules, corresponding to the Kaggle Open Vaccine Challen

Eternagame 40 Dec 29, 2022
Imitating Deep Learning Dynamics via Locally Elastic Stochastic Differential Equations

Imitating Deep Learning Dynamics via Locally Elastic Stochastic Differential Equations This repo contains official code for the NeurIPS 2021 paper Imi

Jiayao Zhang 2 Oct 18, 2021
KakaoBrain KoGPT (Korean Generative Pre-trained Transformer)

KoGPT KoGPT (Korean Generative Pre-trained Transformer) https://github.com/kakaobrain/kogpt https://huggingface.co/kakaobrain/kogpt Model Descriptions

Kakao Brain 799 Dec 28, 2022
A set of examples around hub for creating and processing datasets

Examples for Hub - Dataset Format for AI A repository showcasing examples of using Hub Uploading Dataset Places365 Colab Tutorials Notebook Link Getti

Activeloop 11 Dec 14, 2022
disentanglement_lib is an open-source library for research on learning disentangled representations.

disentanglement_lib disentanglement_lib is an open-source library for research on learning disentangled representation. It supports a variety of diffe

Google Research 1.3k Dec 28, 2022
Libtorch yolov3 deepsort

Overview It is for my undergrad thesis in Tsinghua University. There are four modules in the project: Detection: YOLOv3 Tracking: SORT and DeepSORT Pr

Xu Wei 226 Dec 13, 2022
Release of SPLASH: Dataset for semantic parse correction with natural language feedback in the context of text-to-SQL parsing

SPLASH: Semantic Parsing with Language Assistance from Humans SPLASH is dataset for the task of semantic parse correction with natural language feedba

Microsoft Research - Language and Information Technologies (MSR LIT) 35 Oct 31, 2022
This is the research repository for Vid2Doppler: Synthesizing Doppler Radar Data from Videos for Training Privacy-Preserving Activity Recognition.

Vid2Doppler: Synthesizing Doppler Radar Data from Videos for Training Privacy-Preserving Activity Recognition This is the research repository for Vid2

Future Interfaces Group (CMU) 26 Dec 24, 2022
Code for paper "Vocabulary Learning via Optimal Transport for Neural Machine Translation"

**Codebase and data are uploaded in progress. ** VOLT(-py) is a vocabulary learning codebase that allows researchers and developers to automaticaly ge

416 Jan 09, 2023
E-RAFT: Dense Optical Flow from Event Cameras

E-RAFT: Dense Optical Flow from Event Cameras This is the code for the paper E-RAFT: Dense Optical Flow from Event Cameras by Mathias Gehrig, Mario Mi

Robotics and Perception Group 71 Dec 12, 2022
Gauge equivariant mesh cnn

Geometric Mesh CNN The code in this repository is an implementation of the Gauge Equivariant Mesh CNN introduced in the paper Gauge Equivariant Mesh C

50 Dec 18, 2022
2nd solution of ICDAR 2021 Competition on Scientific Literature Parsing, Task B.

TableMASTER-mmocr Contents About The Project Method Description Dependency Getting Started Prerequisites Installation Usage Data preprocess Train Infe

Jianquan Ye 298 Dec 21, 2022
Training Confidence-Calibrated Classifier for Detecting Out-of-Distribution Samples / ICLR 2018

Training Confidence-Calibrated Classifier for Detecting Out-of-Distribution Samples This project is for the paper "Training Confidence-Calibrated Clas

168 Nov 29, 2022
[NeurIPS 2021] The PyTorch implementation of paper "Self-Supervised Learning Disentangled Group Representation as Feature"

IP-IRM [NeurIPS 2021] The PyTorch implementation of paper "Self-Supervised Learning Disentangled Group Representation as Feature". Codes will be relea

Wang Tan 67 Dec 24, 2022
Normalizing Flows with a resampled base distribution

Resampling Base Distributions of Normalizing Flows Normalizing flows are a popular class of models for approximating probability distributions. Howeve

Vincent Stimper 24 Nov 03, 2022
This is the code for the paper "Motion-Focused Contrastive Learning of Video Representations" (ICCV'21).

Motion-Focused Contrastive Learning of Video Representations Introduction This is the code for the paper "Motion-Focused Contrastive Learning of Video

11 Sep 23, 2022
Official implementation of DreamerPro: Reconstruction-Free Model-Based Reinforcement Learning with Prototypical Representations in TensorFlow 2

DreamerPro Official implementation of DreamerPro: Reconstruction-Free Model-Based Reinforcement Learning with Prototypical Representations in TensorFl

22 Nov 01, 2022
A Python library for Deep Graph Networks

PyDGN Wiki Description This is a Python library to easily experiment with Deep Graph Networks (DGNs). It provides automatic management of data splitti

Federico Errica 194 Dec 22, 2022
StarGAN2 for practice

StarGAN2 for practice This version of StarGAN2 (coined as 'Post-modern Style Transfer') is intended mostly for fellow artists, who rarely look at scie

vadim epstein 87 Sep 24, 2022
When in Doubt: Improving Classification Performance with Alternating Normalization

When in Doubt: Improving Classification Performance with Alternating Normalization Findings of EMNLP 2021 Menglin Jia, Austin Reiter, Ser-Nam Lim, Yoa

Menglin Jia 13 Nov 06, 2022