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
Negative Interactions for Improved Collaborative Filtering:

Negative Interactions for Improved Collaborative Filtering: Don’t go Deeper, go Higher This notebook provides an implementation in Python 3 of the alg

Harald Steck 21 Mar 05, 2022
Code release of paper Improving neural implicit surfaces geometry with patch warping

NeuralWarp: Improving neural implicit surfaces geometry with patch warping Project page | Paper Code release of paper Improving neural implicit surfac

François Darmon 167 Dec 30, 2022
Official repository of "Investigating Tradeoffs in Real-World Video Super-Resolution"

RealBasicVSR [Paper] This is the official repository of "Investigating Tradeoffs in Real-World Video Super-Resolution, arXiv". This repository contain

Kelvin C.K. Chan 566 Dec 28, 2022
Leveraging Two Types of Global Graph for Sequential Fashion Recommendation, ICMR 2021

This is the repo for the paper: Leveraging Two Types of Global Graph for Sequential Fashion Recommendation Requirements OS: Ubuntu 16.04 or higher ver

Yujuan Ding 10 Oct 10, 2022
Efficient face emotion recognition in photos and videos

This repository contains code of face emotion recognition that was developed in the RSF (Russian Science Foundation) project no. 20-71-10010 (Efficien

Andrey Savchenko 239 Jan 04, 2023
Code release for "Masked-attention Mask Transformer for Universal Image Segmentation"

Mask2Former: Masked-attention Mask Transformer for Universal Image Segmentation Bowen Cheng, Ishan Misra, Alexander G. Schwing, Alexander Kirillov, Ro

Meta Research 1.2k Jan 02, 2023
Implementation of CoCa, Contrastive Captioners are Image-Text Foundation Models, in Pytorch

CoCa - Pytorch Implementation of CoCa, Contrastive Captioners are Image-Text Foundation Models, in Pytorch. They were able to elegantly fit in contras

Phil Wang 565 Dec 30, 2022
A PyTorch re-implementation of Neural Radiance Fields

nerf-pytorch A PyTorch re-implementation Project | Video | Paper NeRF: Representing Scenes as Neural Radiance Fields for View Synthesis Ben Mildenhall

Krishna Murthy 709 Jan 09, 2023
[CVPR 2021] Forecasting the panoptic segmentation of future video frames

Panoptic Segmentation Forecasting Colin Graber, Grace Tsai, Michael Firman, Gabriel Brostow, Alexander Schwing - CVPR 2021 [Link to paper] We propose

Niantic Labs 44 Nov 29, 2022
Cross-Modal Contrastive Learning for Text-to-Image Generation

Cross-Modal Contrastive Learning for Text-to-Image Generation This repository hosts the open source JAX implementation of XMC-GAN. Setup instructions

Google Research 94 Nov 12, 2022
This is an official source code for implementation on Extensive Deep Temporal Point Process

Extensive Deep Temporal Point Process This is an official source code for implementation on Extensive Deep Temporal Point Process, which is composed o

Haitao Lin 8 Aug 15, 2022
Face recognition. Redefined.

FaceFinder Use a powerful CNN to identify faces in images! TABLE OF CONTENTS About The Project Built With Getting Started Prerequisites Installation U

BleepLogger 20 Jun 16, 2021
Saeed Lotfi 28 Dec 12, 2022
This repository introduces a short project about Transfer Learning for Classification of MRI Images.

Transfer Learning for MRI Images Classification This repository introduces a short project made during my stay at Neuromatch Summer School 2021. This

Oscar Guarnizo 3 Nov 15, 2022
*ObjDetApp* deploys a pytorch model for object detection

*ObjDetApp* deploys a pytorch model for object detection

Will Chao 1 Dec 26, 2021
DIRL: Domain-Invariant Representation Learning

DIRL: Domain-Invariant Representation Learning Domain-Invariant Representation Learning (DIRL) is a novel algorithm that semantically aligns both the

Ajay Tanwani 30 Nov 07, 2022
Implementation of Segformer, Attention + MLP neural network for segmentation, in Pytorch

Segformer - Pytorch Implementation of Segformer, Attention + MLP neural network for segmentation, in Pytorch. Install $ pip install segformer-pytorch

Phil Wang 208 Dec 25, 2022
Unofficial implementation of Pix2SEQ

Unofficial-Pix2seq: A Language Modeling Framework for Object Detection Unofficial implementation of Pix2SEQ. Please use this code with causion. Many i

159 Dec 12, 2022
Wenzhou-Kean University AI-LAB

AI-LAB This is Wenzhou-Kean University AI-LAB. Our research interests are in Computer Vision and Natural Language Processing. Computer Vision Please g

WKU AI-LAB 10 May 05, 2022
Deep Learning: Architectures & Methods Project: Deep Learning for Audio Super-Resolution

Deep Learning: Architectures & Methods Project: Deep Learning for Audio Super-Resolution Figure: Example visualization of the method and baseline as a

Oliver Hahn 16 Dec 23, 2022