8000 Minor example updates by QuLogic · Pull Request #7559 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Minor example updates #7559

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 11 commits into from
Dec 17, 2016
Prev Previous commit
Next Next commit
Fix several minor typos in examples.
  • Loading branch information
QuLogic committed Dec 11, 2016
commit 7de832cab101c3e615061ce92ba974f95f7eb6ce
2 changes: 1 addition & 1 deletion doc/mpl_toolkits/axes_grid/figures/simple_axisartist1.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
ax.axis["bottom", "top", "right"].set_visible(False)

# make an new axis along the first axis axis (x-axis) which pass
# throught y=0.
# through y=0.
ax.axis["y=0"] = ax.new_floating_axis(nth_coord=0, value=0,
axis_direction="bottom")
ax.axis["y=0"].toggle(all=True)
Expand Down
2 changes: 1 addition & 1 deletion doc/mpl_toolkits/axes_grid/figures/simple_axisline2.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

fig = plt.figure(1, (4,3))

# a subplot with two additiona axis, "xzero" and "yzero". "xzero" is
# a subplot with two additional axis, "xzero" and "yzero". "xzero" is
# y=0 line, and "yzero" is x=0 line.
ax = SubplotZero(fig, 1, 1, 1)
fig.add_subplot(ax)
Expand Down
2 changes: 1 addition & 1 deletion doc/users/plotting/examples/custom_boxstyle02.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import matplotlib.pyplot as plt

# we may derive from matplotlib.patches.BoxStyle._Base class.
# You need to overide transmute method in this case.
# You need to override transmute method in this case.

class MyStyle(BoxStyle._Base):
"""
Expand Down
2 changes: 1 addition & 1 deletion examples/api/date_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
datafile = cbook.get_sample_data('goog.npy')
try:
# Python3 cannot load python2 .npy files with datetime(object) arrays
# unless the encoding is set to bytes. Hovever this option was
# unless the encoding is set to bytes. However this option was
# not added until numpy 1.10 so this example will only work with
# python 2 or with numpy 1.10 and later.
r = np.load(datafile, encoding='bytes').view(np.recarray)
Expand Down
2 changes: 1 addition & 1 deletion examples/api/font_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
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
solution, see the font_fmaily_rc.py and fonts_demo.py examples).
solution, see the font_family_rc.py and fonts_demo.py examples).
"""
import sys
import os
Expand Down
2 changes: 1 addition & 1 deletion examples/api/histogram_path_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
the faster method of using PolyCollections, were implemented before we
had proper paths with moveto/lineto, closepoly etc in mpl. Now that
we have them, we can draw collections of regularly shaped objects with
homogeous properties more efficiently with a PathCollection. This
homogeneous properties more efficiently with a PathCollection. This
example makes a histogram -- its more work to set up the vertex arrays
at the outset, but it should be much faster for large numbers of
objects
Expand Down
2 changes: 1 addition & 1 deletion examples/api/radar_chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def example_data():
# Pyrolized Organic Carbon (OP)
# 2)Inclusion of gas-phase specie carbon monoxide (CO)
# 3)Inclusion of gas-phase specie ozone (O3).
# 4)Inclusion of both gas-phase speciesis present...
# 4)Inclusion of both gas-phase species is present...
data = [
['Sulfate', 'Nitrate', 'EC', 'OC1', 'OC2', 'OC3', 'OP', 'CO', 'O3'],
('Basecase', [
Expand Down
8 changes: 4 additions & 4 deletions examples/api/unicode_minus.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
Unicode minus
=============
You can use the proper typesetting unicode minus (see
http://en.wikipedia.org/wiki/Plus_sign#Plus_sign) or the ASCII hypen
You can use the proper typesetting Unicode minus (see
https://en.wikipedia.org/wiki/Plus_sign#Plus_sign) or the ASCII hyphen
for minus, which some people prefer. The matplotlibrc param
axes.unicode_minus controls the default behavior.
The default is to use the unicode minus
The default is to use the Unicode minus.
"""
import numpy as np
import matplotlib
Expand All @@ -17,5 +17,5 @@
matplotlib.rcParams['axes.unicode_minus'] = False
fig, ax = plt.subplots()
ax.plot(10*np.random.randn(100), 10*np.random.randn(100), 'o')
ax.set_title('Using hypen instead of unicode minus')
ax.set_title('Using hyphen instead of Unicode minus')
plt.show()
2 changes: 1 addition & 1 deletion examples/axes_grid/demo_curvelinear_grid.py
Original file line number Diff line number Diff line change
10000 Expand Up @@ -113,7 +113,7 @@ def curvelinear_test2(fig):
# A parasite axes with given transform
ax2 = ParasiteAxesAuxTrans(ax1, tr, "equal")
# note that ax2.transData == tr + ax1.transData
# Anthing you draw in ax2 will match the ticks and grids of ax1.
# Anything you draw in ax2 will match the ticks and grids of ax1.
ax1.parasites.append(ax2)
intp = cbook.simple_linear_interpolation
ax2.plot(intp(np.array([0, 30]), 50),
Expand Down
2 changes: 1 addition & 1 deletion examples/axes_grid/demo_parasite_axes2.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
to plot multiple different values onto one single plot. Notice how in this
example, par1 and par2 are both calling twinx meaning both are tied directly to
the x-axis. From there, each of those two axis can behave separately from the
each other, meaning they can take on seperate values from themselves as well as
each other, meaning they can take on separate values from themselves as well as
the x-axis.
"""
from mpl_toolkits.axes_grid1 import host_subplot
Expand Down
2 changes: 1 addition & 1 deletion examples/event_handling/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ matplotlib supports event handling with a GUI neutral event model. So
you can connect to matplotlib events w/o knowledge of what user
interface matplotlib will ultimately be plugged in to. This has two
advantages: the code you write will be more portable, and matplotlib
events are aware of things like data coordinate space and whih axes
events are aware of things like data coordinate space and which axes
the event occurs in so you don't have to mess with low level
transformation details to go from canvas space to data space. Object
picking examples are also included.
2 changes: 1 addition & 1 deletion examples/event_handling/legend_picking.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Enable picking on the legend to toggle the legended line on and off
Enable picking on the legend to toggle the original line on and off
"""
import numpy as np
import matplotlib.pyplot as plt
Expand Down
4 changes: 2 additions & 2 deletions examples/event_handling/viewlims.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def __call__(self, ax):
# A class that will regenerate a fractal set as we zoom in, so that you
# can actually see the increasing detail. A box in the left panel will show
# the area to which we are zoomed.
class MandlebrotDisplay(object):
class MandelbrotDisplay(object):
def __init__(self, h=500, w=500, niter=50, radius=2., power=2):
self.height = h
self.width = w
Expand Down Expand Up @@ -57,7 +57,7 @@ def ax_update(self, ax):
im.set_extent((xstart, xend, ystart, yend))
ax.figure.canvas.draw_idle()

md = MandlebrotDisplay()
md = MandelbrotDisplay()
Z = md(-2., 0.5, -1.25, 1.25)

fig1, (ax1, ax2) = plt.subplots(1, 2)
Expand Down
4 changes: 2 additions & 2 deletions examples/misc/ftface_props.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"""
This is a demo script to show you how to use all the properties of an
FT2Font object. These describe global font properties. For
individual character metrices, use the Glyp object, as returned by
individual character metrics, use the Glyph object, as returned by
load_char
"""
import matplotlib
Expand All @@ -18,7 +18,7 @@
print('Num faces :', font.num_faces) # number of faces in file
print('Num glyphs :', font.num_glyphs) # number of glyphs in the face
print('Family name :', font.family_name) # face family name
print('Syle name :', font.style_name) # face syle name
print('Style name :', font.style_name) # face style name
print('PS name :', font.postscript_name) # the postscript name
print('Num fixed :', font.num_fixed_sizes) # number of embedded bitmap in face

Expand Down
2 changes: 1 addition & 1 deletion examples/misc/sample_data_demo.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
Grab mpl data from the ~/.matplotlib/sample_data cache if it exists, else
fetch it from github and cache it
fetch it from GitHub and cache it
"""
from __future__ import print_function
import matplotlib.cbook as cbook
Expand Down
4 changes: 2 additions & 2 deletions examples/misc/svg_filter_line.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
Demonstrate SVG filtering effects which might be used with mpl.
Note that the filtering effects are only effective if your svg rederer
Note that the filtering effects are only effective if your svg renderer
support it.
"""

Expand Down Expand Up @@ -78,7 +78,7 @@
for l in [l1, l2]:
# pick up the svg element with given id
shadow = xmlid[l.get_label() + "_shadow"]
# apply shdow filter
# apply shadow filter
shadow.set("filter", 'url(#dropshadow)')

fn = "svg_filter_line.svg"
Expand Down
10 changes: 5 additions & 5 deletions examples/misc/svg_filter_pie.py
10000
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Demonstrate SVG filtering effects which might be used with mpl.
The pie chart drawing code is borrowed from pie_demo.py
Note that the filtering effects are only effective if your svg rederer
Note that the filtering effects are only effective if your svg renderer
support it.
"""

Expand Down Expand Up @@ -50,12 +50,12 @@


# filter definition for shadow using a gaussian blur
# and lighteneing effect.
# The lightnening filter is copied from http://www.w3.org/TR/SVG/filters.html
# and lightening effect.
# The lightening filter is copied from http://www.w3.org/TR/SVG/filters.html

# I tested it with Inkscape and Firefox3. "Gaussian blur" is supported
# in both, but the lightnening effect only in the inkscape. Also note
# that, inkscape's exporting also may not support it.
# in both, but the lightening effect only in the Inkscape. Also note
# that, Inkscape's exporting also may not support it.

filter_def = """
<defs xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'>
Expand Down
2 changes: 1 addition & 1 deletion examples/pylab_examples/accented_text.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""
r"""
matplotlib supports accented characters via TeX mathtext
The following accents are provided: \hat, \breve, \grave, \bar,
Expand Down
2 changes: 1 addition & 1 deletion examples/pylab_examples/centered_ticklabels.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
fh = cbook.get_sample_data('aapl.npy.gz')
try:
# Python3 cannot load python2 .npy files with datetime(object) arrays
# unless the encoding is set to bytes. Hovever this option was
# unless the encoding is set to bytes. However this option was
# not added until numpy 1.10 so this example will only work with
# python 2 or with numpy 1.10 and later.
r = np.load(fh, encoding='bytes')
Expand Down
2 changes: 1 addition & 1 deletion examples/pylab_examples/demo_agg_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ def drop_shadow_line(ax):


def drop_shadow_patches(ax):
# copyed from barchart_demo.py
# Copied from barchart_demo.py
N = 5
menMeans = (20, 35, 30, 35, 27)

Expand Down
2 changes: 1 addition & 1 deletion examples/pylab_examples/errorbar_subsample.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@
ax.set_title('only every 5th errorbar')


fig.suptitle('Errorbar subsampling for better visualibility')
fig.suptitle('Errorbar subsampling for better appearance')
Copy link
Member

Choose a reason for hiding this comment

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

how about just "Errorbar subsampling"?


plt.show()
2 changes: 1 addition & 1 deletion examples/pylab_examples/leftventricle_bulleye.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def bullseye_plot(ax, data, segBold=None, cmap=None, norm=None):
theta_i = i*60*np.pi/180
ax.plot([theta_i, theta_i], [r[1], 1], '-k', lw=linewidth)

# Create the bounds for the segmentss 13-16
# Create the bounds for the segments 13-16
for i in range(4):
theta_i = i*90*np.pi/180 - 45*np.pi/180
ax.plot([theta_i, thet CDA2 a_i], [r[0], r[1]], '-k', lw=linewidth)
Expand Down
4 changes: 2 additions & 2 deletions examples/pylab_examples/pythonic_matplotlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
show commands. These hide a lot of complexity from you that you don't
need to see in normal figure creation, like instantiating DPI
instances, managing the bounding boxes of the figure elements,
creating and reaslizing GUI windows and embedding figures in them.
creating and realizing GUI windows and embedding figures in them.
If you are an application developer and want to embed matplotlib in
Expand All @@ -19,7 +19,7 @@
If you are a web application developer, you may want to use the
example in webapp_demo.py, which shows how to use the backend agg
figure canvase directly, with none of the globals (current figure,
figure canvas directly, with none of the globals (current figure,
current axes) that are present in the pyplot interface. Note that
there is no reason why the pyplot interface won't work for web
application developers, however.
Expand Down
2 changes: 1 addition & 1 deletion examples/pylab_examples/scatter_demo2.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
datafile = cbook.get_sample_data('goog.npy')
try:
# Python3 cannot load python2 .npy files with datetime(object) arrays
# unless the encoding is set to bytes. Hovever this option was
# unless the encoding is set to bytes. However this option was
# not added until numpy 1.10 so this example will only work with
# python 2 or with numpy 1.10 and later
price_data = np.load(datafile, encoding='bytes').view(np.recarray)
Copy link
Contributor

Choose a reason for hiding this comment

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

If you regenerate the npy under a recent py3, can you cover all cases?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not having luck with it:

ipython3 
In [1]: import numpy as np
In [2]: np.__version__
Out[2]: '1.11.2'
In [3]: i = np.load('lib/matplotlib/mpl-data/sample_data/goog.npy', encoding='bytes')
In [4]: np.save('goog.npy', i)

$ python2
>>> import numpy as np
>>> np.__version__
'1.11.2'
>>> i = np.load('goog.npy')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.7/site-packages/numpy/lib/npyio.py", line 406, in load
    pickle_kwargs=pickle_kwargs)
  File "/usr/lib64/python2.7/site-packages/numpy/lib/format.py", line 637, in read_array
    array = pickle.load(fp, **pickle_kwargs)
ValueError: non-string names in Numpy dtype unpickling
>>> i = np.load('goog.npy', encoding='bytes')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.7/site-packages/numpy/lib/npyio.py", line 406, in load
    pickle_kwargs=pickle_kwargs)
  File "/usr/lib64/python2.7/site-packages/numpy/lib/format.py", line 637, in read_array
    array = pickle.load(fp, **pickle_kwargs)
ValueError: non-string names in Numpy dtype unpickling

What would probably be the most portable is np.datetime64, but unfortunately, it appears Matplotlib doesn't handle it as well as datetime.datetime. Probably because we didn't depend on a new enough NumPy to carry the converter in-tree.

Copy link
Member

Choose a reason for hiding this comment

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

np.datetime64 has been a mess from the start. It is marginally usable now that we require numpy 1.7, so we do need to add support as best we can. Maybe someone will want to take that on for 2.1.

Copy link
Member Author

Choose a reason for hiding this comment

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

np.datetime64 can be converted back to datetime.datetime with arr.astype('O'); would that look better than this current try/except stuff?

Copy link
Member

Choose a reason for hiding this comment

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

This example doesn't use dates or times in any form! It is just plotting random-looking numbers that happen to come from some stock statistics. As a plotting example, it doesn't need to read data in from a file at all.

Copy link
Member Author
@QuLogic QuLogic Dec 5, 2016

Choose a reason for hiding this comment

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

Yes, but there are a couple others (just search for this same typo message in this PR) that do use the file and do use the dates, so I was mainly referring to them.

Expand Down
2 changes: 1 addition & 1 deletion examples/pylab_examples/scatter_masked.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
r0 = 0.6
x = 0.9*np.random.rand(N)
y = 0.9*np.random.rand(N)
area = np.pi*(10 * np.random.rand(N))**2 # 0 to 10 point radiuses
area = np.pi*(10 * np.random.rand(N))**2 # 0 to 10 point radii
c = np.sqrt(area)
r = np.sqrt(x*x + y*y)
area1 = np.ma.masked_where(r < r0, area)
Expand Down
2 changes: 1 addition & 1 deletion examples/pylab_examples/system_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def get_stats(t):
try:
# make sure that the GUI framework has a chance to run its event loop
# and clear any GUI events. This needs to be in a try/except block
# because the default implemenation of this method is to raise
# because the default implementation of this method is to raise
# NotImplementedError
fig.canvas.flush_events()
except NotImplementedError:
Expand Down
4 changes: 2 additions & 2 deletions examples/pylab_examples/tricontour_smooth_delaunay.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ def experiment_res(x, y):
plt.title("Filtering a Delaunay mesh\n" +
"(application to high-resolution tricontouring)")

# 1) plot of the refined (computed) data countours:
# 1) plot of the refined (computed) data contours:
plt.tricontour(tri_refi, z_test_refi, levels=levels, cmap=cmap,
linewidths=[2.0, 0.5, 1.0, 0.5])
# 2) plot of the expected (analytical) data countours (dashed):
# 2) plot of the expected (analytical) data contours (dashed):
if plot_expected:
plt.tricontour(tri_refi 10000 , z_expected, levels=levels, cmap=cmap,
linestyles='--')
Expand Down
2 changes: 1 addition & 1 deletion examples/pylab_examples/webapp_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def make_fig():
# make a translucent scatter collection
x = np.random.rand(100)
y = np.random.rand(100)
area = np.pi * (10 * np.random.rand(100)) ** 2 # 0 to 10 point radiuses
area = np.pi * (10 * np.random.rand(100)) ** 2 # 0 to 10 point radii
c = ax.scatter(x, y, area)
c.set_alpha(0.5)

Expand Down
2 changes: 1 addition & 1 deletion examples/shapes_and_collections/scatter_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
x = np.random.rand(N)
y = np.random.rand(N)
colors = np.random.rand(N)
area = np.pi * (15 * np.random.rand(N))**2 # 0 to 15 point radiuses
area = np.pi * (15 * np.random.rand(N))**2 # 0 to 15 point radii

plt.scatter(x, y, s=area, c=colors, alpha=0.5)
plt.show()
2 changes: 1 addition & 1 deletion examples/specialty_plots/topographic_hillshading.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
# If you need topographically accurate vertical exaggeration, or you don't want
# to guess at what *vert_exag* should be, you'll need to specify the cellsize
# of the grid (i.e. the *dx* and *dy* parameters). Otherwise, any *vert_exag*
# value you specify will be realitive to the grid spacing of your input data
# value you specify will be relative to the grid spacing of your input data
# (in other words, *dx* and *dy* default to 1.0, and *vert_exag* is calculated
# relative to those parameters). Similarly, *dx* and *dy* are assumed to be in
# the same units as your input z-values. Therefore, we'll need to convert the
Expand Down
2 changes: 1 addition & 1 deletion examples/statistics/histogram_demo_cumulative.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

fig, ax = plt.subplots(figsize=(8, 4))

# plot the cumulative histograme
# plot the cumulative histogram
n, bins, patches = ax.hist(x, n_bins, normed=1, histtype='step',
cumulative=True, label='Empirical')

Expand Down
2 changes: 1 addition & 1 deletion examples/statistics/violinplot_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
sample. Rather than showing counts of data points that fall into bins
or order statistics, violin plots use kernel density estimation (KDE) to
compute an empirical distribution of the sample. That computation
is controlled by several parameters. This example demostrates how to
is controlled by several parameters. This example demonstrates how to
modify the number of points at which the KDE is evaluated (``points``)
and how to modify the band-width of the KDE (``bw_method``).
Expand Down
2 changes: 1 addition & 1 deletion examples/units/units_sample.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
plot using a variety of cm vs inches conversions. The example shows
how default unit instrospection works (ax1), how various keywords can
how default unit introspection works (ax1), how various keywords can
be used to set the x and y units to override the defaults (ax2, ax3,
ax4) and how one can set the xlimits using scalars (ax3, current units
assumed) or units (conversions applied to get the numbers to current
Expand Down
2 changes: 1 addition & 1 deletion examples/user_interfaces/README.wx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ matplotlib in a wxPython application

http://agni.phys.iit.edu/~kmcivor/wxmpl/

Each of these approachs has different benefits and drawbacks, so I
Each of these approaches has different benefits and drawbacks, so I
encourage you to evaluate each of them and select the one that best
meets your needs.
2 changes: 1 addition & 1 deletion examples/user_interfaces/embedding_in_tk_canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def draw_figure(canvas, figure, loc=(0, 0)):
# Position: convert from top-left anchor to center anchor
canvas.create_image(loc[0] + figure_w/2, loc[1] + figure_h/2, image=photo)

# Unfortunatly, there's no accessor for the pointer to the native renderer
# Unfortunately, there's no accessor for the pointer to the native renderer
tkagg.blit(photo, figure_canvas_agg.get_renderer()._renderer, colormode=2)

# Return a handle which contains a reference to the photo object
Expand Down
Loading
0