8000 MEP12 API examples by NelleV · Pull Request #7439 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

MEP12 API examples #7439

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 11, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions examples/api/agg_oo.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# -*- noplot -*-
"""
=============================
The object-oriented interface
=============================

A pure OO (look Ma, no pylab!) example using the agg backend
"""
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
Expand Down
4 changes: 4 additions & 0 deletions examples/api/barchart_demo.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
"""
========
Barchart
========

A bar plot with errorbars and height labels on individual bars
"""
import numpy as np
Expand Down
10 changes: 10 additions & 0 deletions examples/api/bbox_intersect.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
"""
===========================================
Changing colors of lines intersecting a box
===========================================

The lines intersecting the rectangle are colored in red, while the others
are left as blue lines. This example showcases the `intersect_bbox` function.

"""

import numpy as np
import matplotlib.pyplot as plt
from matplotlib.transforms import Bbox
Expand Down
6 changes: 4 additions & 2 deletions examples/api/collections_demo.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'''Demonstration of LineCollection, PolyCollection, and
RegularPolyCollection with autoscaling.
'''
=========================================================
Line, Poly and RegularPoly Collection with autoscaling
=========================================================

For the first two subplots, we will use spirals. Their
size will be set in plot units, not data units. Their positions
Expand Down
9 changes: 9 additions & 0 deletions examples/api/colorbar_basics.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
"""
========
Colorbar
========

This example shows how to use colorbar by specifying the mappable object (here
the imshow returned object) and the axes to attach the colorbar to.
"""

import numpy as np
import matplotlib.pyplot as plt

Expand Down
6 changes: 5 additions & 1 deletion examples/api/colorbar_only.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
'''
Make a colorbar as a separate figure.
====================
Customized colorbars
====================

This example shows how to build colorbars without an attached mappable.
'''

import matplotlib.pyplot as plt
Expand Down
8 changes: 6 additions & 2 deletions examples/api/compound_path.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
"""
Make a compund path -- in this case two simple polygons, a rectangle
and a triangle. Use CLOSEOPOLY and MOVETO for the different parts of
=============
Compound path
=============

Make a compound path -- in this case two simple polygons, a rectangle
and a triangle. Use CLOSEPOLY and MOVETO for the different parts of
the compound path
"""
import numpy as np
Expand Down
10 changes: 10 additions & 0 deletions examples/api/custom_projection_example.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
"""
=================
Custom projection
=================

This example showcases the Hammer projection by alleviating many features of
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think alleviating is the right verb here; not sure what it's trying to say (utilizing/using would fit without changing the sentence, but doesn't quite imply the same things.)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed this one.

matplotlib.
"""


from __future__ import unicode_literals

import matplotlib
Expand Down
10 changes: 10 additions & 0 deletions examples/api/custom_scale_example.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
"""
============
Custom scale
============

This example showcases how to create a custom scale, by implementing the
scaling use for latitude data in a Mercator Projection.
"""


from __future__ import unicode_literals

import numpy as np
Expand Down
4 changes: 4 additions & 0 deletions examples/api/date_demo.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
"""
================
Date tick labels
================

Show how to make date plots in matplotlib using date tick locators and
formatters. See major_minor_demo1.py for more information on
controlling major and minor ticks
Expand Down
13 changes: 10 additions & 3 deletions examples/api/date_index_formatter.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
"""
=====================================
Custom tick formatter for time series
=====================================

When plotting time series, e.g., financial time series, one often wants
to leave out days on which there is no data, eh weekends. The example
to leave out days on which there is no data, i.e. weekends. The example
below shows how to use an 'index formatter' to achieve the desired plot
"""
from __future__ import print_function
Expand All @@ -19,8 +23,10 @@


# first we'll do it the default way, with gaps on weekends
fig, ax = plt.subplots()
fig, axes = plt.subplots(ncols=2, figsize=(8, 4))
ax = axes[0]
ax.plot(r.date, r.adj_close, 'o-')
ax.set_title("Default")
fig.autofmt_xdate()

# next we'll write a custom formatter
Expand All @@ -32,9 +38,10 @@ def format_date(x, pos=None):
thisind = np.clip(int(x + 0.5), 0, N - 1)
return r.date[thisind].strftime('%Y-%m-%d')

fig, ax = plt.subplots()
ax = axes[1]
ax.plot(ind, r.adj_close, 'o-')
ax.xaxis.set_major_formatter(ticker.FuncFormatter(format_date))
ax.set_title("Custom tick formatter")
fig.autofmt_xdate()

plt.show()
4 changes: 4 additions & 0 deletions examples/api/demo_affine_image.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
"""
============================
Affine transform of an image
============================

For the backends that support draw_image with optional affine
transform (e.g., agg, ps backend), the image of the output should
have its boundary match the dashed yellow rectangle.
Expand Down
8 changes: 8 additions & 0 deletions examples/api/donut_demo.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
"""
=============
Mmh Donuts!!!
=============

This example draws donuts (miam!) using Path and Patches.
"""

import numpy as np
import matplotlib.path as mpath
import matplotlib.patches as mpatches
Expand Down
4 changes: 4 additions & 0 deletions examples/api/engineering_formatter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
'''
=========================================
Labeling ticks using engineering notation
=========================================

Demo to show use of the engineering Formatter.
'''

Expand Down
9 changes: 9 additions & 0 deletions examples/api/filled_step.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
"""
=========================
Hatch-filled histograms
=========================

This example showcases the hatching capabilities of matplotlib by plotting
various histograms.
"""

import itertools
from collections import OrderedDict
from functools import partial
Expand Down
4 changes: 4 additions & 0 deletions examples/api/font_family_rc.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
"""
===========================
Configuring the font family
===========================

You can explicitly set which font family is picked up for a given font
style (e.g., 'serif', 'sans-serif', or 'monospace').

Expand Down
4 changes: 4 additions & 0 deletions examples/api/font_file.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# -*- noplot -*-
"""
===================================
Using a ttf font file in matplotlib
===================================

Although it is usually not a good idea to explicitly point to a single
ttf file for a font instance, you can do so using the
font_manager.FontProperties fname argument (for a more flexible
Expand Down
6 changes: 5 additions & 1 deletion examples/api/histogram_path_demo.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
"""
========================================================
Building histograms using Rectangles and PolyCollections
========================================================

This example shows how to use a path patch to draw a bunch of
rectangles. The technique of using lots of Rectangle instances, or
the faster method of using PolyCollections, were implemented before we
Expand Down Expand Up @@ -41,7 +45,7 @@
barpath = path.Path.make_compound_path_from_polys(XY)

# make a patch out of it
patch = patches.PathPatch(barpath, facecolor='blue')
patch = patches.PathPatch(barpath)
ax.add_patch(patch)

# update the view limits
Expand Down
5 changes: 4 additions & 1 deletion examples/api/image_zcoord.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
"""
==================================
Modifying the coordinate formatter
==================================

Show how to modify the coordinate formatter to report the image "z"
value of the nearest pixel given x and y
"""
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.cm as cm

# Fixing random state for reproducibility
np.random.seed(19680801)
Expand Down
4 changes: 4 additions & 0 deletions examples/api/joinstyle.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
"""
===========
Join styles
===========

Illustrate the three different join styles
"""

Expand Down
9 changes: 9 additions & 0 deletions examples/api/legend_demo.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
"""
===============================
Legend using pre-defined labels
===============================

Notice how the legend labels are defined with the plots!
"""


import numpy as np
import matplotlib.pyplot as plt

Expand Down
4 changes: 4 additions & 0 deletions examples/api/line_with_text.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
"""
=======================
Artist within an artist
=======================

Show how to override basic methods so an artist can contain another
artist. In this case, the line contains a Text instance to label it.
"""
Expand Down
8 changes: 5 additions & 3 deletions examples/api/logo2.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
"""
==========
matplotlib
==========

Thanks to Tony Yu <tsyu80@gmail.com> for the logo design
"""

Expand All @@ -13,7 +17,6 @@


axalpha = 0.05
#figcolor = '#EFEFEF'
figcolor = 'white'
dpi = 80
fig = plt.figure(figsize=(6, 1.1), dpi=dpi)
Expand All @@ -37,8 +40,6 @@ def add_math_background():
(0.35, 0.9), 20))
text.append((r"$\int_{-\infty}^\infty e^{-x^2}dx=\sqrt{\pi}$",
(0.15, 0.3), 25))
#text.append((r"$E = mc^2 = \sqrt{{m_0}^2c^4 + p^2c^2}$",
# (0.7, 0.42), 30))
text.append((r"$F_G = G\frac{m_1m_2}{r^2}$",
(0.85, 0.7), 30))
for eq, (x, y), size in text:
Expand Down Expand Up @@ -80,6 +81,7 @@ def add_polar_bar():
ax.set_yticks(np.arange(1, 9, 2))
ax.set_rmax(9)


if __name__ == '__main__':
main_axes = add_math_background()
add_polar_bar()
Expand Down
6 changes: 5 additions & 1 deletion examples/api/mathtext_asarray.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
"""
Load a mathtext image as numpy array
===============================
A mathtext image as numpy array
===============================

This example shows how to make images from LaTeX strings.
"""

import matplotlib.mathtext as mathtext
Expand Down
6 changes: 6 additions & 0 deletions examples/api/patch_collection.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
"""
============================
Circles, Wedges and Polygons
============================
"""

import numpy as np
import matplotlib
from matplotlib.patches import Circle, Wedge, Polygon
Expand Down
9 changes: 9 additions & 0 deletions examples/api/power_norm_demo.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
"""
========================
Exploring normalizations
========================

Let's explore various normalization on a multivariate normal distribution.

"""

from matplotlib import pyplot as plt
import matplotlib.colors as mcolors
import numpy as np
Expand Down
9 changes: 9 additions & 0 deletions examples/api/quad_bezier.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
"""
============
Bezier Curve
============

This example showcases the PathPatch object to create a Bezier polycurve path
patch.
"""

import matplotlib.path as mpath
import matplotlib.patches as mpatches
import matplotlib.pyplot as plt
Expand Down
9 changes: 7 additions & 2 deletions examples/api/radar_chart.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
"""
Example of creating a radar chart (a.k.a. a spider or star chart) [1]_.
======================================
Radar chart (aka spider or star chart)
======================================

This example creates a radar chart, also known as a spider or star chart [1]_.

Although this example allows a frame of either 'circle' or 'polygon', polygon
frames don't have proper gridlines (the lines are circles instead of polygons).
Expand Down Expand Up @@ -187,7 +191,8 @@ def example_data():
# add legend relative to top-left plot
ax = axes[0, 0]
labels = ('Factor 1', 'Factor 2', 'Factor 3', 'Factor 4', 'Factor 5')
legend = ax.legend(labels, loc=(0.9, .95), labelspacing=0.1, fontsize='small')
legend = ax.legend(labels, loc=(0.9, .95),
labelspacing=0.1, fontsize='small')

fig.text(0.5, 0.965, '5-Factor Solution Profiles Across Four Scenarios',
horizontalalignment='center', color='black', weight='bold',
Expand Down
7 changes: 6 additions & 1 deletion examples/api/sankey_demo_basics.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
"""Demonstrate the Sankey class by producing three basic diagrams.
"""
================
The Sankey class
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

50/50 on changing class to diagram here too.

================

Demonstrate the Sankey class by producing three basic diagrams.
"""
import numpy as np
import matplotlib.pyplot as plt
Expand Down
Loading
0