10000 py3fy examples by anntzer · Pull Request #10528 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

py3fy examples #10528

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 1 commit into from
Feb 19, 2018
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
1 change: 0 additions & 1 deletion examples/api/custom_index_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
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
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.cbook as cbook
Expand Down
6 changes: 1 addition & 5 deletions examples/api/custom_projection_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@
Custom projection
=================

Showcase Hammer projection by alleviating many features of
matplotlib.
Showcase Hammer projection by alleviating many features of Matplotlib.
"""


from __future__ import unicode_literals

import matplotlib
from matplotlib.axes import Axes
from matplotlib.patches import Circle
Expand Down
7 changes: 2 additions & 5 deletions examples/api/custom_scale_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@
Custom scale
============

Create a custom scale, by implementing the
scaling use for latitude data in a Mercator Projection.
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
from numpy import ma
from matplotlib import scale as mscale
Expand Down
2 changes: 1 addition & 1 deletion examples/api/engineering_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
# `sep` (separator between the number and the prefix/unit).
ax1.set_title('SI-prefix only ticklabels, 1-digit precision & '
'thin space separator')
formatter1 = EngFormatter(places=1, sep=u"\N{THIN SPACE}") # U+2009
formatter1 = EngFormatter(places=1, sep="\N{THIN SPACE}") # U+2009
ax1.xaxis.set_major_formatter(formatter1)
ax1.plot(xs, ys)
ax1.set_xlabel('Frequency [Hz]')
Expand Down
5 changes: 2 additions & 3 deletions examples/api/filled_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import matplotlib.pyplot as plt
import matplotlib.ticker as mticker
from cycler import cycler
from six.moves import zip


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

if label_data:
loop_iter = enumerate((stacked_data[lab], lab, s) for lab, s in
zip(labels, sty_cycle))
loop_iter = enumerate((stacked_data[lab], lab, s)
for lab, s in zip(labels, sty_cycle))
else:
loop_iter = enumerate(zip(stacked_data, labels, sty_cycle))

Expand Down
2 changes: 1 addition & 1 deletion examples/api/skewt.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,10 @@ def upper_xlim(self):

if __name__ == '__main__':
# Now make a simple example using the custom projection.
from io import StringIO
from matplotlib.ticker import (MultipleLocator, NullFormatter,
ScalarFormatter)
import matplotlib.pyplot as plt
from six import StringIO
import numpy as np

# Some examples data
Expand Down
1 change: 0 additions & 1 deletion examples/api/watermark_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

Use a PNG file as a watermark
"""
from __future__ import print_function
import numpy as np
import matplotlib.cbook as cbook
import matplotlib.image as image
Expand Down
1 change: 0 additions & 1 deletion examples/color/named_colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

Simple plot example with the named colors and its visual representation.
"""
from __future__ import division

import matplotlib.pyplot as plt
from matplotlib import colors as mcolors
Expand Down
1 change: 0 additions & 1 deletion examples/event_handling/close_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

Example to show connecting events that occur when the figure closes.
"""
from __future__ import print_function
import matplotlib.pyplot as plt


Expand Down
1 change: 0 additions & 1 deletion examples/event_handling/coords_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
An example of how to interact with the plotting canvas by connecting
to move and click events
"""
from __future__ import print_function
import sys
import matplotlib.pyplot as plt
import numpy as np
Expand Down
1 change: 0 additions & 1 deletion examples/event_handling/figure_axes_enter_leave.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
Illustrate the figure and axes enter and leave events by changing the
frame colors on enter and leave
"""
from __future__ import print_function
import matplotlib.pyplot as plt


Expand Down
1 change: 0 additions & 1 deletion examples/event_handling/ginput_demo_sgskip.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

"""

from __future__ import print_function

import matplotlib.pyplot as plt
import numpy as np
Expand Down
1 change: 0 additions & 1 deletion examples/event_handling/ginput_manual_clabel_sgskip.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

"""

from __future__ import print_function

import time
import matplotlib
Expand Down
1 change: 0 additions & 1 deletion examples/event_handling/image_slices_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

Scroll through 2D image slices of a 3D array.
"""
from __future__ import print_function

import numpy as np
import matplotlib.pyplot as plt
Expand Down
1 change: 0 additions & 1 deletion examples/event_handling/keypress_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

Show how to connect to keypress events
"""
from __future__ import print_function
import sys
import numpy as np
import matplotlib.pyplot as plt
Expand Down
1 change: 0 additions & 1 deletion examples/event_handling/pick_event_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ def pick_handler(event):
The examples below illustrate each of these methods.
"""

from __future__ import print_function
import matplotlib.pyplot as plt
from matplotlib.lines import Line2D
from matplotlib.patches import Rectangle
Expand Down
1 change: 0 additions & 1 deletion examples/event_handling/pipong.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
pipong.py was written by Paul Ivanov <http://pirsquared.org>
"""

from __future__ import print_function

import numpy as np
import matplotlib.pyplot as plt
Expand Down
1 change: 0 additions & 1 deletion examples/event_handling/pong_sgskip.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
This example requires :download:`pipong.py <pipong.py>`

"""
from __future__ import print_function, division
import time


Expand Down
1 change: 0 additions & 1 deletion examples/images_contours_and_fields/image_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
functionality of imshow and the many images you can create.

"""
from __future__ import print_function

import numpy as np
import matplotlib.cm as cm
Expand Down
1 change: 0 additions & 1 deletion examples/images_contours_and_fields/layer_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

Layer images above one another using alpha blending
"""
from __future__ import division
import matplotlib.pyplot as plt
import numpy as np

Expand Down
6 changes: 2 additions & 4 deletions examples/lines_bars_and_markers/marker_reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

Reference for filled- and unfilled-marker types included with Matplotlib.
"""
from six import iteritems

import numpy as np
import matplotlib.pyplot as plt
from matplotlib.lines import Line2D
Expand Down Expand Up @@ -36,9 +36,7 @@ def split_list(a_list):
fig, axes = plt.subplots(ncols=2)

# Filter out filled markers and marker settings that do nothing.
# We use iteritems from six to make sure that we get an iterator
# in both python 2 and 3
unfilled_markers = [m for m, func in iteritems(Line2D.markers)
unfilled_markers = [m for m, func in Line2D.markers.items()
if func != 'nothing' and m not in Line2D.filled_markers]
# Reverse-sort for pretty. We use our own sort key which is essentially
# a python3 compatible reimplementation of python2 sort.
Expand Down
1 change: 0 additions & 1 deletion examples/lines_bars_and_markers/markevery_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

"""

from __future__ import division
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
Expand Down
1 change: 0 additions & 1 deletion examples/misc/cursor_demo_sgskip.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
https://github.com/joferkington/mpldatacursor
https://github.com/anntzer/mplcursors
"""
from __future__ import print_function
import matplotlib.pyplot as plt
import numpy as np

Expand Down
1 change: 0 additions & 1 deletion examples/misc/font_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
tables relate to one another. Mainly for mpl developers....

"""
from __future__ import print_function
import matplotlib
from matplotlib.ft2font import FT2Font, KERNING_DEFAULT, KERNING_UNFITTED, KERNING_UNSCALED

Expand Down
1 change: 0 additions & 1 deletion examples/misc/ftface_props.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
individual character metrics, use the Glyph object, as returned by
load_char
"""
from __future__ import print_function
import matplotlib
import matplotlib.ft2font as ft

Expand Down
1 change: 0 additions & 1 deletion examples/misc/image_thumbnail_sgskip.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

"""

from __future__ import print_function
# build thumbnails of all images in a directory
import sys
import os
Expand Down
1 change: 0 additions & 1 deletion examples/misc/load_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
==============

"""
from __future__ import print_function
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.cbook as cbook
Expand Down
1 change: 0 additions & 1 deletion examples/misc/multiprocess_sgskip.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

Written by Robert Cimrman
"""
from __future__ import print_function

import time
import numpy as np
Expand Down
6 changes: 1 addition & 5 deletions examples/misc/print_stdout_sgskip.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,4 @@
import matplotlib.pyplot as plt

plt.plot([1, 2, 3])

if sys.version_info[0] >= 3:
plt.savefig(sys.stdout.buffer)
else:
plt.savefig(sys.stdout)
plt.savefig(sys.stdout.buffer)
1 change: 0 additions & 1 deletion examples/misc/set_and_get.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
these properties will be listed as 'fullname or aliasname'.
"""

from __future__ import print_function

import matplotlib.pyplot as plt
import numpy as np
Expand Down
1 change: 0 additions & 1 deletion examples/misc/svg_filter_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
support it.
"""

from __future__ import print_function

import matplotlib.pyplot as plt
import matplotlib.transforms as mtransforms
Expand Down
1 change: 0 additions & 1 deletion examples/misc/tight_bbox_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
===============

"""
from __future__ import print_function
import matplotlib.pyplot as plt
import numpy as np

Expand Down
1 change: 0 additions & 1 deletion examples/mplot3d/wire3d_animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
A very simple 'animation' of a 3D plot. See also rotate_axes3d_demo.
"""

from __future__ import print_function

from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
Expand Down
1 change: 0 additions & 1 deletion examples/pyplots/text_commands.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
=============
Text Commands
Expand Down
1 change: 0 additions & 1 deletion examples/specialty_plots/anscombe.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
==================

"""
from __future__ import print_function
"""
Edward Tufte uses this example from Anscombe to show 4 datasets of x
and y that have the same mean, standard deviation, and regression
Expand Down
1 change: 0 additions & 1 deletion examples/specialty_plots/mri_with_eeg.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
histogram and some EEG traces.
"""

from __future__ import division, print_function

import numpy as np
import matplotlib.pyplot as plt
Expand Down
11 changes: 1 addition & 10 deletions examples/tests/backend_driver_sgskip.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
switches with a --.
"""

from __future__ import print_function, division
import os
import time
import sys
Expand Down Expand Up @@ -383,16 +382,12 @@ def drive(backend, directories, python=['python'], switches=[]):
tmpfile_name = '_tmp_%s.py' % basename
tmpfile = open(tmpfile_name, 'w')

future_imports = 'from __future__ import division, print_function'
for line in open(fullpath):
line_lstrip = line.lstrip()
if line_lstrip.startswith("#"):
tmpfile.write(line)
elif 'unicode_literals' in line:
future_imports = future_imports + ', unicode_literals'

tmpfile.writelines((
future_imports + '\n',
'import sys\n',
'sys.path.append("%s")\n' % fpath.replace('\\', '\\\\'),
'import matplotlib\n',
Expand All @@ -402,11 +397,7 @@ def drive(backend, directories, python=['python'], switches=[]):
'numpy.seterr(invalid="ignore")\n',
))
for line in open(fullpath):
line_lstrip = line.lstrip()
if (line_lstrip.startswith('from __future__ import') or
line_lstrip.startswith('matplotlib.use') or
line_lstrip.startswith('savefig') or
line_lstrip.startswith('show')):
if line.lstrip().startswith(('matplotlib.use', 'savefig', 'show')):
continue
tmpfile.write(line)
if backend in rcsetup.interactive_bk:
Expand Down
2 changes: 0 additions & 2 deletions examples/text_labels_and_annotations/accented_text.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
r"""
=================================
Using accented text in matplotlib
Expand All @@ -13,7 +12,6 @@
\^y

"""
from __future__ import unicode_literals
import matplotlib.pyplot as plt

# Mathtext demo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
from matplotlib.font_manager import FontProperties
import matplotlib.pyplot as plt

import six
from six import unichr

# the font table grid

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

lightgrn = (0.5, 0.8, 0.5)
Expand Down
Loading
0