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
Repository for Driving Style Recognition algorithms for Autonomous Vehicles

Driving Style Recognition Using Interval Type-2 Fuzzy Inference System and Multiple Experts Decision Making Created by Iago Pachêco Gomes at USP - ICM

Iago Gomes 9 Nov 28, 2022
Machine Learning Time-Series Platform

cesium: Open-Source Platform for Time Series Inference Summary cesium is an open source library that allows users to: extract features from raw time s

632 Dec 26, 2022
Implementation of Hourglass Transformer, in Pytorch, from Google and OpenAI

Hourglass Transformer - Pytorch (wip) Implementation of Hourglass Transformer, in Pytorch. It will also contain some of my own ideas about how to make

Phil Wang 61 Dec 25, 2022
Fast, Attemptable Route Planner for Navigation in Known and Unknown Environments

FAR Planner uses a dynamically updated visibility graph for fast replanning. The planner models the environment with polygons and builds a global visi

Fan Yang 346 Dec 30, 2022
Face Mask Detection system based on computer vision and deep learning using OpenCV and Tensorflow/Keras

Face Mask Detection Face Mask Detection System built with OpenCV, Keras/TensorFlow using Deep Learning and Computer Vision concepts in order to detect

Chandrika Deb 1.4k Jan 03, 2023
A computational optimization project towards the goal of gerrymandering the results of a hypothetical election in the UK.

A computational optimization project towards the goal of gerrymandering the results of a hypothetical election in the UK.

Emma 1 Jan 18, 2022
NaturalCC is a sequence modeling toolkit that allows researchers and developers to train custom models

NaturalCC NaturalCC is a sequence modeling toolkit that allows researchers and developers to train custom models for many software engineering tasks,

159 Dec 28, 2022
MAGMA - a GPT-style multimodal model that can understand any combination of images and language

MAGMA -- Multimodal Augmentation of Generative Models through Adapter-based Finetuning Authors repo (alphabetical) Constantin (CoEich), Mayukh (Mayukh

Aleph Alpha GmbH 331 Jan 03, 2023
Code for "ATISS: Autoregressive Transformers for Indoor Scene Synthesis", NeurIPS 2021

ATISS: Autoregressive Transformers for Indoor Scene Synthesis This repository contains the code that accompanies our paper ATISS: Autoregressive Trans

138 Dec 22, 2022
Python scripts performing class agnostic object localization using the Object Localization Network model in ONNX.

ONNX Object Localization Network Python scripts performing class agnostic object localization using the Object Localization Network model in ONNX. Ori

Ibai Gorordo 15 Oct 14, 2022
This reposityory contains the PyTorch implementation of our paper "Generative Dynamic Patch Attack".

Generative Dynamic Patch Attack This reposityory contains the PyTorch implementation of our paper "Generative Dynamic Patch Attack". Requirements PyTo

Xiang Li 8 Nov 17, 2022
This repository contains code to run experiments in the paper "Signal Strength and Noise Drive Feature Preference in CNN Image Classifiers."

Signal Strength and Noise Drive Feature Preference in CNN Image Classifiers This repository contains code to run experiments in the paper "Signal Stre

0 Jan 19, 2022
Language-Agnostic Website Embedding and Classification

Homepage2Vec Language-Agnostic Website Embedding and Classification based on Curlie labels https://arxiv.org/pdf/2201.03677.pdf Homepage2Vec is a pre-

25 Dec 27, 2022
For IBM Quantum Challenge Africa 2021, 9 September (07:00 UTC) - 20 September (23:00 UTC).

IBM Quantum Challenge Africa 2021 To ensure Africa is able to apply quantum computing to solve problems relevant to the continent, the IBM Research La

Qiskit Community 48 Dec 25, 2022
Help you understand Manual and w/ Clutch point while driving.

简体中文 forza_auto_gear forza_auto_gear is a tool for Forza Horizon 5. It will help us understand the best gear shift point using Manual or w/ Clutch in

15 Oct 08, 2022
Official implementation of "Open-set Label Noise Can Improve Robustness Against Inherent Label Noise" (NeurIPS 2021)

Open-set Label Noise Can Improve Robustness Against Inherent Label Noise NeurIPS 2021: This repository is the official implementation of ODNL. Require

Hongxin Wei 12 Dec 07, 2022
The official implementation of CSG-Stump: A Learning Friendly CSG-Like Representation for Interpretable Shape Parsing

CSGStumpNet The official implementation of CSG-Stump: A Learning Friendly CSG-Like Representation for Interpretable Shape Parsing Paper | Project page

Daxuan 39 Dec 26, 2022
Collective Multi-type Entity Alignment Between Knowledge Graphs (WWW'20)

CG-MuAlign A reference implementation for "Collective Multi-type Entity Alignment Between Knowledge Graphs", published in WWW 2020. If you find our pa

Bran Zhu 28 Dec 11, 2022
Learning to Communicate with Deep Multi-Agent Reinforcement Learning in PyTorch

Learning to Communicate with Deep Multi-Agent Reinforcement Learning This is a PyTorch implementation of the original Lua code release. Overview This

Minqi 297 Dec 12, 2022
The implementation of our CIKM 2021 paper titled as: "Cross-Market Product Recommendation"

FOREC: A Cross-Market Recommendation System This repository provides the implementation of our CIKM 2021 paper titled as "Cross-Market Product Recomme

Hamed Bonab 16 Sep 12, 2022