8000 py3fy examples · matplotlib/matplotlib@a51b708 · GitHub
[go: up one dir, main page]

Skip to content

Commit a51b708

Browse files
committed
py3fy examples
- Remove future imports, six, encoding cookies. - The pgf_examples don't actually need to be sgskipped.
1 parent 637b649 commit a51b708

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+43
-133
lines changed

examples/api/custom_index_formatter.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
to leave out days on which there is no data, i.e. weekends. The example
88
below shows how to use an 'index formatter' to achieve the desired plot
99
"""
10-
from __future__ import print_function
1110
import numpy as np
1211
import matplotlib.pyplot as plt
1312
import matplotlib.cbook as cbook

examples/api/custom_projection_example.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,9 @@
33
Custom projection
44
=================
55
6-
Showcase Hammer projection by alleviating many features of
7-
matplotlib.
6+
Showcase Hammer projection by alleviating many features of Matplotlib.
87
"""
98

10-
11-
from __future__ import unicode_literals
12-
139
import matplotlib
1410
from matplotlib.axes import Axes
1511
from matplotlib.patches import Circle

examples/api/custom_scale_example.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,10 @@
33
Custom scale
44
============
55
6-
Create a custom scale, by implementing the
7-
scaling use for latitude data in a Mercator Projection.
6+
Create a custom scale, by implementing the scaling use for latitude data in a
7+
Mercator Projection.
88
"""
99

10-
11-
from __future__ import unicode_literals
12-
1310
import numpy as np
1411
from numpy import ma
1512
from matplotlib import scale as mscale

examples/api/engineering_formatter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
# `sep` (separator between the number and the prefix/unit).
3636
ax1.set_title('SI-prefix only ticklabels, 1-digit precision & '
3737
'thin space separator')
38-
formatter1 = EngFormatter(places=1, sep=u"\N{THIN SPACE}") # U+2009
38+
formatter1 = EngFormatter(places=1, sep="\N{THIN SPACE}") # U+2009
3939
ax1.xaxis.set_major_formatter(formatter1)
4040
ax1.plot(xs, ys)
4141
ax1.set_xlabel('Frequency [Hz]')

examples/api/filled_step.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import matplotlib.pyplot as plt
1515
import matplotlib.ticker as mticker
1616
from cycler import cycler
17-
from six.moves import zip
1817

1918

2019
def filled_hist(ax, edges, values, bottoms=None, orientation='v',
@@ -150,8 +149,8 @@ def stack_hist(ax, stacked_data, sty_cycle, bottoms=None,
150149
labels = itertools.repeat(None)
151150

152151
if label_data:
153-
loop_iter = enumerate((stacked_data[lab], lab, s) for lab, s in
154-
zip(labels, sty_cycle))
152+
loop_iter = enumerate((stacked_data[lab], lab, s)
153+
for lab, s in zip(labels, sty_cycle))
155154
else:
156155
loop_iter = enumerate(zip(stacked_data, labels, sty_cycle))
157156

examples/api/skewt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,10 @@ def upper_xlim(self):
180180

181181
if __name__ == '__main__':
182182
# Now make a simple example using the custom projection.
183+
from io import StringIO
183184
from matplotlib.ticker import (MultipleLocator, NullFormatter,
184185
ScalarFormatter)
185186
import matplotlib.pyplot as plt
186-
from six import StringIO
187187
import numpy as np
188188

189189
# Some examples data

examples/api/watermark_image.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
66
Use a PNG file as a watermark
77
"""
8-
from __future__ import print_function
98
import numpy as np
109
import matplotlib.cbook as cbook
1110
import matplotlib.image as image

examples/color/named_colors.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
66
Simple plot example with the named colors and its visual representation.
77
"""
8-
from __future__ import division
98

109
import matplotlib.pyplot as plt
1110
from matplotlib import colors as mcolors

examples/event_handling/close_event.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
66
Example to show connecting events that occur when the figure closes.
77
"""
8-
from __future__ import print_function
98
import matplotlib.pyplot as plt
109

1110

examples/event_handling/coords_demo.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
An example of how to interact with the plotting canvas by connecting
77
to move and click events
88
"""
9-
from __future__ import print_function
109
import sys
1110
import matplotlib.pyplot as plt
1211
import numpy as np

examples/event_handling/figure_axes_enter_leave.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
Illustrate the figure and axes enter and leave events by changing the
77
frame colors on enter and leave
88
"""
9-
from __future__ import print_function
109
import matplotlib.pyplot as plt
1110

1211

examples/event_handling/ginput_demo_sgskip.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
88
"""
99

10-
from __future__ import print_function
1110

1211
import matplotlib.pyplot as plt
1312
import numpy as np

examples/event_handling/ginput_manual_clabel_sgskip.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
1515
"""
1616

17-
from __future__ import print_function
1817

1918
import time
2019
import matplotlib

examples/event_handling/image_slices_viewer.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
66
Scroll through 2D image slices of a 3D array.
77
"""
8-
from __future__ import print_function
98

109
import numpy as np
1110
import matplotlib.pyplot as plt

examples/event_handling/keypress_demo.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
66
Show how to connect to keypress events
77
"""
8-
from __future__ import print_function
98
import sys
109
import numpy as np
1110
import matplotlib.pyplot as plt

examples/event_handling/pick_event_demo.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ def pick_handler(event):
6666
The examples below illustrate each of these methods.
6767
"""
6868

69-
from __future__ import print_function
7069
import matplotlib.pyplot as plt
7170
from matplotlib.lines import Line2D
7271
from matplotlib.patches import Rectangle

examples/event_handling/pipong.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
pipong.py was written by Paul Ivanov <http://pirsquared.org>
99
"""
1010

11-
from __future__ import print_function
1211

1312
import numpy as np
1413
import matplotlib.pyplot as plt

examples/event_handling/pong_sgskip.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
This example requires :download:`pipong.py <pipong.py>`
1111
1212
"""
13-
from __future__ import print_function, division
1413
import time
1514

1615

examples/images_contours_and_fields/image_demo.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
functionality of imshow and the many images you can create.
1111
1212
"""
13-
from __future__ import print_function
1413

1514
import numpy as np
1615
import matplotlib.cm as cm

examples/images_contours_and_fields/layer_images.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
66
Layer images above one another using alpha blending
77
"""
8-
from __future__ import division
98
import matplotlib.pyplot as plt
109
import numpy as np
1110

examples/lines_bars_and_markers/marker_reference.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
66
Reference for filled- and unfilled-marker types included with Matplotlib.
77
"""
8-
from six import iteritems
8+
99
import numpy as np
1010
import matplotlib.pyplot as plt
1111
from matplotlib.lines import Line2D
@@ -36,9 +36,7 @@ def split_list(a_list):
3636
fig, axes = plt.subplots(ncols=2)
3737

3838
# Filter out filled markers and marker settings that do nothing.
39-
# We use iteritems from six to make sure that we get an iterator
40-
# in both python 2 and 3
41-
unfilled_markers = [m for m, func in iteritems(Line2D.markers)
39+
unfilled_markers = [m for m, func in Line2D.markers.items()
4240
if func != 'nothing' and m not in Line2D.filled_markers]
4341
# Reverse-sort for pretty. We use our own sort key which is essentially
4442
# a python3 compatible reimplementation of python2 sort.

examples/lines_bars_and_markers/markevery_demo.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
2121
"""
2222

23-
from __future__ import division
2423
import numpy as np
2524
import matplotlib.pyplot as plt
2625
import matplotlib.gridspec as gridspec

examples/misc/cursor_demo_sgskip.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
https://github.com/joferkington/mpldatacursor
1717
https://github.com/anntzer/mplcursors
1818
"""
19-
from __future__ import print_function
2019
import matplotlib.pyplot as plt
2120
import numpy as np
2221

examples/misc/font_indexing.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
tables relate to one another. Mainly for mpl developers....
88
99
"""
10-
from __future__ import print_function
1110
import matplotlib
1211
from matplotlib.ft2font import FT2Font, KERNING_DEFAULT, KERNING_UNFITTED, KERNING_UNSCALED
1312

examples/misc/ftface_props.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
individual character metrics, use the Glyph object, as returned by
99
load_char
1010
"""
11-
from __future__ import print_function
1211
import matplotlib
1312
import matplotlib.ft2font as ft
1413

examples/misc/image_thumbnail_sgskip.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
1111
"""
1212

13-
from __future__ import print_function
1413
# build thumbnails of all images in a directory
1514
import sys
1615
import os

examples/misc/load_converter.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
==============
55
66
"""
7-
from __future__ import print_function
87
import numpy as np
98
import matplotlib.pyplot as plt
109
import matplotlib.cbook as cbook

examples/misc/multiprocess_sgskip.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
99
Written by Robert Cimrman
1010
"""
11-
from __future__ import print_function
1211

1312
import time
1413
import numpy as np

examples/misc/print_stdout_sgskip.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,4 @@
1515
import matplotlib.pyplot as plt
1616

1717
plt.plot([1, 2, 3])
18-
19-
if sys.version_info[0] >= 3:
20-
plt.savefig(sys.stdout.buffer)
21-
else:
22-
plt.savefig(sys.stdout)
18+
plt.savefig(sys.stdout.buffer)

examples/misc/set_and_get.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@
6767
these properties will be listed as 'fullname or aliasname'.
6868
"""
6969

70-
from __future__ import print_function
7170

7271
import matplotlib.pyplot as plt
7372
import numpy as np

examples/misc/svg_filter_line.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
support it.
1010
"""
1111

12-
from __future__ import print_function
1312

1413
import matplotlib.pyplot as plt
1514
import matplotlib.transforms as mtransforms

examples/misc/tight_bbox_test.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
===============
55
66
"""
7-
from __future__ import print_function
87
import matplotlib.pyplot as plt
98
import numpy as np
109

examples/mplot3d/wire3d_animation.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
A very simple 'animation' of a 3D plot. See also rotate_axes3d_demo.
77
"""
88

9-
from __future__ import print_function
109

1110
from mpl_toolkits.mplot3d import axes3d
1211
import matplotlib.pyplot as plt

examples/pyplots/text_commands.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
"""
32
=============
43
Text Commands

examples/specialty_plots/anscombe.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
==================
55
66
"""
7-
from __future__ import print_function
87
"""
98
Edward Tufte uses this example from Anscombe to show 4 datasets of x
109
and y that have the same mean, standard deviation, and regression

examples/specialty_plots/mri_with_eeg.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
histogram and some EEG traces.
88
"""
99

10-
from __future__ import division, print_function
1110

1211
import numpy as np
1312
import matplotlib.pyplot as plt

examples/tests/backend_driver_sgskip.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
switches with a --.
2222
"""
2323

24-
from __future__ import print_function, division
2524
import os
2625
import time
2726
import sys
@@ -383,16 +382,12 @@ def drive(backend, directories, python=['python'], switches=[]):
383382
tmpfile_name = '_tmp_%s.py' % basename
384383
tmpfile = open(tmpfile_name, 'w')
385384

386-
future_imports = 'from __future__ import division, print_function'
387385
for line in open(fullpath):
388386
line_lstrip = line.lstrip()
389387
if line_lstrip.startswith("#"):
390388
tmpfile.write(line)
391-
elif 'unicode_literals' in line:
392-
future_imports = future_imports + ', unicode_literals'
393389

394390
tmpfile.writelines((
395-
future_imports + '\n',
396391
'import sys\n',
397392
'sys.path.append("%s")\n' % fpath.replace('\\', '\\\\'),
398393
'import matplotlib\n',
@@ -402,11 +397,7 @@ def drive(backend, directories, python=['python'], switches=[]):
402397
'numpy.seterr(invalid="ignore")\n',
403398
))
404399
for line in open(fullpath):
405-
line_lstrip = line.lstrip()
406-
if (line_lstrip.startswith('from __future__ import') or
407-
line_lstrip.startswith('matplotlib.use') or
408-
line_lstrip.startswith('savefig') or
409-
line_lstrip.startswith('show')):
400+
if line.lstrip().startswith(('matplotlib.use', 'savefig', 'show')):
410401
continue
411402
tmpfile.write(line)
412403
if backend in rcsetup.interactive_bk:

examples/text_labels_and_annotations/accented_text.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
r"""
32
=================================
43
Using accented text in matplotlib
@@ -13,7 +12,6 @@
1312
\^y
1413
1514
"""
16-
from __future__ import unicode_literals
1715
import matplotlib.pyplot as plt
1816

1917
# Mathtext demo

examples/text_labels_and_annotations/font_table_ttf_sgskip.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@
1919
from matplotlib.font_mana 94C9 ger import FontProperties
2020
import matplotlib.pyplot as plt
2121

22-
import six
23-
from six import unichr
24-
2522
# the font table grid
2623

2724
labelc = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
@@ -47,7 +44,7 @@
4744
if ccode >= 256:
4845
continue
4946
r, c = divmod(ccode, 16)
50-
s = unichr(ccode)
47+
s = chr(ccode)
5148
chars[r][c] = s
5249

5350
lightgrn = (0.5, 0.8, 0.5)

0 commit comments

Comments
 (0)
0