diff --git a/examples/axes_grid1/inset_locator_demo.py b/examples/axes_grid1/inset_locator_demo.py index 0e75afdd370f..5fd0bc926794 100644 --- a/examples/axes_grid1/inset_locator_demo.py +++ b/examples/axes_grid1/inset_locator_demo.py @@ -55,9 +55,9 @@ ax = fig.add_subplot(121) # We use the axes transform as bbox_transform. Therefore the bounding box -# needs to be specified in axes coordinates ((0,0) is the lower left corner -# of the axes, (1,1) is the upper right corner). -# The bounding box (.2, .4, .6, .5) starts at (.2,.4) and ranges to (.8,.9) +# needs to be specified in axes coordinates ((0, 0) is the lower left corner +# of the axes, (1, 1) is the upper right corner). +# The bounding box (.2, .4, .6, .5) starts at (.2, .4) and ranges to (.8, .9) # in those coordinates. # Inside of this bounding box an inset of half the bounding box' width and # three quarters of the bounding box' height is created. The lower left corner diff --git a/examples/event_handling/trifinder_event_demo.py b/examples/event_handling/trifinder_event_demo.py index 3cc96f1aac37..c97a262f5528 100644 --- a/examples/event_handling/trifinder_event_demo.py +++ b/examples/event_handling/trifinder_event_demo.py @@ -54,7 +54,7 @@ def motion_notify(event): # Setup plot and callbacks. plt.subplot(111, aspect='equal') plt.triplot(triang, 'bo-') -polygon = Polygon([[0, 0], [0, 0]], facecolor='y') # dummy data for xs,ys +polygon = Polygon([[0, 0], [0, 0]], facecolor='y') # dummy data for (xs, ys) update_polygon(-1) plt.gca().add_patch(polygon) plt.gcf().canvas.mpl_connect('motion_notify_event', motion_notify) diff --git a/examples/event_handling/zoom_window.py b/examples/event_handling/zoom_window.py index c2cc1cce5561..cab911ac29ca 100644 --- a/examples/event_handling/zoom_window.py +++ b/examples/event_handling/zoom_window.py @@ -8,7 +8,7 @@ If you click on a point in the first window, the z and y limits of the second will be adjusted so that the center of the zoom in the second window will be -the x,y coordinates of the clicked point. +the (x, y) coordinates of the clicked point. Note the diameter of the circles in the scatter are defined in points**2, so their size is independent of the zoom. diff --git a/examples/images_contours_and_fields/image_demo.py b/examples/images_contours_and_fields/image_demo.py index 58ae0c9e2903..39813aa94063 100644 --- a/examples/images_contours_and_fields/image_demo.py +++ b/examples/images_contours_and_fields/image_demo.py @@ -78,9 +78,9 @@ # achieving the look you want. Below we'll display the same (small) array, # interpolated with three different interpolation methods. # -# The center of the pixel at A[i,j] is plotted at i+0.5, i+0.5. If you -# are using interpolation='nearest', the region bounded by (i,j) and -# (i+1,j+1) will have the same color. If you are using interpolation, +# The center of the pixel at A[i, j] is plotted at (i+0.5, i+0.5). If you +# are using interpolation='nearest', the region bounded by (i, j) and +# (i+1, j+1) will have the same color. If you are using interpolation, # the pixel center will have the same color as it does with nearest, but # other pixels will be interpolated between the neighboring pixels. # @@ -129,7 +129,7 @@ ############################################################################### # You can specify whether images should be plotted with the array origin -# x[0,0] in the upper left or lower right by using the origin parameter. +# x[0, 0] in the upper left or lower right by using the origin parameter. # You can also control the default setting image.origin in your # :ref:`matplotlibrc file `. For more on # this topic see the :doc:`complete guide on origin and extent diff --git a/examples/images_contours_and_fields/irregulardatagrid.py b/examples/images_contours_and_fields/irregulardatagrid.py index 643e3a911c7e..1715e0ce292e 100644 --- a/examples/images_contours_and_fields/irregulardatagrid.py +++ b/examples/images_contours_and_fields/irregulardatagrid.py @@ -44,8 +44,7 @@ xi = np.linspace(-2.1, 2.1, ngridx) yi = np.linspace(-2.1, 2.1, ngridy) -# Perform linear interpolation of the data (x,y) -# on a grid defined by (xi,yi) +# Linearly interpolate the data (x, y) on a grid defined by (xi, yi). triang = tri.Triangulation(x, y) interpolator = tri.LinearTriInterpolator(triang, z) Xi, Yi = np.meshgrid(xi, yi) @@ -56,7 +55,6 @@ #from scipy.interpolate import griddata #zi = griddata((x, y), z, (xi[None,:], yi[:,None]), method='linear') - ax1.contour(xi, yi, zi, levels=14, linewidths=0.5, colors='k') cntr1 = ax1.contourf(xi, yi, zi, levels=14, cmap="RdBu_r") @@ -66,7 +64,6 @@ ax1.set_title('grid and contour (%d points, %d grid points)' % (npts, ngridx * ngridy)) - # ---------- # Tricontour # ---------- diff --git a/examples/lines_bars_and_markers/psd_demo.py b/examples/lines_bars_and_markers/psd_demo.py index cd0d35882630..9c3cb78c0c2d 100644 --- a/examples/lines_bars_and_markers/psd_demo.py +++ b/examples/lines_bars_and_markers/psd_demo.py @@ -45,7 +45,7 @@ # s = 0.1*sin(2*pi*t) + cnse; # # subplot(211) -# plot(t,s) +# plot(t, s) # subplot(212) # psd(s, 512, 1/dt) # diff --git a/examples/lines_bars_and_markers/scatter_piecharts.py b/examples/lines_bars_and_markers/scatter_piecharts.py index 2bb0e292b89d..6b2b4aa88824 100644 --- a/examples/lines_bars_and_markers/scatter_piecharts.py +++ b/examples/lines_bars_and_markers/scatter_piecharts.py @@ -19,7 +19,7 @@ sizes = np.array([60, 80, 120]) # calculate the points of the first pie marker -# these are just the origin (0,0) + some points on a circle cos,sin +# these are just the origin (0, 0) + some (cos, sin) points on a circle x1 = np.cos(2 * np.pi * np.linspace(0, r1)) y1 = np.sin(2 * np.pi * np.linspace(0, r1)) xy1 = np.row_stack([[0, 0], np.column_stack([x1, y1])]) diff --git a/examples/misc/customize_rc.py b/examples/misc/customize_rc.py index 37bc5b8d4bc7..7a5384b9bb08 100644 --- a/examples/misc/customize_rc.py +++ b/examples/misc/customize_rc.py @@ -22,7 +22,7 @@ def set_pub(): >>> set_pub() >>> subplot(111) - >>> plot([1,2,3]) + >>> plot([1, 2, 3]) >>> savefig('myfig') >>> rcdefaults() # restore the defaults diff --git a/examples/misc/demo_agg_filter.py b/examples/misc/demo_agg_filter.py index c2f085d844ae..9dfc45655c3b 100644 --- a/examples/misc/demo_agg_filter.py +++ b/examples/misc/demo_agg_filter.py @@ -264,7 +264,7 @@ def drop_shadow_patches(ax): men_means = [20, 35, 30, 35, 27] ind = np.arange(N) # the x locations for the groups - width = 0.35 # the width of the bars + width = 0.35 # the width of the bars rects1 = ax.bar(ind, men_means, width, color='r', ec="w", lw=2) @@ -272,8 +272,8 @@ def drop_shadow_patches(ax): rects2 = ax.bar(ind + width + 0.1, women_means, width, color='y', ec="w", lw=2) - # gauss = GaussianFilter(1.5, offsets=(1,1), ) - gauss = DropShadowFilter(5, offsets=(1, 1), ) + # gauss = GaussianFilter(1.5, offsets=(1, 1)) + gauss = DropShadowFilter(5, offsets=(1, 1)) shadow = FilteredArtistList(rects1 + rects2, gauss) ax.add_artist(shadow) shadow.set_zorder(rects1[0].get_zorder() - 0.1) diff --git a/examples/misc/set_and_get.py b/examples/misc/set_and_get.py index 3239d39518b0..b1ffc7199068 100644 --- a/examples/misc/set_and_get.py +++ b/examples/misc/set_and_get.py @@ -11,7 +11,7 @@ To set the linestyle of a line to be dashed, you can do:: - >>> line, = plt.plot([1,2,3]) + >>> line, = plt.plot([1, 2, 3]) >>> plt.setp(line, linestyle='--') If you want to know the valid types of arguments, you can provide the @@ -31,7 +31,7 @@ the instances will be set. e.g., suppose you have a list of two lines, the following will make both lines thicker and red:: - >>> x = np.arange(0,1.0,0.01) + >>> x = np.arange(0, 1, 0.01) >>> y1 = np.sin(2*np.pi*x) >>> y2 = np.sin(4*np.pi*x) >>> lines = plt.plot(x, y1, x, y2) diff --git a/examples/mplot3d/2dcollections3d.py b/examples/mplot3d/2dcollections3d.py index f07275e0468d..c5956bc08fb5 100644 --- a/examples/mplot3d/2dcollections3d.py +++ b/examples/mplot3d/2dcollections3d.py @@ -16,7 +16,7 @@ # Plot a sin curve using the x and y axes. x = np.linspace(0, 1, 100) y = np.sin(x * 2 * np.pi) / 2 + 0.5 -ax.plot(x, y, zs=0, zdir='z', label='curve in (x,y)') +ax.plot(x, y, zs=0, zdir='z', label='curve in (x, y)') # Plot scatterplot data (20 2D points per colour) on the x and z axes. colors = ('r', 'g', 'b', 'k') @@ -30,8 +30,8 @@ for c in colors: c_list.extend([c] * 20) # By using zdir='y', the y value of these points is fixed to the zs value 0 -# and the (x,y) points are plotted on the x and z axes. -ax.scatter(x, y, zs=0, zdir='y', c=c_list, label='points in (x,z)') +# and the (x, y) points are plotted on the x and z axes. +ax.scatter(x, y, zs=0, zdir='y', c=c_list, label='points in (x, z)') # Make legend, set axes limits and labels ax.legend() diff --git a/examples/mplot3d/contour3d.py b/examples/mplot3d/contour3d.py index d4bfdec9693a..a740c30376c1 100644 --- a/examples/mplot3d/contour3d.py +++ b/examples/mplot3d/contour3d.py @@ -3,8 +3,8 @@ Demonstrates plotting contour (level) curves in 3D ================================================== -This is like a contour plot in 2D except that the f(x,y)=c curve is plotted -on the plane z=c. +This is like a contour plot in 2D except that the ``f(x, y)=c`` curve is +plotted on the plane ``z=c``. """ from mpl_toolkits.mplot3d import axes3d diff --git a/examples/mplot3d/polys3d.py b/examples/mplot3d/polys3d.py index 3759175d56bf..06c138b5c59c 100644 --- a/examples/mplot3d/polys3d.py +++ b/examples/mplot3d/polys3d.py @@ -28,7 +28,8 @@ def polygon_under_graph(xlist, ylist): fig = plt.figure() ax = fig.gca(projection='3d') -# Make verts a list, verts[i] will be a list of (x,y) pairs defining polygon i +# Make verts a list such that verts[i] is a list of (x, y) pairs defining +# polygon i. verts = [] # Set up the x sequence diff --git a/examples/pie_and_polar_charts/pie_and_donut_labels.py b/examples/pie_and_polar_charts/pie_and_donut_labels.py index 237c5e71508e..701d464267b7 100644 --- a/examples/pie_and_polar_charts/pie_and_donut_labels.py +++ b/examples/pie_and_polar_charts/pie_and_donut_labels.py @@ -28,7 +28,7 @@ # the pie. Here we use the axes coordinates ``(1, 0, 0.5, 1)`` together # with the location ``"center left"``; i.e. # the left central point of the legend will be at the left central point of the -# bounding box, spanning from ``(1,0)`` to ``(1.5,1)`` in axes coordinates. +# bounding box, spanning from ``(1, 0)`` to ``(1.5, 1)`` in axes coordinates. import numpy as np import matplotlib.pyplot as plt diff --git a/examples/pyplots/annotation_polar.py b/examples/pyplots/annotation_polar.py index e900c70d102d..534bb54a7760 100644 --- a/examples/pyplots/annotation_polar.py +++ b/examples/pyplots/annotation_polar.py @@ -13,7 +13,7 @@ fig = plt.figure() ax = fig.add_subplot(111, polar=True) -r = np.arange(0,1,0.001) +r = np.arange(0, 1, 0.001) theta = 2 * 2*np.pi * r line, = ax.plot(theta, r, color='#ee8d18', lw=3) diff --git a/examples/pyplots/auto_subplots_adjust.py b/examples/pyplots/auto_subplots_adjust.py index cac2cffbcf42..4283d0dcedf3 100644 --- a/examples/pyplots/auto_subplots_adjust.py +++ b/examples/pyplots/auto_subplots_adjust.py @@ -17,7 +17,7 @@ fig, ax = plt.subplots() ax.plot(range(10)) -ax.set_yticks((2,5,7)) +ax.set_yticks((2, 5, 7)) labels = ax.set_yticklabels(('really, really, really', 'long', 'labels')) def on_draw(event): diff --git a/examples/pyplots/boxplot_demo_pyplot.py b/examples/pyplots/boxplot_demo_pyplot.py index 26e4fcd9b72b..c073c40344b0 100644 --- a/examples/pyplots/boxplot_demo_pyplot.py +++ b/examples/pyplots/boxplot_demo_pyplot.py @@ -74,7 +74,7 @@ # This is actually more efficient because boxplot converts # a 2-D array into a list of vectors internally anyway. -data = [data, d2, d2[::2,0]] +data = [data, d2, d2[::2, 0]] fig7, ax7 = plt.subplots() ax7.set_title('Multiple Samples with Different sizes') ax7.boxplot(data) diff --git a/examples/pyplots/pyplot_mathtext.py b/examples/pyplots/pyplot_mathtext.py index 709488bcc933..40bbaccf72d2 100644 --- a/examples/pyplots/pyplot_mathtext.py +++ b/examples/pyplots/pyplot_mathtext.py @@ -11,7 +11,7 @@ t = np.arange(0.0, 2.0, 0.01) s = np.sin(2*np.pi*t) -plt.plot(t,s) +plt.plot(t, s) plt.title(r'$\alpha_i > \beta_i$', fontsize=20) plt.text(1, -0.6, r'$\sum_{i=0}^\infty x_i$', fontsize=20) plt.text(0.6, 0.6, r'$\mathcal{A}\mathrm{sin}(2 \omega t)$', diff --git a/examples/pyplots/pyplot_simple.py b/examples/pyplots/pyplot_simple.py index 6ad0483ebe2e..025c7b65ee40 100644 --- a/examples/pyplots/pyplot_simple.py +++ b/examples/pyplots/pyplot_simple.py @@ -6,7 +6,7 @@ A most simple plot, where a list of numbers is plotted against their index. """ import matplotlib.pyplot as plt -plt.plot([1,2,3,4]) +plt.plot([1, 2, 3, 4]) plt.ylabel('some numbers') plt.show() diff --git a/examples/shapes_and_collections/collections.py b/examples/shapes_and_collections/collections.py index 46d5972953a7..fd368e2fe528 100644 --- a/examples/shapes_and_collections/collections.py +++ b/examples/shapes_and_collections/collections.py @@ -12,11 +12,10 @@ The third subplot will make regular polygons, with the same type of scaling and positioning as in the first two. -The last subplot illustrates the use of "offsets=(xo,yo)", +The last subplot illustrates the use of "offsets=(xo, yo)", that is, a single tuple instead of a list of tuples, to generate successively offset curves, with the offset given in data units. This behavior is available only for the LineCollection. - ''' import matplotlib.pyplot as plt @@ -53,7 +52,7 @@ trans = fig.dpi_scale_trans + transforms.Affine2D().scale(1.0/72.0) col.set_transform(trans) # the points to pixels transform # Note: the first argument to the collection initializer -# must be a list of sequences of x,y tuples; we have only +# must be a list of sequences of (x, y) tuples; we have only # one sequence, but we still have to put it in a list. ax1.add_collection(col, autolim=True) # autolim=True enables autoscaling. For collections with diff --git a/examples/shapes_and_collections/line_collection.py b/examples/shapes_and_collections/line_collection.py index 343c4a124ac5..baeae677ebaa 100644 --- a/examples/shapes_and_collections/line_collection.py +++ b/examples/shapes_and_collections/line_collection.py @@ -71,7 +71,7 @@ # If linestyle is omitted, 'solid' is used # See :class:`matplotlib.collections.LineCollection` for more information -# Make a sequence of x,y pairs +# Make a sequence of (x, y) pairs. line_segments = LineCollection([np.column_stack([x, y]) for y in ys], linewidths=(0.5, 1, 1.5, 2), linestyles='solid') diff --git a/examples/specialty_plots/leftventricle_bulleye.py b/examples/specialty_plots/leftventricle_bulleye.py index 1d87dbaf3c3c..11947f6617a5 100644 --- a/examples/specialty_plots/leftventricle_bulleye.py +++ b/examples/specialty_plots/leftventricle_bulleye.py @@ -205,6 +205,6 @@ def bullseye_plot(ax, data, seg_bold=None, cmap=None, norm=None): bullseye_plot(ax[2], data, seg_bold=[3, 5, 6, 11, 12, 16], cmap=cmap3, norm=norm3) -ax[2].set_title('Segments [3,5,6,11,12,16] in bold') +ax[2].set_title('Segments [3, 5, 6, 11, 12, 16] in bold') plt.show() diff --git a/examples/statistics/boxplot_demo.py b/examples/statistics/boxplot_demo.py index c6fc79cfc008..15733151a537 100644 --- a/examples/statistics/boxplot_demo.py +++ b/examples/statistics/boxplot_demo.py @@ -82,8 +82,8 @@ # properties of the original sample, and a boxplot is one visual tool # to make this assessment -random_dists = ['Normal(1,1)', ' Lognormal(1,1)', 'Exp(1)', 'Gumbel(6,4)', - 'Triangular(2,9,11)'] +random_dists = ['Normal(1, 1)', 'Lognormal(1, 1)', 'Exp(1)', 'Gumbel(6, 4)', + 'Triangular(2, 9, 11)'] N = 500 norm = np.random.normal(1, 1, N) diff --git a/examples/subplots_axes_and_figures/broken_axis.py b/examples/subplots_axes_and_figures/broken_axis.py index 613955378798..beb87f3dadd6 100644 --- a/examples/subplots_axes_and_figures/broken_axis.py +++ b/examples/subplots_axes_and_figures/broken_axis.py @@ -42,8 +42,8 @@ # This looks pretty good, and was fairly painless, but you can get that # cut-out diagonal lines look with just a bit more work. The important # thing to know here is that in axes coordinates, which are always -# between 0-1, spine endpoints are at these locations (0,0), (0,1), -# (1,0), and (1,1). Thus, we just need to put the diagonals in the +# between 0-1, spine endpoints are at these locations (0, 0), (0, 1), +# (1, 0), and (1, 1). Thus, we just need to put the diagonals in the # appropriate corners of each of our axes, and so long as we use the # right transform and disable clipping. diff --git a/examples/subplots_axes_and_figures/subplots_demo.py b/examples/subplots_axes_and_figures/subplots_demo.py index 6dddeb26ba07..35848e8ebdd5 100644 --- a/examples/subplots_axes_and_figures/subplots_demo.py +++ b/examples/subplots_axes_and_figures/subplots_demo.py @@ -78,13 +78,13 @@ fig, axs = plt.subplots(2, 2) axs[0, 0].plot(x, y) -axs[0, 0].set_title('Axis [0,0]') +axs[0, 0].set_title('Axis [0, 0]') axs[0, 1].plot(x, y, 'tab:orange') -axs[0, 1].set_title('Axis [0,1]') +axs[0, 1].set_title('Axis [0, 1]') axs[1, 0].plot(x, -y, 'tab:green') -axs[1, 0].set_title('Axis [1,0]') +axs[1, 0].set_title('Axis [1, 0]') axs[1, 1].plot(x, -y, 'tab:red') -axs[1, 1].set_title('Axis [1,1]') +axs[1, 1].set_title('Axis [1, 1]') for ax in axs.flat: ax.set(xlabel='x-label', ylabel='y-label') diff --git a/examples/text_labels_and_annotations/annotation_demo.py b/examples/text_labels_and_annotations/annotation_demo.py index 92958dde25f5..5476c39d243f 100644 --- a/examples/text_labels_and_annotations/annotation_demo.py +++ b/examples/text_labels_and_annotations/annotation_demo.py @@ -20,21 +20,21 @@ # Specifying text points and annotation points # -------------------------------------------- # -# You must specify an annotation point `xy=(x,y)` to annotate this point. -# additionally, you may specify a text point `xytext=(x,y)` for the +# You must specify an annotation point `xy=(x, y)` to annotate this point. +# additionally, you may specify a text point `xytext=(x, y)` for the # location of the text for this annotation. Optionally, you can # specify the coordinate system of `xy` and `xytext` with one of the # following strings for `xycoords` and `textcoords` (default is 'data'):: # -# 'figure points' : points from the lower left corner of the figure -# 'figure pixels' : pixels from the lower left corner of the figure -# 'figure fraction' : 0,0 is lower left of figure and 1,1 is upper, right -# 'axes points' : points from lower left corner of axes -# 'axes pixels' : pixels from lower left corner of axes -# 'axes fraction' : 0,0 is lower left of axes and 1,1 is upper right -# 'offset points' : Specify an offset (in points) from the xy value -# 'offset pixels' : Specify an offset (in pixels) from the xy value -# 'data' : use the axes data coordinate system +# 'figure points' : points from the lower left corner of the figure +# 'figure pixels' : pixels from the lower left corner of the figure +# 'figure fraction' : (0, 0) is lower left of figure and (1, 1) is upper right +# 'axes points' : points from lower left corner of axes +# 'axes pixels' : pixels from lower left corner of axes +# 'axes fraction' : (0, 0) is lower left of axes and (1, 1) is upper right +# 'offset points' : Specify an offset (in points) from the xy value +# 'offset pixels' : Specify an offset (in pixels) from the xy value +# 'data' : use the axes data coordinate system # # Note: for physical coordinate systems (points or pixels) the origin is the # (bottom, left) of the figure or axes. diff --git a/examples/text_labels_and_annotations/text_alignment.py b/examples/text_labels_and_annotations/text_alignment.py index e92984098c92..836a75ae7920 100644 --- a/examples/text_labels_and_annotations/text_alignment.py +++ b/examples/text_labels_and_annotations/text_alignment.py @@ -3,9 +3,8 @@ Precise text layout =================== -You can precisely layout text in data or axes (0,1) coordinates. This -example shows you some of the alignment and rotation specifications for text -layout. +You can precisely layout text in data or axes coordinates. This example shows +you some of the alignment and rotation specifications for text layout. """ import matplotlib.pyplot as plt diff --git a/examples/text_labels_and_annotations/text_rotation.py b/examples/text_labels_and_annotations/text_rotation.py index 0e22ee02d638..cdd678013bf8 100644 --- a/examples/text_labels_and_annotations/text_rotation.py +++ b/examples/text_labels_and_annotations/text_rotation.py @@ -8,12 +8,11 @@ The text is aligned by its bounding box (the rectangular box that surrounds the ink rectangle). The order of operations is rotation then alignment. -Basically, the text is centered at your x,y location, rotated around this +Basically, the text is centered at your (x, y) location, rotated around this point, and then aligned according to the bounding box of the rotated text. So if you specify left, bottom alignment, the bottom left of the -bounding box of the rotated text will be at the x,y coordinate of the -text. +bounding box of the rotated text will be at the (x, y) coordinate of the text. But a picture is worth a thousand words! """ diff --git a/examples/user_interfaces/embedding_in_wx4_sgskip.py b/examples/user_interfaces/embedding_in_wx4_sgskip.py index 65d592d1768b..a2fa08f56d54 100644 --- a/examples/user_interfaces/embedding_in_wx4_sgskip.py +++ b/examples/user_interfaces/embedding_in_wx4_sgskip.py @@ -29,20 +29,12 @@ def __init__(self, canvas): self.Bind(wx.EVT_TOOL, self._on_custom, id=tool.GetId()) def _on_custom(self, evt): - # add some text to the axes in a random location in axes (0,1) - # coords) with a random color - - # get the axes + # add some text to the axes in a random location in axes coords with a + # random color ax = self.canvas.figure.axes[0] - - # generate a random location can color - x, y = np.random.rand(2) - rgb = np.random.rand(3) - - # add the text and draw - ax.text(x, y, 'You clicked me', - transform=ax.transAxes, - color=rgb) + x, y = np.random.rand(2) # generate a random location + rgb = np.random.rand(3) # generate a random color + ax.text(x, y, 'You clicked me', transform=ax.transAxes, color=rgb) self.canvas.draw() evt.Skip() diff --git a/examples/user_interfaces/svg_histogram_sgskip.py b/examples/user_interfaces/svg_histogram_sgskip.py index 2332fac8a050..b213d7441718 100644 --- a/examples/user_interfaces/svg_histogram_sgskip.py +++ b/examples/user_interfaces/svg_histogram_sgskip.py @@ -141,7 +141,7 @@ var names = container['hist_'+num] for (var i=0; i < names.length; i++) { - toggle(names[i], 'opacity', [1,0]) + toggle(names[i], 'opacity', [1, 0]) }; } ]]> diff --git a/examples/userdemo/simple_annotate01.py b/examples/userdemo/simple_annotate01.py index 0092aaabbf95..2c0fd606e9b0 100644 --- a/examples/userdemo/simple_annotate01.py +++ b/examples/userdemo/simple_annotate01.py @@ -81,7 +81,7 @@ bbox=dict(boxstyle="round", fc="w", ), arrowprops=dict(arrowstyle="->", relpos=(0., 0.)) ) -ax.text(.05, .95, "relpos=(0,0)", transform=ax.transAxes, ha="left", va="top") +ax.text(.05, .95, "relpos=(0, 0)", transform=ax.transAxes, ha="left", va="top") for ax in axs.flat: ax.set(xlim=(0, 1), ylim=(0, 1), xticks=[], yticks=[], aspect=1) diff --git a/lib/matplotlib/_cm.py b/lib/matplotlib/_cm.py index 4de5e7c2bad8..06f3ebbf13a0 100644 --- a/lib/matplotlib/_cm.py +++ b/lib/matplotlib/_cm.py @@ -65,22 +65,22 @@ def _ch_helper(gamma, s, r, h, p0, p1, x): def cubehelix(gamma=1.0, s=0.5, r=-1.5, h=1.0): """ - Return custom data dictionary of (r,g,b) conversion functions, which can be - used with :func:`register_cmap`, for the cubehelix color scheme. + Return custom data dictionary of (r, g, b) conversion functions, which can + be used with :func:`register_cmap`, for the cubehelix color scheme. Unlike most other color schemes cubehelix was designed by D.A. Green to be monotonically increasing in terms of perceived brightness. Also, when printed on a black and white postscript printer, the scheme results in a greyscale with monotonically increasing brightness. - This color scheme is named cubehelix because the r,g,b values produced + This color scheme is named cubehelix because the (r, g, b) values produced can be visualised as a squashed helix around the diagonal in the - r,g,b color cube. + (r, g, b) color cube. - For a unit color cube (i.e. 3-D coordinates for r,g,b each in the - range 0 to 1) the color scheme starts at (r,g,b) = (0,0,0), i.e. black, - and finishes at (r,g,b) = (1,1,1), i.e. white. For some fraction *x*, + For a unit color cube (i.e. 3-D coordinates for (r, g, b) each in the + range 0 to 1) the color scheme starts at (r, g, b) = (0, 0, 0), i.e. black, + and finishes at (r, g, b) = (1, 1, 1), i.e. white. For some fraction *x*, between 0 and 1, the color is the corresponding grey value at that - fraction along the black to white diagonal (x,x,x) plus a color + fraction along the black to white diagonal (x, x, x) plus a color element. This color element is calculated in a plane of constant perceived intensity and controlled by the following parameters. @@ -93,7 +93,7 @@ def cubehelix(gamma=1.0, s=0.5, r=-1.5, h=1.0): (gamma < 1), or high intensity values (gamma > 1); defaults to 1.0. s the start color; defaults to 0.5 (i.e. purple). - r the number of r,g,b rotations in color that are made + r the number of r, g, b rotations in color that are made from the start to the end of the color scheme; defaults to -1.5 (i.e. -> B -> G -> R -> B). h the hue parameter which controls how saturated the diff --git a/lib/matplotlib/_constrained_layout.py b/lib/matplotlib/_constrained_layout.py index 0230a317a9f2..b9fac97d30a8 100644 --- a/lib/matplotlib/_constrained_layout.py +++ b/lib/matplotlib/_constrained_layout.py @@ -409,7 +409,7 @@ def _align_spines(fig, gs): # This allows vertically stacked subplots to have # different sizes if they occupy different amounts # of the gridspec: i.e. - # gs = gridspec.GridSpec(3,1) + # gs = gridspec.GridSpec(3, 1) # ax1 = gs[0,:] # ax2 = gs[1:,:] # then drows0 = 1, and drowsC = 2, and ax2 diff --git a/lib/matplotlib/_layoutbox.py b/lib/matplotlib/_layoutbox.py index f8bf9640181c..4f31f7bdb95e 100644 --- a/lib/matplotlib/_layoutbox.py +++ b/lib/matplotlib/_layoutbox.py @@ -445,7 +445,7 @@ def layout_from_subplotspec(self, subspec, figLeft = min(figLefts[colNum1], figLefts[colNum2]) figRight = max(figRights[colNum1], figRights[colNum2]) - # These are numbers relative to 0,0,1,1. Need to constrain + # These are numbers relative to (0, 0, 1, 1). Need to constrain # relative to parent. width = figRight - figLeft @@ -700,9 +700,9 @@ def plot_children(fig, box, level=0, printit=True): print(child) ax.add_patch( patches.Rectangle( - (child.left.value(), child.bottom.value()), # (x,y) - child.width.value(), # width - child.height.value(), # height + (child.left.value(), child.bottom.value()), # (x, y) + child.width.value(), # width + child.height.value(), # height fc='none', alpha=0.8, ec=colors[level] diff --git a/lib/matplotlib/animation.py b/lib/matplotlib/animation.py index d1122102c4ba..1aa11f99bc37 100644 --- a/lib/matplotlib/animation.py +++ b/lib/matplotlib/animation.py @@ -591,7 +591,7 @@ def output_args(self): args = ['-vcodec', self.codec] # For h264, the default format is yuv444p, which is not compatible # with quicktime (and others). Specifying yuv420p fixes playback on - # iOS,as well as HTML5 video in firefox and safari (on both Win and + # iOS, as well as HTML5 video in firefox and safari (on both Win and # OSX). Also fixes internet explorer. This is as of 2015/10/29. if self.codec == 'h264' and '-pix_fmt' not in self.extra_args: args.extend(['-pix_fmt', 'yuv420p']) diff --git a/lib/matplotlib/artist.py b/lib/matplotlib/artist.py index 97b1cc777679..5098574c50f6 100644 --- a/lib/matplotlib/artist.py +++ b/lib/matplotlib/artist.py @@ -1502,7 +1502,7 @@ def setp(obj, *args, **kwargs): introspection on the object. For example, to set the linestyle of a line to be dashed, you can do:: - >>> line, = plot([1,2,3]) + >>> line, = plot([1, 2, 3]) >>> setp(line, linestyle='--') If you want to know the valid types of arguments, you can provide @@ -1530,7 +1530,7 @@ def setp(obj, *args, **kwargs): suppose you have a list of two lines, the following will make both lines thicker and red:: - >>> x = arange(0,1.0,0.01) + >>> x = arange(0, 1, 0.01) >>> y1 = sin(2*pi*x) >>> y2 = sin(4*pi*x) >>> lines = plot(x, y1, x, y2) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 7e12b1fcabcb..1ae809f35319 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -729,8 +729,8 @@ def text(self, x, y, s, fontdict=None, withdash=False, **kwargs): >>> text(x, y, s, fontsize=12) The default transform specifies that text is in data coords, - alternatively, you can specify text in axis coords (0,0 is - lower-left and 1,1 is upper-right). The example below places + alternatively, you can specify text in axis coords ((0, 0) is + lower-left and (1, 1) is upper-right). The example below places text in the center of the axes:: >>> text(0.5, 0.5, 'matplotlib', horizontalalignment='center', @@ -1537,8 +1537,8 @@ def plot(self, *args, scalex=True, scaley=True, data=None, **kwargs): auto legends), linewidth, antialiasing, marker face color. Example:: - >>> plot([1,2,3], [1,2,3], 'go-', label='line 1', linewidth=2) - >>> plot([1,2,3], [1,4,9], 'rs', label='line 2') + >>> plot([1, 2, 3], [1, 2, 3], 'go-', label='line 1', linewidth=2) + >>> plot([1, 2, 3], [1, 4, 9], 'rs', label='line 2') If you make multiple lines with one plot command, the kwargs apply to all those lines. @@ -2222,15 +2222,15 @@ def bar(self, x, height, width=0.8, bottom=None, *, align="center", The tick labels of the bars. Default: None (Use default numeric labels.) - xerr, yerr : scalar or array-like of shape(N,) or shape(2,N), optional + xerr, yerr : scalar or array-like of shape(N,) or shape(2, N), optional If not *None*, add horizontal / vertical errorbars to the bar tips. The values are +/- sizes relative to the data: - scalar: symmetric +/- values for all bars - shape(N,): symmetric +/- values for each bar - - shape(2,N): Separate - and + values for each bar. First row - contains the lower errors, the second row contains the - upper errors. + - shape(2, N): Separate - and + values for each bar. First row + contains the lower errors, the second row contains the upper + errors. - *None*: No errorbar. (Default) See :doc:`/gallery/statistics/errorbar_features` @@ -2518,15 +2518,15 @@ def barh(self, y, width, height=0.8, left=None, *, align="center", The tick labels of the bars. Default: None (Use default numeric labels.) - xerr, yerr : scalar or array-like of shape(N,) or shape(2,N), optional + xerr, yerr : scalar or array-like of shape(N,) or shape(2, N), optional If not ``None``, add horizontal / vertical errorbars to the bar tips. The values are +/- sizes relative to the data: - scalar: symmetric +/- values for all bars - shape(N,): symmetric +/- values for each bar - - shape(2,N): Separate - and + values for each bar. First row - contains the lower errors, the second row contains the - upper errors. + - shape(2, N): Separate - and + values for each bar. First row + contains the lower errors, the second row contains the upper + errors. - *None*: No errorbar. (default) See :doc:`/gallery/statistics/errorbar_features` @@ -3085,14 +3085,14 @@ def errorbar(self, x, y, yerr=None, xerr=None, x, y : scalar or array-like The data positions. - xerr, yerr : scalar or array-like, shape(N,) or shape(2,N), optional + xerr, yerr : scalar or array-like, shape(N,) or shape(2, N), optional The errorbar sizes: - scalar: Symmetric +/- values for all data points. - shape(N,): Symmetric +/-values for each data point. - - shape(2,N): Separate - and + values for each bar. First row - contains the lower errors, the second row contains the - upper errors. + - shape(2, N): Separate - and + values for each bar. First row + contains the lower errors, the second row contains the upper + errors. - *None*: No errorbar. Note that all error arrays should have *positive* values. @@ -3167,7 +3167,7 @@ def errorbar(self, x, y, yerr=None, xerr=None, command for the markers. For example, this code makes big red squares with thick green edges:: - x,y,yerr = rand(3,10) + x, y, yerr = rand(3, 10) errorbar(x, y, yerr, marker='s', mfc='red', mec='green', ms=20, mew=4) @@ -4574,7 +4574,7 @@ def hexbin(self, x, y, C=None, gridsize=100, bins=None, norm : object, optional, default is *None* :class:`matplotlib.colors.Normalize` instance is used to - scale luminance data to 0,1. + scale luminance data to (0, 1). vmin, vmax : scalar, optional, default is *None* *vmin* and *vmax* are used in conjunction with *norm* to @@ -5423,7 +5423,7 @@ def get_interp_point(ind): self._request_autoscale_view() return collection - #### plotting z(x,y): imshow, pcolor and relatives, contour + #### plotting z(x, y): imshow, pcolor and relatives, contour @_preprocess_data() @cbook._delete_parameter("3.1", "shape") @cbook._delete_parameter("3.1", "imlim") @@ -5512,7 +5512,7 @@ def imshow(self, X, cmap=None, norm=None, aspect=None, data. *vmin*, *vmax* are ignored if the *norm* parameter is used. origin : {'upper', 'lower'}, optional - Place the [0,0] index of the array in the upper left or lower left + Place the [0, 0] index of the array in the upper left or lower left corner of the axes. The convention 'upper' is typically used for matrices and images. If not given, :rc:`image.origin` is used, defaulting to 'upper'. @@ -5714,13 +5714,13 @@ def pcolor(self, *args, alpha=None, norm=None, cmap=None, vmin=None, X, Y : array_like, optional The coordinates of the quadrilateral corners. The quadrilateral - for ``C[i,j]`` has corners at:: + for ``C[i, j]`` has corners at:: - (X[i+1, j], Y[i+1, j]) (X[i+1, j+1], Y[i+1, j+1]) - +--------+ - | C[i,j] | - +--------+ - (X[i, j], Y[i, j]) (X[i, j+1], Y[i, j+1]), + (X[i+1, j], Y[i+1, j]) (X[i+1, j+1], Y[i+1, j+1]) + +---------+ + | C[i, j] | + +---------+ + (X[i, j], Y[i, j]) (X[i, j+1], Y[i, j+1]) Note that the column index corresponds to the x-coordinate, and the row index corresponds to y. For @@ -5802,7 +5802,7 @@ def pcolor(self, *args, alpha=None, norm=None, cmap=None, vmin=None, **Masked arrays** *X*, *Y* and *C* may be masked arrays. If either ``C[i, j]``, or one - of the vertices surrounding ``C[i,j]`` (*X* or *Y* at + of the vertices surrounding ``C[i, j]`` (*X* or *Y* at ``[i, j], [i+1, j], [i, j+1], [i+1, j+1]``) is masked, nothing is plotted. @@ -5945,13 +5945,13 @@ def pcolormesh(self, *args, alpha=None, norm=None, cmap=None, vmin=None, X, Y : array_like, optional The coordinates of the quadrilateral corners. The quadrilateral - for ``C[i,j]`` has corners at:: + for ``C[i, j]`` has corners at:: - (X[i+1, j], Y[i+1, j]) (X[i+1, j+1], Y[i+1, j+1]) - +--------+ - | C[i,j] | - +--------+ - (X[i, j], Y[i, j]) (X[i, j+1], Y[i, j+1]), + (X[i+1, j], Y[i+1, j]) (X[i+1, j+1], Y[i+1, j+1]) + +---------+ + | C[i, j] | + +---------+ + (X[i, j], Y[i, j]) (X[i, j+1], Y[i, j+1]) Note that the column index corresponds to the x-coordinate, and the row index corresponds to y. For @@ -6000,7 +6000,7 @@ def pcolormesh(self, *args, alpha=None, norm=None, cmap=None, vmin=None, - 'flat': A solid color is used for each quad. The color of the quad (i, j), (i+1, j), (i, j+1), (i+1, j+1) is given by - ``C[i,j]``. + ``C[i, j]``. - 'gouraud': Each quad will be Gouraud shaded: The color of the corners (i', j') are given by ``C[i',j']``. The color values of the area in between is interpolated from the corner values. @@ -6515,7 +6515,7 @@ def hist(self, x, bins=None, range=None, density=False, weights=None, The values of the histogram bins. See *density* and *weights* for a description of the possible semantics. If input *x* is an array, then this is an array of length *nbins*. If input is a sequence of - arrays ``[data1, data2,..]``, then this is a list of arrays with + arrays ``[data1, data2, ...]``, then this is a list of arrays with the values of the histograms for each of the arrays in the same order. The dtype of the array *n* (or of its element arrays) will always be float even if no weighting or normalization is used. @@ -7668,7 +7668,7 @@ def spy(self, Z, precision=0, marker=None, markersize=None, will be plotted, even if it is identically zero. origin : {'upper', 'lower'}, optional - Place the [0,0] index of the array in the upper left or lower left + Place the [0, 0] index of the array in the upper left or lower left corner of the axes. The convention 'upper' is typically used for matrices and images. If not given, :rc:`image.origin` is used, defaulting to 'upper'. @@ -8117,7 +8117,7 @@ def violin(self, vpstats, positions=None, vert=True, widths=0.5, table = mtable.table - # args can by either Y or y1,y2,... and all should be replaced + # args can by either Y or y1, y2, ... and all should be replaced stackplot = _preprocess_data()(mstack.stackplot) streamplot = _preprocess_data( diff --git a/lib/matplotlib/axes/_base.py b/lib/matplotlib/axes/_base.py index 16d8d7ae9a5d..50519bb54a40 100644 --- a/lib/matplotlib/axes/_base.py +++ b/lib/matplotlib/axes/_base.py @@ -2785,8 +2785,8 @@ def ticklabel_format(self, *, axis='both', style='', scilimits=None, is 'sci', scientific notation will be used for numbers outside the range 10\ :sup:`m` to 10\ :sup:`n`. - Use (0,0) to include all numbers. - Use (m,m) where m <> 0 to fix the order + Use (0, 0) to include all numbers. + Use (m, m) where m != 0 to fix the order of magnitude to 10\ :sup:`m`. *useOffset* [ bool | offset ]; if True, the offset will be calculated as needed; @@ -3942,10 +3942,10 @@ def _set_view_from_bbox(self, bbox, direction='in', ---------- bbox : 4-tuple or 3 tuple * If bbox is a 4 tuple, it is the selected bounding box limits, - in *display* coordinates. + in *display* coordinates. * If bbox is a 3 tuple, it is an (xp, yp, scl) triple, where - (xp,yp) is the center of zooming and scl the scale factor to - zoom by. + (xp, yp) is the center of zooming and scl the scale factor to + zoom by. direction : str The direction to apply the bounding box. diff --git a/lib/matplotlib/axes/_subplots.py b/lib/matplotlib/axes/_subplots.py index 3357c438d2e6..6ba9439f6b86 100644 --- a/lib/matplotlib/axes/_subplots.py +++ b/lib/matplotlib/axes/_subplots.py @@ -99,13 +99,13 @@ def __reduce__(self): self.__getstate__()) def get_geometry(self): - """get the subplot geometry, e.g., 2,2,3""" + """Get the subplot geometry, e.g., (2, 2, 3).""" rows, cols, num1, num2 = self.get_subplotspec().get_geometry() return rows, cols, num1 + 1 # for compatibility # COVERAGE NOTE: Never used internally or from examples def change_geometry(self, numrows, numcols, num): - """change subplot geometry, e.g., from 1,1,1 to 2,2,3""" + """Change subplot geometry, e.g., from (1, 1, 1) to (2, 2, 3).""" self._subplotspec = GridSpec(numrows, numcols, figure=self.figure)[num - 1] self.update_params() diff --git a/lib/matplotlib/axis.py b/lib/matplotlib/axis.py index db8a41e628e5..edb57f6264a2 100644 --- a/lib/matplotlib/axis.py +++ b/lib/matplotlib/axis.py @@ -426,7 +426,7 @@ def apply_tickdir(self, tickdir): def _get_text1(self): 'Get the default Text instance' # the y loc is 3 points below the min of y axis - # get the affine as an a,b,c,d,tx,ty list + # get the affine as an a, b, c, d, tx, ty list # x in data coords, y in axes coords trans, vert, horiz = self._get_text1_transform() t = mtext.Text( @@ -799,15 +799,13 @@ def set_label_coords(self, x, y, transform=None): """ Set the coordinates of the label. - By default, the x coordinate of the y label is determined by the tick - label bounding boxes, but this can lead to poor alignment of multiple - ylabels if there are multiple axes. Ditto for the y coordinate of - the x label. + By default, the x coordinate of the y label and the y coordinate of the + x label are determined by the tick label bounding boxes, but this can + lead to poor alignment of multiple labels if there are multiple axes. - You can also specify the coordinate system of the label with - the transform. If None, the default coordinate system will be - the axes coordinate system (0,0) is (left,bottom), (0.5, 0.5) - is middle, etc + You can also specify the coordinate system of the label with the + transform. If None, the default coordinate system will be the axes + coordinate system: (0, 0) is bottom left, (0.5, 0.5) is center, etc. """ self._autolabelpos = False if transform is None: diff --git a/lib/matplotlib/backend_bases.py b/lib/matplotlib/backend_bases.py index 65fca83d9deb..4661bf79761c 100644 --- a/lib/matplotlib/backend_bases.py +++ b/lib/matplotlib/backend_bases.py @@ -717,7 +717,7 @@ class GraphicsContextBase: def __init__(self): self._alpha = 1.0 self._forced_alpha = False # if True, _alpha overrides A from RGBA - self._antialiased = 1 # use 0,1 not True, False for extension code + self._antialiased = 1 # use 0, 1 not True, False for extension code self._capstyle = 'butt' self._cliprect = None self._clippath = None @@ -1311,7 +1311,7 @@ class LocationEvent(Event): def __init__(self, name, canvas, x, y, guiEvent=None): """ - *x*, *y* in figure coords, 0,0 = bottom, left + (*x*, *y*) in figure coords ((0, 0) = bottom left). """ Event.__init__(self, name, canvas, guiEvent=guiEvent) # x position - pixels from left of canvas @@ -1323,7 +1323,7 @@ def __init__(self, name, canvas, x, y, guiEvent=None): self.ydata = None # y coord of mouse in data coords if x is None or y is None: - # cannot check if event was in axes if no x,y info + # cannot check if event was in axes if no (x, y) info self._update_enter_leave() return @@ -1428,7 +1428,7 @@ def on_press(event): def __init__(self, name, canvas, x, y, button=None, key=None, step=0, dblclick=False, guiEvent=None): """ - x, y in figure coords, 0,0 = bottom, left + (*x*, *y*) in figure coords ((0, 0) = bottom left) button pressed None, 1, 2, 3, 'up', 'down' """ LocationEvent.__init__(self, name, canvas, x, y, guiEvent=guiEvent) @@ -1741,8 +1741,8 @@ def pick_event(self, mouseevent, artist, **kwargs): def scroll_event(self, x, y, step, guiEvent=None): """ Backend derived classes should call this function on any - scroll wheel event. x,y are the canvas coords: 0,0 is lower, - left. button and key are as defined in MouseEvent. + scroll wheel event. (*x*, *y*) are the canvas coords ((0, 0) is lower + left). button and key are as defined in MouseEvent. This method will be call all functions connected to the 'scroll_event' with a :class:`MouseEvent` instance. @@ -1759,7 +1759,7 @@ def scroll_event(self, x, y, step, guiEvent=None): def button_press_event(self, x, y, button, dblclick=False, guiEvent=None): """ Backend derived classes should call this function on any mouse - button press. x,y are the canvas coords: 0,0 is lower, left. + button press. (*x*, *y*) are the canvas coords ((0, 0) is lower left). button and key are as defined in :class:`MouseEvent`. This method will be call all functions connected to the @@ -1862,7 +1862,7 @@ def inaxes(self, xy): Parameters ---------- xy : tuple or list - (x,y) coordinates. + (x, y) coordinates. x position - pixels from left of canvas. y position - pixels from bottom of canvas. @@ -2969,7 +2969,7 @@ def release_zoom(self, event): self.draw() return - # detect twinx,y axes and avoid double zooming + # detect twinx, twiny axes and avoid double zooming twinx, twiny = False, False if last_a: for la in last_a: diff --git a/lib/matplotlib/backend_tools.py b/lib/matplotlib/backend_tools.py index bb097641a9dd..17b28883819d 100644 --- a/lib/matplotlib/backend_tools.py +++ b/lib/matplotlib/backend_tools.py @@ -941,7 +941,7 @@ def _release(self, event): self._cancel_action() return - # detect twinx,y axes and avoid double zooming + # detect twinx, twiny axes and avoid double zooming twinx, twiny = False, False if last_a: for la in last_a: diff --git a/lib/matplotlib/backends/backend_cairo.py b/lib/matplotlib/backends/backend_cairo.py index 63b1b8461458..4b1d7a8b11ce 100644 --- a/lib/matplotlib/backends/backend_cairo.py +++ b/lib/matplotlib/backends/backend_cairo.py @@ -206,7 +206,7 @@ def draw_image(self, gc, x, y, im): def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None): # docstring inherited - # Note: x,y are device/display coords, not user-coords, unlike other + # Note: (x, y) are device/display coords, not user-coords, unlike other # draw_* methods if ismath: self._draw_mathtext(gc, x, y, s, prop, angle) diff --git a/lib/matplotlib/backends/backend_ps.py b/lib/matplotlib/backends/backend_ps.py index 642e859e643b..df21df8a280a 100644 --- a/lib/matplotlib/backends/backend_ps.py +++ b/lib/matplotlib/backends/backend_ps.py @@ -1326,7 +1326,7 @@ def convert_psfrags(tmpfile, psfrags, font_preamble, custom_preamble, # check if the dvips created a ps in landscape paper. Somehow, # above latex+dvips results in a ps file in a landscape mode for a - # certain figure sizes (e.g., 8.3in,5.8in which is a5). And the + # certain figure sizes (e.g., 8.3in, 5.8in which is a5). And the # bounding box of the final output got messed up. We check see if # the generated ps file is in landscape and return this # information. The return value is used in pstoeps step to recover diff --git a/lib/matplotlib/backends/backend_qt5.py b/lib/matplotlib/backends/backend_qt5.py index 19dca99ce743..8810661eae2f 100644 --- a/lib/matplotlib/backends/backend_qt5.py +++ b/lib/matplotlib/backends/backend_qt5.py @@ -697,7 +697,7 @@ def _init_toolbar(self): 'Customize', self.edit_parameters) a.setToolTip('Edit axis, curve and image parameters') - # Add the x,y location widget at the right side of the toolbar + # Add the (x, y) location widget at the right side of the toolbar # The stretch factor is 1 which means any resizing of the toolbar # will resize this label instead of the buttons. if self.coordinates: diff --git a/lib/matplotlib/cbook/__init__.py b/lib/matplotlib/cbook/__init__.py index 87ef050b6310..f0f73154ed09 100644 --- a/lib/matplotlib/cbook/__init__.py +++ b/lib/matplotlib/cbook/__init__.py @@ -1894,7 +1894,7 @@ def _array_perimeter(arr): perimeter : ndarray, shape (2*(M - 1) + 2*(N - 1),) The elements on the perimeter of the array:: - [arr[0,0] ... arr[0,-1] ... arr[-1, -1] ... arr[-1,0] ...] + [arr[0, 0], ..., arr[0, -1], ..., arr[-1, -1], ..., arr[-1, 0], ...] Examples -------- diff --git a/lib/matplotlib/collections.py b/lib/matplotlib/collections.py index ab5e6e2e8520..9239cfdf9328 100644 --- a/lib/matplotlib/collections.py +++ b/lib/matplotlib/collections.py @@ -884,7 +884,7 @@ def legend_elements(self, prop="colors", num="auto", Creates legend handles and labels for a PathCollection. This is useful for obtaining a legend for a :meth:`~.Axes.scatter` plot. E.g.:: - scatter = plt.scatter([1,2,3], [4,5,6], c=[7,2,3]) + scatter = plt.scatter([1, 2, 3], [4, 5, 6], c=[7, 2, 3]) plt.legend(*scatter.legend_elements()) Also see the :ref:`automatedlegendcreation` example. @@ -1148,15 +1148,14 @@ def __init__(self, Example: see :doc:`/gallery/event_handling/lasso_demo` for a complete example:: - offsets = np.random.rand(20,2) + offsets = np.random.rand(20, 2) facecolors = [cm.jet(x) for x in np.random.rand(20)] - black = (0,0,0,1) collection = RegularPolyCollection( numsides=5, # a pentagon rotation=0, sizes=(50,), facecolors=facecolors, - edgecolors=(black,), + edgecolors=("black",), linewidths=(1,), offsets=offsets, transOffset=ax.transData, @@ -1281,7 +1280,7 @@ def __init__(self, segments, # Can be None. *offsets* are added to the segments before any transformation. In this case, a single offset can be specified as:: - offsets=(xo,yo) + offsets=(xo, yo) and this value will be added cumulatively to each successive segment, so as to produce a set of successively offset curves. diff --git a/lib/matplotlib/colorbar.py b/lib/matplotlib/colorbar.py index 22fdb6801581..3597b73d54b8 100644 --- a/lib/matplotlib/colorbar.py +++ b/lib/matplotlib/colorbar.py @@ -1055,12 +1055,11 @@ def _proportional_y(self): def _mesh(self): ''' - Return X,Y, the coordinate arrays for the colorbar pcolormesh. - These are suitable for a vertical colorbar; swapping and - transposition for a horizontal colorbar are done outside - this function. + Return ``(X, Y)``, the coordinate arrays for the colorbar pcolormesh. + These are suitable for a vertical colorbar; swapping and transposition + for a horizontal colorbar are done outside this function. - These are scaled between vmin and vmax + These are scaled between vmin and vmax. ''' # copy the norm and change the vmin and vmax to the vmin and # vmax of the colorbar, not the norm. This allows the situation diff --git a/lib/matplotlib/colors.py b/lib/matplotlib/colors.py index 469c3316d840..a8faeb43837a 100644 --- a/lib/matplotlib/colors.py +++ b/lib/matplotlib/colors.py @@ -1884,9 +1884,9 @@ def blend_hsv(self, rgb, intensity, hsv_max_sat=None, hsv_max_val=None, relief map with a specified light source. RGBA values are returned, which can then be used to plot the shaded image with imshow. - The color of the resulting image will be darkened by moving the (s,v) + The color of the resulting image will be darkened by moving the (s, v) values (in hsv colorspace) toward (hsv_min_sat, hsv_min_val) in the - shaded regions, or lightened by sliding (s,v) toward (hsv_max_sat + shaded regions, or lightened by sliding (s, v) toward (hsv_max_sat, hsv_max_val) in regions that are illuminated. The default extremes are chose so that completely shaded points are nearly black (s = 1, v = 0) and completely illuminated points are nearly white (s = 0, v = 1). diff --git a/lib/matplotlib/contour.py b/lib/matplotlib/contour.py index 835595b334ff..d26dcd84eb9b 100644 --- a/lib/matplotlib/contour.py +++ b/lib/matplotlib/contour.py @@ -112,9 +112,9 @@ def clabel(self, levels=None, *, placement, delete or backspace act like the third mouse button, and any other key will select a label location). - *manual* can also be an iterable object of x,y tuples. + *manual* can also be an iterable object of (x, y) tuples. Contour labels will be created as if mouse is clicked at each - x,y positions. + (x, y) position. rightside_up : bool, optional If ``True``, label rotations will always be plus @@ -486,7 +486,7 @@ def add_label_near(self, x, y, inline=True, inline_spacing=5, conmin, segmin, imin, xmin, ymin = self.find_nearest_contour( x, y, self.labelIndiceList)[:5] - # The calc_label_rot_and_inline routine requires that (xmin,ymin) + # The calc_label_rot_and_inline routine requires that (xmin, ymin) # be a vertex in the path. So, if it isn't, add a vertex here # grab the paths from the collections @@ -698,7 +698,7 @@ class ContourSet(cm.ScalarMappable, ContourLabeler): should look like:: level0segs = [polygon0, polygon1, ...] - polygon0 = array_like [[x0,y0], [x1,y1], ...] + polygon0 = [[x0, y0], [x1, y1], ...] allkinds : ``None`` or [level0kinds, level1kinds, ...] Optional list of all the polygon vertex kinds (code types), as @@ -764,7 +764,7 @@ def __init__(self, ax, *args, should look like:: level0segs = [polygon0, polygon1, ...] - polygon0 = array_like [[x0,y0], [x1,y1], ...] + polygon0 = [[x0, y0], [x1, y1], ...] allkinds : [level0kinds, level1kinds, ...], optional Optional list of all the polygon vertex kinds (code types), as @@ -814,8 +814,8 @@ def __init__(self, ax, *args, cbook._check_in_list([None, 'lower', 'upper', 'image'], origin=origin) if self.extent is not None and len(self.extent) != 4: - raise ValueError("If given, *extent* must be '[ *None* |" - " (x0,x1,y0,y1) ]'") + raise ValueError( + "If given, 'extent' must be None or (x0, x1, y0, y1)") if self.colors is not None and cmap is not None: raise ValueError('Either colors or cmap must be None') if self.origin == 'image': @@ -1048,7 +1048,7 @@ def _process_args(self, *args, **kwargs): len(self.allkinds) != len(self.allsegs)): raise ValueError('allkinds has different length to allsegs') - # Determine x,y bounds and update axes data limits. + # Determine x, y bounds and update axes data limits. flatseglist = [s for seg in self.allsegs for s in seg] points = np.concatenate(flatseglist, axis=0) self._mins = points.min(axis=0) @@ -1065,7 +1065,7 @@ def _get_allsegs_and_allkinds(self): def _get_lowers_and_uppers(self): """ - Return (lowers,uppers) for filled contours. + Return ``(lowers, uppers)`` for filled contours. """ lowers = self._levels[:-1] if self.zmin == lowers[0]: @@ -1553,7 +1553,7 @@ def _initialize_x_y(self, z): """ Return X, Y arrays such that contour(Z) will match imshow(Z) if origin is not None. - The center of pixel Z[i,j] depends on origin: + The center of pixel Z[i, j] depends on origin: if origin is None, x = j, y = i; if origin is 'lower', x = j + 0.5, y = i + 0.5; if origin is 'upper', x = j + 0.5, y = Nrows - i - 0.5 @@ -1689,8 +1689,8 @@ def _initialize_x_y(self, z): extent : (x0, x1, y0, y1), optional If *origin* is not *None*, then *extent* is interpreted as in `.imshow`: it gives the outer pixel boundaries. In this case, the - position of Z[0,0] is the center of the pixel, not a corner. If - *origin* is *None*, then (*x0*, *y0*) is the position of Z[0,0], + position of Z[0, 0] is the center of the pixel, not a corner. If + *origin* is *None*, then (*x0*, *y0*) is the position of Z[0, 0], and (*x1*, *y1*) is the position of Z[-1,-1]. This argument is ignored if *X* and *Y* are specified in the call diff --git a/lib/matplotlib/dates.py b/lib/matplotlib/dates.py index f0f38f6b57b6..b61976850bd8 100644 --- a/lib/matplotlib/dates.py +++ b/lib/matplotlib/dates.py @@ -1258,7 +1258,7 @@ def __init__(self, tz=None, minticks=5, maxticks=None, *interval_multiples* is a boolean that indicates whether ticks should be chosen to be multiple of the interval. This will lock ticks to 'nicer' locations. For example, this will force the - ticks to be at hours 0,6,12,18 when hourly ticking is done at + ticks to be at hours 0, 6, 12, 18 when hourly ticking is done at 6 hour intervals. The AutoDateLocator has an interval dictionary that maps the @@ -1317,7 +1317,7 @@ def __init__(self, tz=None, minticks=5, maxticks=None, 1000000]} if interval_multiples: # Swap "3" for "4" in the DAILY list; If we use 3 we get bad - # tick loc for months w/ 31 days: 1, 4,..., 28, 31, 1 + # tick loc for months w/ 31 days: 1, 4, ..., 28, 31, 1 # If we use 4 then we get: 1, 5, ... 25, 29, 1 self.intervald[DAILY] = [1, 2, 4, 7, 14, 21] @@ -1556,7 +1556,7 @@ class MonthLocator(RRuleLocator): def __init__(self, bymonth=None, bymonthday=1, interval=1, tz=None): """ Mark every month in *bymonth*; *bymonth* can be an int or - sequence. Default is ``range(1,13)``, i.e. every month. + sequence. Default is ``range(1, 13)``, i.e. every month. *interval* is the interval between each iteration. For example, if ``interval=2``, mark every second occurrence. diff --git a/lib/matplotlib/figure.py b/lib/matplotlib/figure.py index 2896a2477ddd..8f582e1c1f76 100644 --- a/lib/matplotlib/figure.py +++ b/lib/matplotlib/figure.py @@ -844,7 +844,7 @@ def figimage(self, X, xo=0, yo=0, alpha=None, norm=None, cmap=None, (:meth:`~matplotlib.axes.Axes.imshow`) which will be resampled to fit the current axes. If you want a resampled image to fill the entire figure, you can define an - :class:`~matplotlib.axes.Axes` with extent [0,0,1,1]. + :class:`~matplotlib.axes.Axes` with extent [0, 0, 1, 1]. Examples:: @@ -1208,11 +1208,11 @@ def add_axes(self, *args, **kwargs): rect = l, b, w, h fig = plt.figure() - fig.add_axes(rect,label=label1) - fig.add_axes(rect,label=label2) + fig.add_axes(rect, label=label1) + fig.add_axes(rect, label=label2) fig.add_axes(rect, frameon=False, facecolor='g') fig.add_axes(rect, polar=True) - ax=fig.add_axes(rect, projection='polar') + ax = fig.add_axes(rect, projection='polar') fig.delaxes(ax) fig.add_axes(ax) """ @@ -2728,7 +2728,7 @@ def figaspect(arg): Make a figure with the proper aspect for an array:: - A = rand(5,3) + A = rand(5, 3) w, h = figaspect(A) fig = Figure(figsize=(w, h)) ax = fig.add_axes([0.1, 0.1, 0.8, 0.8]) diff --git a/lib/matplotlib/image.py b/lib/matplotlib/image.py index 7e7e846a0629..560abe2bae14 100644 --- a/lib/matplotlib/image.py +++ b/lib/matplotlib/image.py @@ -984,12 +984,14 @@ def set_data(self, x, y, A): """ Set the grid for the pixel centers, and the pixel values. - *x* and *y* are monotonic 1-D ndarrays of lengths N and M, - respectively, specifying pixel centers - - *A* is an (M,N) ndarray or masked array of values to be - colormapped, or a (M,N,3) RGB array, or a (M,N,4) RGBA - array. + Parameters + ---------- + x, y : 1D array-likes + Monotonic arrays of shapes (N,) and (M,), respectively, specifying + pixel centers. + A : array-like + (M, N) ndarray or masked array of values to be colormapped, or + (M, N, 3) RGB array, or (M, N, 4) RGBA array. """ x = np.array(x, np.float32) y = np.array(y, np.float32) @@ -1112,15 +1114,15 @@ def set_data(self, x, y, A): """ Set the grid for the rectangle boundaries, and the data values. - *x* and *y* are monotonic 1-D ndarrays of lengths N+1 and M+1, - respectively, specifying rectangle boundaries. If None, - they will be created as uniform arrays from 0 through N - and 0 through M, respectively. - - *A* is an (M,N) ndarray or masked array of values to be - colormapped, or a (M,N,3) RGB array, or a (M,N,4) RGBA - array. - + Parameters + ---------- + x, y : 1D array-likes or None + Monotonic arrays of shapes (N + 1,) and (M + 1,), respectively, + specifying rectangle boundaries. If None, will default to + ``range(N + 1)`` and ``range(M + 1)``, respectively. + A : array-like + (M, N) ndarray or masked array of values to be colormapped, or + (M, N, 3) RGB array, or (M, N, 4) RGBA array. """ A = cbook.safe_masked_invalid(A, copy=True) if x is None: diff --git a/lib/matplotlib/legend.py b/lib/matplotlib/legend.py index 20da51037372..97b6d1052d62 100644 --- a/lib/matplotlib/legend.py +++ b/lib/matplotlib/legend.py @@ -1070,7 +1070,7 @@ def set_bbox_to_anchor(self, bbox, transform=None): def _get_anchored_bbox(self, loc, bbox, parentbbox, renderer): """ Place the *bbox* inside the *parentbbox* according to a given - location code. Return the (x,y) coordinate of the bbox. + location code. Return the (x, y) coordinate of the bbox. - loc: a location code in range(1, 11). This corresponds to the possible values for self._loc, excluding diff --git a/lib/matplotlib/markers.py b/lib/matplotlib/markers.py index c3eec2fe4cee..d4b38738637c 100644 --- a/lib/matplotlib/markers.py +++ b/lib/matplotlib/markers.py @@ -51,7 +51,7 @@ letter ``f``. ``verts`` A list of (x, y) pairs used for Path vertices. The center of the marker is - located at (0,0) and the size is + located at (0, 0) and the size is normalized, such that the created path is encapsulated inside the unit cell. path A `~matplotlib.path.Path` instance. @@ -94,9 +94,8 @@ equally accessible via capitalized variables, like ``CARETDOWNBASE``. Hence the following are equivalent:: - plt.plot([1,2,3], marker=11) - plt.plot([1,2,3], marker=matplotlib.markers.CARETDOWNBASE) - + plt.plot([1, 2, 3], marker=11) + plt.plot([1, 2, 3], marker=matplotlib.markers.CARETDOWNBASE) Examples showing the use of markers: diff --git a/lib/matplotlib/offsetbox.py b/lib/matplotlib/offsetbox.py index 744ef48d40fb..4fc702fe94cc 100644 --- a/lib/matplotlib/offsetbox.py +++ b/lib/matplotlib/offsetbox.py @@ -713,7 +713,7 @@ def set_offset(self, xy): Parameters ---------- xy : (float, float) - The (x,y) coordinates of the offset in display units. + The (x, y) coordinates of the offset in display units. """ self._offset = xy @@ -785,7 +785,7 @@ def draw(self, renderer): class TextArea(OffsetBox): """ The TextArea is contains a single Text instance. The text is - placed at (0,0) with baseline+left alignment. The width and height + placed at (0, 0) with baseline+left alignment. The width and height of the TextArea instance is the width and height of the its child text. """ @@ -887,7 +887,7 @@ def set_offset(self, xy): Parameters ---------- xy : (float, float) - The (x,y) coordinates of the offset in display units. + The (x, y) coordinates of the offset in display units. """ self._offset = xy @@ -955,7 +955,7 @@ class AuxTransformBox(OffsetBox): transformed with the aux_transform first then will be offseted. The absolute coordinate of the aux_transform is meaning as it will be automatically adjust so that the left-lower corner - of the bounding box of children will be set to (0,0) before the + of the bounding box of children will be set to (0, 0) before the offset transform. It is similar to drawing area, except that the extent of the box @@ -1005,7 +1005,7 @@ def set_offset(self, xy): Parameters ---------- xy : (float, float) - The (x,y) coordinates of the offset in display units. + The (x, y) coordinates of the offset in display units. """ self._offset = xy @@ -1410,7 +1410,7 @@ def get_zoom(self): # Parameters # ---------- # xy : (float, float) -# The (x,y) coordinates of the offset in display units. +# The (x, y) coordinates of the offset in display units. # """ # self._offset = xy @@ -1559,7 +1559,7 @@ def anncoords(self, coords): def contains(self, event): t, tinfo = self.offsetbox.contains(event) #if self.arrow_patch is not None: - # a,ainfo=self.arrow_patch.contains(event) + # a, ainfo=self.arrow_patch.contains(event) # t = t or a # self.arrow_patch is currently not checked as this can be a line - JJ diff --git a/lib/matplotlib/patches.py b/lib/matplotlib/patches.py index c648611608d2..f133e8c5e7c0 100644 --- a/lib/matplotlib/patches.py +++ b/lib/matplotlib/patches.py @@ -803,7 +803,7 @@ def set_height(self, h): def set_bounds(self, *args): """ - Set the bounds of the rectangle: l,b,w,h + Set the bounds of the rectangle. ACCEPTS: (left, bottom, width, height) """ @@ -1256,7 +1256,7 @@ def __init__(self, x, y, dx, dy, width=0.001, length_includes_head=False, if not length: verts = np.empty([0, 2]) # display nothing if empty else: - # start by drawing horizontal arrow, point at (0,0) + # start by drawing horizontal arrow, point at (0, 0) hw, hl, hs, lw = head_width, head_length, overhang, width left_half_arrow = np.array([ [0.0, 0.0], # tip @@ -2622,12 +2622,11 @@ class ConnectionStyle(_Style): shrinkA=2., shrinkB=2.) and it returns a :class:`Path` instance. *posA* and *posB* are - tuples of x,y coordinates of the two points to be + tuples of (x, y) coordinates of the two points to be connected. *patchA* (or *patchB*) is given, the returned path is clipped so that it start (or end) from the boundary of the patch. The path is further shrunk by *shrinkA* (or *shrinkB*) which is given in points. - """ _style_list = {} @@ -3869,7 +3868,7 @@ def __init__(self, posA=None, posB=None, Parameters ---------- posA, posB : (float, float), optional (default: None) - (x,y) coordinates of arrow tail and arrow head respectively. + (x, y) coordinates of arrow tail and arrow head respectively. path : `~matplotlib.path.Path`, optional (default: None) If provided, an arrow is drawn along this path and *patchA*, @@ -4006,7 +4005,7 @@ def set_positions(self, posA, posB): Parameters ---------- posA, posB : None, tuple - (x,y) coordinates of arrow tail and arrow head respectively. If + (x, y) coordinates of arrow tail and arrow head respectively. If `None` use current value. """ if posA is not None: @@ -4243,10 +4242,8 @@ def __init__(self, xyA, xyB, coordsA, coordsB=None, """ Connect point *xyA* in *coordsA* with point *xyB* in *coordsB* - Valid keys are - =============== ====================================================== Key Description =============== ====================================================== @@ -4262,30 +4259,27 @@ def __init__(self, xyA, xyB, coordsA, coordsB=None, ? any key for :class:`matplotlib.patches.PathPatch` =============== ====================================================== - *coordsA* and *coordsB* are strings that indicate the coordinates of *xyA* and *xyB*. - ================= =================================================== - Property Description - ================= =================================================== - 'figure points' points from the lower left corner of the figure - 'figure pixels' pixels from the lower left corner of the figure - 'figure fraction' 0,0 is lower left of figure and 1,1 is upper, right - 'axes points' points from lower left corner of axes - 'axes pixels' pixels from lower left corner of axes - 'axes fraction' 0,1 is lower left of axes and 1,1 is upper right - 'data' use the coordinate system of the object being - annotated (default) - 'offset points' Specify an offset (in points) from the *xy* value - - 'polar' you can specify *theta*, *r* for the annotation, - even in cartesian plots. Note that if you - are using a polar axes, you do not need - to specify polar for the coordinate - system since that is the native "data" coordinate - system. - ================= =================================================== + ================= =================================================== + Property Description + ================= =================================================== + 'figure points' points from the lower left corner of the figure + 'figure pixels' pixels from the lower left corner of the figure + 'figure fraction' 0, 0 is lower left of figure and 1, 1 is upper right + 'axes points' points from lower left corner of axes + 'axes pixels' pixels from lower left corner of axes + 'axes fraction' 0, 1 is lower left of axes and 1, 1 is upper right + 'data' use the coordinate system of the object being + annotated (default) + 'offset points' offset (in points) from the *xy* value + 'polar' you can specify *theta*, *r* for the annotation, + even in cartesian plots. Note that if you are using + a polar axes, you do not need to specify polar for + the coordinate system since that is the native + "data" coordinate system. + ================= =================================================== Alternatively they can be set to any valid `~matplotlib.transforms.Transform`. @@ -4381,7 +4375,7 @@ def _get_xy(self, x, y, s, axes=None): y = t + y return x, y elif s == 'figure fraction': - # (0,0) is lower left, (1,1) is upper right of figure + # (0, 0) is lower left, (1, 1) is upper right of figure trans = self.figure.transFigure return trans.transform((x, y)) elif s == 'axes points': @@ -4400,8 +4394,7 @@ def _get_xy(self, x, y, s, axes=None): y = b + y * dpi / 72. return x, y elif s == 'axes pixels': - #pixels from the lower left corner of the axes - + # pixels from the lower left corner of the axes l, b, w, h = axes.bbox.bounds r = l + w t = b + h @@ -4415,7 +4408,7 @@ def _get_xy(self, x, y, s, axes=None): y = b + y return x, y elif s == 'axes fraction': - # (0,0) is lower left, (1,1) is upper right of axes + # (0, 0) is lower left, (1, 1) is upper right of axes trans = axes.transAxes return trans.transform((x, y)) elif isinstance(s, transforms.Transform): diff --git a/lib/matplotlib/projections/polar.py b/lib/matplotlib/projections/polar.py index bc6f4a6fb259..eefde4d5f27c 100644 --- a/lib/matplotlib/projections/polar.py +++ b/lib/matplotlib/projections/polar.py @@ -709,7 +709,7 @@ def _is_full_circle_rad(thetamin, thetamax): class _WedgeBbox(mtransforms.Bbox): """ - Transform (theta,r) wedge Bbox into axes bounding box. + Transform (theta, r) wedge Bbox into axes bounding box. Parameters ---------- diff --git a/lib/matplotlib/pylab.py b/lib/matplotlib/pylab.py index cb9d654950de..63ffa3e71603 100644 --- a/lib/matplotlib/pylab.py +++ b/lib/matplotlib/pylab.py @@ -88,7 +88,7 @@ subplot_tool - launch the subplot configuration tool suptitle - add a figure title table - add a table to the plot - text - add some text at location x,y to the current axes + text - add some text at location (x, y) to the current axes thetagrids - customize the radial theta grids and labels for polar tick_params - control the appearance of ticks and tick labels ticklabel_format - control the format of tick labels @@ -141,7 +141,7 @@ logspace - a log spaced vector of N values from min to max inclusive meshgrid - repeat x and y to make regular matrices ones - an array of ones - rand - an array from the uniform distribution [0,1] + rand - an array from the uniform distribution [0, 1] randn - an array from the normal distribution rot90 - rotate matrix k*90 degrees counterclockwise squeeze - squeeze an array removing any dimensions of length 1 diff --git a/lib/matplotlib/pyplot.py b/lib/matplotlib/pyplot.py index 48d85cfb72ff..4da9315eaf09 100644 --- a/lib/matplotlib/pyplot.py +++ b/lib/matplotlib/pyplot.py @@ -955,7 +955,7 @@ def subplot(*args, **kwargs): import matplotlib.pyplot as plt # plot a line, implicitly creating a subplot(111) - plt.plot([1,2,3]) + plt.plot([1, 2, 3]) # now create a subplot which represents the top plot of a grid # with 2 rows and 1 column. Since this subplot will overlap the # first, the plot (and its axes) previously created, will be removed @@ -1009,7 +1009,7 @@ def subplot(*args, **kwargs): plt.subplot(ax2) """ - # if subplot called without arguments, create subplot(1,1,1) + # if subplot called without arguments, create subplot(1, 1, 1) if len(args) == 0: args = (1, 1, 1) @@ -1690,10 +1690,10 @@ def thetagrids(*args, **kwargs): :: # set the locations of the angular gridlines - lines, labels = thetagrids( range(45,360,90) ) + lines, labels = thetagrids(range(45, 360, 90)) # set the locations and labels of the angular gridlines - lines, labels = thetagrids( range(45,360,90), ('NE', 'NW', 'SW','SE') ) + lines, labels = thetagrids(range(45, 360, 90), ('NE', 'NW', 'SW', 'SE')) See Also -------- @@ -1933,9 +1933,9 @@ def colormaps(): of perceived brightness. Also, when printed on a black and white postscript printer, the scheme results in a greyscale with monotonically increasing brightness. - This color scheme is named cubehelix because the r,g,b + This color scheme is named cubehelix because the (r, g, b) values produced can be visualised as a squashed helix - around the diagonal in the r,g,b color cube. + around the diagonal in the (r, g, b) color cube. gnuplot gnuplot's traditional pm3d scheme (black-blue-red-yellow) gnuplot2 sequential color printable as gray @@ -2227,11 +2227,11 @@ def plotfile(fname, cols=(0,), plotfuncs=None, Example usage:: # plot the 2nd and 4th column against the 1st in two subplots - plotfile(fname, (0,1,3)) + plotfile(fname, (0, 1, 3)) # plot using column names; specify an alternate plot type for volume plotfile(fname, ('date', 'volume', 'adj_close'), - plotfuncs={'volume': 'semilogy'}) + plotfuncs={'volume': 'semilogy'}) Note: plotfile is intended as a convenience for quickly plotting data from flat files; it is not intended as an alternative diff --git a/lib/matplotlib/quiver.py b/lib/matplotlib/quiver.py index e5a4a0e1e671..16f8f56db029 100644 --- a/lib/matplotlib/quiver.py +++ b/lib/matplotlib/quiver.py @@ -106,7 +106,7 @@ Use this if the arrows symbolize a quantity that is not based on *X*, *Y* data coordinates. - - 'xy': Arrows point from (x,y) to (x+u, y+v). + - 'xy': Arrows point from (x, y) to (x+u, y+v). Use this for plotting a gradient field, for example. - Alternatively, arbitrary angles may be specified explicitly as an array @@ -129,8 +129,8 @@ scale_units : {'width', 'height', 'dots', 'inches', 'x', 'y', 'xy'}, optional If the *scale* kwarg is *None*, the arrow length unit. Default is *None*. - e.g. *scale_units* is 'inches', *scale* is 2.0, and - ``(u,v) = (1,0)``, then the vector will be 0.5 inches long. + e.g. *scale_units* is 'inches', *scale* is 2.0, and ``(u, v) = (1, 0)``, + then the vector will be 0.5 inches long. If *scale_units* is 'width' or 'height', then the vector will be half the width/height of the axes. @@ -222,11 +222,11 @@ def __init__(self, Q, X, Y, U, label, x-axis. coordinates : {'axes', 'figure', 'data', 'inches'}, default: 'axes' Coordinate system and units for *X*, *Y*: 'axes' and 'figure' are - normalized coordinate systems with 0,0 in the lower left and 1,1 - in the upper right; 'data' are the axes data coordinates (used for - the locations of the vectors in the quiver plot itself); 'inches' - is position in the figure in inches, with 0,0 at the lower left - corner. + normalized coordinate systems with (0, 0) in the lower left and + (1, 1) in the upper right; 'data' are the axes data coordinates + (used for the locations of the vectors in the quiver plot itself); + 'inches' is position in the figure in inches, with (0, 0) at the + lower left corner. color : color Overrides face and edge colors from *Q*. labelpos : {'N', 'S', 'E', 'W'} @@ -716,7 +716,7 @@ def _make_verts(self, U, V, angles): def _h_arrows(self, length): """Length is in arrow width units.""" # It might be possible to streamline the code - # and speed it up a bit by using complex (x,y) + # and speed it up a bit by using complex (x, y) # instead of separate arrays; but any gain would be slight. minsh = self.minshaft * self.headlength N = len(length) diff --git a/lib/matplotlib/sankey.py b/lib/matplotlib/sankey.py index 9a9e085c8242..35cd141b733c 100644 --- a/lib/matplotlib/sankey.py +++ b/lib/matplotlib/sankey.py @@ -189,7 +189,7 @@ def _arc(self, quadrant=0, cw=True, radius=1, center=(0, 0)): Path.CURVE4, Path.CURVE4] # Vertices of a cubic Bezier curve approximating a 90 deg arc - # These can be determined by Path.arc(0,90). + # These can be determined by Path.arc(0, 90). ARC_VERTICES = np.array([[1.00000000e+00, 0.00000000e+00], [1.00000000e+00, 2.65114773e-01], [8.94571235e-01, 5.19642327e-01], diff --git a/lib/matplotlib/sphinxext/plot_directive.py b/lib/matplotlib/sphinxext/plot_directive.py index eed8c0c626cd..31dc1a6ff414 100644 --- a/lib/matplotlib/sphinxext/plot_directive.py +++ b/lib/matplotlib/sphinxext/plot_directive.py @@ -38,7 +38,7 @@ .. plot:: A plotting example: >>> import matplotlib.pyplot as plt - >>> plt.plot([1,2,3], [4,5,6]) + >>> plt.plot([1, 2, 3], [4, 5, 6]) Options ------- diff --git a/lib/matplotlib/streamplot.py b/lib/matplotlib/streamplot.py index 4063f9f657fd..f8e431d20a2f 100644 --- a/lib/matplotlib/streamplot.py +++ b/lib/matplotlib/streamplot.py @@ -113,8 +113,8 @@ def streamplot(axes, x, y, u, v, density=1, linewidth=None, color=None, use_multicolor_lines = isinstance(color, np.ndarray) if use_multicolor_lines: if color.shape != grid.shape: - raise ValueError( - "If 'color' is given, must have the shape of 'Grid(x,y)'") + raise ValueError("If 'color' is given, it must match the shape of " + "'Grid(x, y)'") line_colors = [] color = np.ma.masked_invalid(color) else: @@ -123,8 +123,8 @@ def streamplot(axes, x, y, u, v, density=1, linewidth=None, color=None, if isinstance(linewidth, np.ndarray): if linewidth.shape != grid.shape: - raise ValueError( - "If 'linewidth' is given, must have the shape of 'Grid(x,y)'") + raise ValueError("If 'linewidth' is given, it must match the " + "shape of 'Grid(x, y)'") line_kw['linewidth'] = [] else: line_kw['linewidth'] = linewidth @@ -135,7 +135,7 @@ def streamplot(axes, x, y, u, v, density=1, linewidth=None, color=None, ## Sanity checks. if u.shape != grid.shape or v.shape != grid.shape: - raise ValueError("'u' and 'v' must be of shape 'Grid(x,y)'") + raise ValueError("'u' and 'v' must match the shape of 'Grid(x, y)'") u = np.ma.masked_invalid(u) v = np.ma.masked_invalid(v) diff --git a/lib/matplotlib/table.py b/lib/matplotlib/table.py index 24fb7bdcdf94..9a1bee6b0849 100644 --- a/lib/matplotlib/table.py +++ b/lib/matplotlib/table.py @@ -421,9 +421,11 @@ def draw(self, renderer): self.stale = False def _get_grid_bbox(self, renderer): - """Get a bbox, in axes co-ordinates for the cells. + """ + Get a bbox, in axes co-ordinates for the cells. - Only include those in the range (0,0) to (maxRow, maxCol)""" + Only include those in the range (0, 0) to (maxRow, maxCol). + """ boxes = [cell.get_window_extent(renderer) for (row, col), cell in self._cells.items() if row >= 0 and col >= 0] diff --git a/lib/matplotlib/tests/test_artist.py b/lib/matplotlib/tests/test_artist.py index 4f097e92e1dc..5a987ec01808 100644 --- a/lib/matplotlib/tests/test_artist.py +++ b/lib/matplotlib/tests/test_artist.py @@ -24,7 +24,7 @@ def test_patch_transform_of_none(): ax.set_xlim([1, 3]) ax.set_ylim([1, 3]) - # Draw an ellipse over data coord (2,2) by specifying device coords. + # Draw an ellipse over data coord (2, 2) by specifying device coords. xy_data = (2, 2) xy_pix = ax.transData.transform(xy_data) @@ -66,7 +66,7 @@ def test_collection_transform_of_none(): ax.set_xlim([1, 3]) ax.set_ylim([1, 3]) - # draw an ellipse over data coord (2,2) by specifying device coords + # draw an ellipse over data coord (2, 2) by specifying device coords xy_data = (2, 2) xy_pix = ax.transData.transform(xy_data) diff --git a/lib/matplotlib/tests/test_mlab.py b/lib/matplotlib/tests/test_mlab.py index d238651e2d02..9447cfb3707c 100644 --- a/lib/matplotlib/tests/test_mlab.py +++ b/lib/matplotlib/tests/test_mlab.py @@ -2184,8 +2184,8 @@ def test_evaluate_diff_dim(self): def test_evaluate_inv_dim(self): """ - Invert the dimensions; i.e., for a dataset of dimension 1 [3,2,4], the - points should have a dimension of 3 [[3],[2],[4]]. + Invert the dimensions; i.e., for a dataset of dimension 1 [3, 2, 4], + the points should have a dimension of 3 [[3], [2], [4]]. """ np.random.seed(8765678) n_basesample = 50 diff --git a/lib/matplotlib/tests/test_preprocess_data.py b/lib/matplotlib/tests/test_preprocess_data.py index 62a4af623a1d..28f6cc416cac 100644 --- a/lib/matplotlib/tests/test_preprocess_data.py +++ b/lib/matplotlib/tests/test_preprocess_data.py @@ -227,7 +227,7 @@ def funcy(ax, x, y, z, bar=None): """Funcy does nothing""" pass - # lists can print in any order, so test for both x,bar and bar,x + # lists can print in any order, so test for both x, bar and bar, x. assert re.search(r".*All arguments with the following names: '.*', '.*'\.", funcy.__doc__) assert re.search(r".*'x'.*", funcy.__doc__) diff --git a/lib/matplotlib/tests/test_ticker.py b/lib/matplotlib/tests/test_ticker.py index 4859fff48b56..6408d231159d 100644 --- a/lib/matplotlib/tests/test_ticker.py +++ b/lib/matplotlib/tests/test_ticker.py @@ -645,7 +645,7 @@ def test_sublabel(self): self._sub_labels(ax.xaxis, subs=[]) # For the next two, if the numdec threshold in LogFormatter.set_locs - # were 3, then the label sub would be 3 for 2-3 decades and (2,5) + # were 3, then the label sub would be 3 for 2-3 decades and (2, 5) # for 1-2 decades. With a threshold of 1, subs are not labeled. # axis range at 2 to 3 decades ax.set_xlim(1, 800) diff --git a/lib/matplotlib/texmanager.py b/lib/matplotlib/texmanager.py index f2470ff038ec..946c6d522a3c 100644 --- a/lib/matplotlib/texmanager.py +++ b/lib/matplotlib/texmanager.py @@ -22,7 +22,7 @@ texmanager = TexManager() s = ('\TeX\ is Number ' '$\displaystyle\sum_{n=1}^\infty\frac{-e^{i\pi}}{2^n}$!') - Z = texmanager.get_rgba(s, fontsize=12, dpi=80, rgb=(1,0,0)) + Z = texmanager.get_rgba(s, fontsize=12, dpi=80, rgb=(1, 0, 0)) To enable tex rendering of all text in your matplotlib figure, set :rc:`text.usetex` to True. diff --git a/lib/matplotlib/text.py b/lib/matplotlib/text.py index 052c9eb50418..70af842f8ad2 100644 --- a/lib/matplotlib/text.py +++ b/lib/matplotlib/text.py @@ -418,7 +418,7 @@ def _get_layout(self, renderer): bbox = Bbox.from_bounds(xmin, ymin, width, height) - # now rotate the positions around the first x,y position + # now rotate the positions around the first (x, y) position xys = M.transform(offset_layout) - (offsetx, offsety) ret = bbox, list(zip(lines, zip(ws, hs), *xys.T)), descent @@ -1336,7 +1336,7 @@ def __init__(self, linespacing=linespacing, ) - # The position (x,y) values for text and dashline + # The position (x, y) values for text and dashline # are bogus as given in the instantiation; they will # be set correctly by update_coords() in draw() @@ -1986,10 +1986,10 @@ def __init__(self, text, xy, parameter. xy : (float, float) - The point *(x,y)* to annotate. + The point *(x, y)* to annotate. xytext : (float, float), optional - The position *(x,y)* to place the text at. + The position *(x, y)* to place the text at. If *None*, defaults to *xy*. xycoords : str, `.Artist`, `.Transform`, callable or tuple, optional @@ -2010,7 +2010,7 @@ def __init__(self, text, xy, 'axes fraction' Fraction of axes from lower left 'data' Use the coordinate system of the object being annotated (default) - 'polar' *(theta,r)* if not native 'data' coordinates + 'polar' *(theta, r)* if not native 'data' coordinates ================= ============================================= - An `.Artist`: *xy* is interpreted as a fraction of the artists @@ -2278,7 +2278,7 @@ def _update_position_xytext(self, renderer, xy_pixel): self.arrow_patch.set_arrowstyle('simple', **stylekw) # using YAArrow style: - # pick the x,y corner of the text bbox closest to point + # pick the (x, y) corner of the text bbox closest to point # annotated xpos = ((l, 0), (xc, 0.5), (r, 1)) ypos = ((b, 0), (yc, 0.5), (t, 1)) diff --git a/lib/matplotlib/ticker.py b/lib/matplotlib/ticker.py index 0fa42d958b29..e48dacd13f3b 100644 --- a/lib/matplotlib/ticker.py +++ b/lib/matplotlib/ticker.py @@ -505,12 +505,12 @@ class ScalarFormatter(Formatter): average, then an offset will be determined such that the tick labels are meaningful. Scientific notation is used for ``data < 10^-n`` or ``data >= 10^m``, where ``n`` and ``m`` are the power limits set - using ``set_powerlimits((n,m))``. The defaults for these are + using ``set_powerlimits((n, m))``. The defaults for these are controlled by the ``axes.formatter.limits`` rc parameter. """ def __init__(self, useOffset=None, useMathText=None, useLocale=None): # useOffset allows plotting small data ranges with large offsets: for - # example: [1+1e-9,1+2e-9,1+3e-9] useMathText will render the offset + # example: [1+1e-9, 1+2e-9, 1+3e-9] useMathText will render the offset # and scientific notation in mathtext if useOffset is None: diff --git a/lib/matplotlib/transforms.py b/lib/matplotlib/transforms.py index 72c35bba8e12..335d9f73518c 100644 --- a/lib/matplotlib/transforms.py +++ b/lib/matplotlib/transforms.py @@ -1537,7 +1537,7 @@ def transform_angles(self, angles, pts, radians=False, pushoff=1e-5): raise ValueError("'angles' must be a column vector and have same " "number of rows as 'pts'") if pts.shape[1] != 2: - raise ValueError("'pts' must be array with 2 columns for x,y") + raise ValueError("'pts' must be array with 2 columns for x, y") # Convert to radians if desired if not radians: angles = np.deg2rad(angles) diff --git a/lib/matplotlib/tri/triangulation.py b/lib/matplotlib/tri/triangulation.py index 2b7fcaf50b2c..df66d9319a0b 100644 --- a/lib/matplotlib/tri/triangulation.py +++ b/lib/matplotlib/tri/triangulation.py @@ -182,14 +182,13 @@ def get_trifinder(self): @property def neighbors(self): """ - Return integer array of shape (ntri, 3) containing neighbor - triangles. + Return integer array of shape (ntri, 3) containing neighbor triangles. For each triangle, the indices of the three triangles that share the same edges, or -1 if there is no such neighboring - triangle. neighbors[i,j] is the triangle that is the neighbor - to the edge from point index triangles[i,j] to point index - triangles[i,(j+1)%3]. + triangle. ``neighbors[i, j]`` is the triangle that is the neighbor + to the edge from point index ``triangles[i,j]`` to point index + ``triangles[i,(j+1)%3]``. """ if self._neighbors is None: self._neighbors = self.get_cpp_triangulation().get_neighbors() diff --git a/lib/matplotlib/tri/tricontour.py b/lib/matplotlib/tri/tricontour.py index 4b6e0f52c73a..1fa79b859fef 100644 --- a/lib/matplotlib/tri/tricontour.py +++ b/lib/matplotlib/tri/tricontour.py @@ -194,19 +194,19 @@ def tricontour(ax, *args, **kwargs): *origin*: [ *None* | 'upper' | 'lower' | 'image' ] If *None*, the first value of *Z* will correspond to the - lower left corner, location (0,0). If 'image', the rc + lower left corner, location (0, 0). If 'image', the rc value for ``image.origin`` will be used. This keyword is not active if *X* and *Y* are specified in the call to contour. - *extent*: [ *None* | (x0,x1,y0,y1) ] + *extent*: [ *None* | (x0, x1, y0, y1) ] If *origin* is not *None*, then *extent* is interpreted as in :func:`matplotlib.pyplot.imshow`: it gives the outer - pixel boundaries. In this case, the position of Z[0,0] + pixel boundaries. In this case, the position of Z[0, 0] is the center of the pixel, not a corner. If *origin* is - *None*, then (*x0*, *y0*) is the position of Z[0,0], and + *None*, then (*x0*, *y0*) is the position of Z[0, 0], and (*x1*, *y1*) is the position of Z[-1,-1]. This keyword is not active if *X* and *Y* are specified in diff --git a/lib/matplotlib/tri/trifinder.py b/lib/matplotlib/tri/trifinder.py index ae7b803793f5..4c12171b19a5 100644 --- a/lib/matplotlib/tri/trifinder.py +++ b/lib/matplotlib/tri/trifinder.py @@ -7,13 +7,13 @@ class TriFinder: """ Abstract base class for classes used to find the triangles of a - Triangulation in which (x,y) points lie. + Triangulation in which (x, y) points lie. Rather than instantiate an object of a class derived from TriFinder, it is usually better to use the function :func:`matplotlib.tri.Triangulation.get_trifinder`. - Derived classes implement __call__(x,y) where x,y are array_like point + Derived classes implement __call__(x, y) where x and y are array_like point coordinates of the same shape. """ def __init__(self, triangulation): @@ -43,8 +43,8 @@ def __init__(self, triangulation): def __call__(self, x, y): """ Return an array containing the indices of the triangles in which the - specified x,y points lie, or -1 for points that do not lie within a - triangle. + specified *x*, *y* points lie, or -1 for points that do not lie within + a triangle. *x*, *y* are array_like x and y coordinates of the same shape and any number of dimensions. diff --git a/lib/matplotlib/tri/triinterpolate.py b/lib/matplotlib/tri/triinterpolate.py index 8f22159bf17f..569d84df445c 100644 --- a/lib/matplotlib/tri/triinterpolate.py +++ b/lib/matplotlib/tri/triinterpolate.py @@ -62,7 +62,7 @@ def __init__(self, triangulation, z, trifinder=None): # confusion in the documentation. _docstring__call__ = """ Returns a masked array containing interpolated values at the specified - x,y points. + (x, y) points. Parameters ---------- @@ -80,7 +80,7 @@ def __init__(self, triangulation, z, trifinder=None): _docstringgradient = r""" Returns a list of 2 masked arrays containing interpolated derivatives - at the specified x,y points. + at the specified (x, y) points. Parameters ---------- @@ -92,7 +92,7 @@ def __init__(self, triangulation, z, trifinder=None): ------- dzdx, dzdy : np.ma.array 2 masked arrays of the same shape as *x* and *y*; values - corresponding to (x,y) points outside of the triangulation + corresponding to (x, y) points outside of the triangulation are masked out. The first returned array contains the values of :math:`\frac{\partial z}{\partial x}` and the second those of @@ -236,7 +236,7 @@ class LinearTriInterpolator(TriInterpolator): A LinearTriInterpolator performs linear interpolation on a triangular grid. Each triangle is represented by a plane so that an interpolated value at - point (x,y) lies on the plane of the triangle containing (x,y). + point (x, y) lies on the plane of the triangle containing (x, y). Interpolated values are therefore continuous across the triangulation, but their first derivatives are discontinuous at edges between triangles. @@ -253,8 +253,8 @@ class LinearTriInterpolator(TriInterpolator): Methods ------- - `__call__` (x, y) : Returns interpolated values at x,y points - `gradient` (x, y) : Returns interpolated derivatives at x,y points + `__call__` (x, y) : Returns interpolated values at (x, y) points. + `gradient` (x, y) : Returns interpolated derivatives at (x, y) points. """ def __init__(self, triangulation, z, trifinder=None): @@ -333,8 +333,8 @@ class CubicTriInterpolator(TriInterpolator): Methods ------- - `__call__` (x, y) : Returns interpolated values at x,y points - `gradient` (x, y) : Returns interpolated derivatives at x,y points + `__call__` (x, y) : Returns interpolated values at (x, y) points. + `gradient` (x, y) : Returns interpolated derivatives at (x, y) points. Notes ----- @@ -467,7 +467,7 @@ def _compute_dof(self, kind, dz=None): Returns ------- - dof : array_like, shape (npts,2) + dof : array_like, shape (npts, 2) Estimation of the gradient at triangulation nodes (stored as degree of freedoms of reduced-HCT triangle elements). """ @@ -497,12 +497,12 @@ def _get_alpha_vec(x, y, tris_pts): x, y : array-like of dim 1 (shape (nx,)) Coordinates of the points whose points barycentric coordinates are requested - tris_pts : array like of dim 3 (shape: (nx,3,2)) + tris_pts : array like of dim 3 (shape: (nx, 3, 2)) Coordinates of the containing triangles apexes. Returns ------- - alpha : array of dim 2 (shape (nx,3)) + alpha : array of dim 2 (shape (nx, 3)) Barycentric coordinates of the points inside the containing triangles. """ @@ -534,12 +534,12 @@ def _get_jacobian(tris_pts): Parameters ---------- - tris_pts : array like of dim 3 (shape: (nx,3,2)) + tris_pts : array like of dim 3 (shape: (nx, 3, 2)) Coordinates of the containing triangles apexes. Returns ------- - J : array of dim 3 (shape (nx,2,2)) + J : array of dim 3 (shape (nx, 2, 2)) Barycentric coordinates of the points inside the containing triangles. J[itri,:,:] is the jacobian matrix at apex 0 of the triangle @@ -562,12 +562,12 @@ def _compute_tri_eccentricities(tris_pts): Parameters ---------- - tris_pts : array like of dim 3 (shape: (nx,3,2)) + tris_pts : array like of dim 3 (shape: (nx, 3, 2)) Coordinates of the triangles apexes. Returns ------- - ecc : array like of dim 2 (shape: (nx,3)) + ecc : array like of dim 2 (shape: (nx, 3)) The so-called eccentricity parameters [1] needed for HCT triangular element. """ @@ -1048,7 +1048,7 @@ def get_dof_vec(tri_z, tri_dz, J): of the local Jacobian at each node. *tri_z*: array of shape (3,) of f nodal values - *tri_dz*: array of shape (3,2) of df/dx, df/dy nodal values + *tri_dz*: array of shape (3, 2) of df/dx, df/dy nodal values *J*: Jacobian matrix in local basis of apex 0 Returns dof array of shape (9,) so that for each apex iapex: @@ -1145,7 +1145,7 @@ def compute_geom_weights(self): def compute_geom_grads(self): """ Compute the (global) gradient component of f assumed linear (~f). - returns array df of shape (nelems,2) + returns array df of shape (nelems, 2) df[ielem].dM[ielem] = dz[ielem] i.e. df = dz x dM = dM.T^-1 x dz """ tris_pts = self._tris_pts @@ -1235,7 +1235,7 @@ def __init__(self, vals, rows, cols, shape): *vals*: arrays of values of non-null entries of the matrix *rows*: int arrays of rows of non-null entries of the matrix *cols*: int arrays of cols of non-null entries of the matrix - *shape*: 2-tuple (n,m) of matrix shape + *shape*: 2-tuple (n, m) of matrix shape """ self.n, self.m = shape @@ -1387,7 +1387,7 @@ def _cg(A, b, x0=None, tol=1.e-10, maxiter=1000): # matrices - stored as (:, n_rows, n_cols)-shaped np.arrays. # Development note: Dealing with pathologic 'flat' triangles in the -# CubicTriInterpolator code and impact on (2,2)-matrix inversion functions +# CubicTriInterpolator code and impact on (2, 2)-matrix inversion functions # :func:`_safe_inv22_vectorized` and :func:`_pseudo_inv22sym_vectorized`. # # Goals: @@ -1423,10 +1423,10 @@ def _cg(A, b, x0=None, tol=1.e-10, maxiter=1000): # to compute a pseudo-inverse in :func:`_pseudo_inv22sym_vectorized` def _safe_inv22_vectorized(M): """ - Inversion of arrays of (2,2) matrices, returns 0 for rank-deficient + Inversion of arrays of (2, 2) matrices, returns 0 for rank-deficient matrices. - *M* : array of (2,2) matrices to inverse, shape (n,2,2) + *M* : array of (2, 2) matrices to inverse, shape (n, 2, 2) """ assert M.ndim == 3 assert M.shape[-2:] == (2, 2) @@ -1454,14 +1454,14 @@ def _safe_inv22_vectorized(M): def _pseudo_inv22sym_vectorized(M): """ - Inversion of arrays of (2,2) SYMMETRIC matrices; returns the + Inversion of arrays of (2, 2) SYMMETRIC matrices; returns the (Moore-Penrose) pseudo-inverse for rank-deficient matrices. In case M is of rank 1, we have M = trace(M) x P where P is the orthogonal projection on Im(M), and we return trace(M)^-1 x P == M / trace(M)**2 In case M is of rank 0, we return the null matrix. - *M* : array of (2,2) matrices to inverse, shape (n,2,2) + *M* : array of (2, 2) matrices to inverse, shape (n, 2, 2) """ assert M.ndim == 3 assert M.shape[-2:] == (2, 2) @@ -1566,7 +1566,7 @@ def _to_matrix_vectorized(M): *M*: ncols-list of nrows-lists of shape sh. Returns M_res np.array of shape (sh, nrow, ncols) so that: - M_res[...,i,j] = M[i][j] + M_res[..., i, j] = M[i][j] """ assert isinstance(M, (tuple, list)) assert all(isinstance(item, (tuple, list)) for item in M) diff --git a/lib/matplotlib/tri/trirefine.py b/lib/matplotlib/tri/trirefine.py index 9f251567c744..858386ae5798 100644 --- a/lib/matplotlib/tri/trirefine.py +++ b/lib/matplotlib/tri/trirefine.py @@ -200,9 +200,9 @@ def _refine_triangulation_once(triangulation, ancestors=None): y = triangulation.y # According to tri.triangulation doc: - # neighbors[i,j] is the triangle that is the neighbor - # to the edge from point index masked_triangles[i,j] to point - # index masked_triangles[i,(j+1)%3]. + # neighbors[i, j] is the triangle that is the neighbor + # to the edge from point index masked_triangles[i, j] to point + # index masked_triangles[i, (j+1)%3]. neighbors = triangulation.neighbors triangles = triangulation.triangles npts = np.shape(x)[0] diff --git a/lib/matplotlib/widgets.py b/lib/matplotlib/widgets.py index d64c91a8d278..644f662c361f 100644 --- a/lib/matplotlib/widgets.py +++ b/lib/matplotlib/widgets.py @@ -2381,11 +2381,11 @@ def _set_active_handle(self, event): @property def geometry(self): """ - Returns numpy.ndarray of shape (2,5) containing - x (``RectangleSelector.geometry[1,:]``) and - y (``RectangleSelector.geometry[0,:]``) - coordinates of the four corners of the rectangle starting - and ending in the top left corner. + Return an array of shape (2, 5) containing the + x (``RectangleSelector.geometry[1, :]``) and + y (``RectangleSelector.geometry[0, :]``) coordinates + of the four corners of the rectangle starting and ending + in the top left corner. """ if hasattr(self.to_draw, 'get_verts'): xfm = self.ax.transData.inverted() @@ -2482,7 +2482,7 @@ class LassoSelector(_SelectorWidget): Example usage:: ax = subplot(111) - ax.plot(x,y) + ax.plot(x, y) def onselect(verts): print(verts) diff --git a/lib/mpl_toolkits/axes_grid1/anchored_artists.py b/lib/mpl_toolkits/axes_grid1/anchored_artists.py index a769c7fd3861..cc93967f3a11 100644 --- a/lib/mpl_toolkits/axes_grid1/anchored_artists.py +++ b/lib/mpl_toolkits/axes_grid1/anchored_artists.py @@ -144,7 +144,7 @@ def __init__(self, transform, loc, height of 0.4 in data coordinates: >>> box = AnchoredAuxTransformBox(ax.transData, loc='upper left') - >>> el = Ellipse((0,0), width=0.1, height=0.4, angle=30) + >>> el = Ellipse((0, 0), width=0.1, height=0.4, angle=30) >>> box.drawing_area.add_artist(el) >>> ax.add_artist(box) """ @@ -320,7 +320,7 @@ def __init__(self, transform, size, label, loc, >>> from mpl_toolkits.axes_grid1.anchored_artists import ( ... AnchoredSizeBar) >>> fig, ax = plt.subplots() - >>> ax.imshow(np.random.random((10,10))) + >>> ax.imshow(np.random.random((10, 10))) >>> bar = AnchoredSizeBar(ax.transData, 3, '3 data units', 4) >>> ax.add_artist(bar) >>> fig.show() @@ -503,7 +503,7 @@ def __init__(self, transform, label_x, label_y, length=0.15, >>> from mpl_toolkits.axes_grid1.anchored_artists import ( ... AnchoredDirectionArrows) >>> fig, ax = plt.subplots() - >>> ax.imshow(np.random.random((10,10))) + >>> ax.imshow(np.random.random((10, 10))) >>> arrows = AnchoredDirectionArrows(ax.transAxes, '111', '110') >>> ax.add_artist(arrows) >>> fig.show() diff --git a/lib/mpl_toolkits/axes_grid1/axes_divider.py b/lib/mpl_toolkits/axes_grid1/axes_divider.py index 6a4f96303801..05f272ce95aa 100644 --- a/lib/mpl_toolkits/axes_grid1/axes_divider.py +++ b/lib/mpl_toolkits/axes_grid1/axes_divider.py @@ -390,7 +390,7 @@ def __init__(self, fig, *args, horizontal=None, vertical=None, # total = rows*cols # num -= 1 # convert from matlab to python indexing - # # i.e., num in range(0,total) + # # i.e., num in range(0, total) # if num >= total: # raise ValueError( 'Subplot number exceeds total subplots') # self._rows = rows @@ -445,28 +445,27 @@ def get_position(self): # figW, figH) def update_params(self): - 'update the subplot position from fig.subplotpars' - + """Update the subplot position from fig.subplotpars.""" self.figbox = self.get_subplotspec().get_position(self.figure) def get_geometry(self): - 'get the subplot geometry, e.g., 2,2,3' + """Get the subplot geometry, e.g., (2, 2, 3).""" rows, cols, num1, num2 = self.get_subplotspec().get_geometry() return rows, cols, num1+1 # for compatibility # COVERAGE NOTE: Never used internally or from examples def change_geometry(self, numrows, numcols, num): - 'change subplot geometry, e.g., from 1,1,1 to 2,2,3' + """Change subplot geometry, e.g., from (1, 1, 1) to (2, 2, 3).""" self._subplotspec = GridSpec(numrows, numcols)[num-1] self.update_params() self.set_position(self.figbox) def get_subplotspec(self): - 'get the SubplotSpec instance' + """Get the SubplotSpec instance.""" return self._subplotspec def set_subplotspec(self, subplotspec): - 'set the SubplotSpec instance' + """Set the SubplotSpec instance.""" self._subplotspec = subplotspec diff --git a/lib/mpl_toolkits/axes_grid1/inset_locator.py b/lib/mpl_toolkits/axes_grid1/inset_locator.py index 4629896c8647..f64726fdbc72 100644 --- a/lib/mpl_toolkits/axes_grid1/inset_locator.py +++ b/lib/mpl_toolkits/axes_grid1/inset_locator.py @@ -503,7 +503,7 @@ def inset_axes(parent_axes, width, height, loc='upper right', cbook._warn_external("Using the axes or figure transform " "requires a bounding box in the respective " "coordinates. " - "Using bbox_to_anchor=(0,0,1,1) now.") + "Using bbox_to_anchor=(0, 0, 1, 1) now.") bbox_to_anchor = (0, 0, 1, 1) if bbox_to_anchor is None: diff --git a/lib/mpl_toolkits/axisartist/floating_axes.py b/lib/mpl_toolkits/axisartist/floating_axes.py index 393031db495c..f635df099592 100644 --- a/lib/mpl_toolkits/axisartist/floating_axes.py +++ b/lib/mpl_toolkits/axisartist/floating_axes.py @@ -294,7 +294,7 @@ def get_gridlines(self, which="major", axis="both"): def get_boundary(self): """ - return Nx2 array of x,y coordinate of the boundary + Return (N, 2) array of (x, y) coordinate of the boundary. """ x0, x1, y0, y1 = self._extremes tr = self._aux_trans diff --git a/lib/mpl_toolkits/mplot3d/axes3d.py b/lib/mpl_toolkits/mplot3d/axes3d.py index 26d12fabc5e4..6c6e047c9f37 100644 --- a/lib/mpl_toolkits/mplot3d/axes3d.py +++ b/lib/mpl_toolkits/mplot3d/axes3d.py @@ -966,7 +966,7 @@ def view_init(self, elev=None, azim=None): This can be used to rotate the axes programmatically. 'elev' stores the elevation angle in the z plane (in degrees). - 'azim' stores the azimuth angle in the x,y plane (in degrees). + 'azim' stores the azimuth angle in the (x, y) plane (in degrees). if elev or azim are None (default), then the initial value is used which was specified in the :class:`Axes3D` constructor. @@ -1002,11 +1002,9 @@ def get_proj(self): Create the projection matrix from the current viewing position. elev stores the elevation angle in the z plane - azim stores the azimuth angle in the x,y plane - - dist is the distance of the eye viewing point from the object - point. + azim stores the azimuth angle in the (x, y) plane + dist is the distance of the eye viewing point from the object point. """ relev, razim = np.pi * self.elev/180, np.pi * self.azim/180 @@ -1014,7 +1012,7 @@ def get_proj(self): ymin, ymax = self.get_ylim3d() zmin, zmax = self.get_zlim3d() - # transform to uniform world coordinates 0-1.0,0-1.0,0-1.0 + # transform to uniform world coordinates 0-1, 0-1, 0-1 worldM = proj3d.world_transformation(xmin, xmax, ymin, ymax, zmin, zmax) @@ -1219,7 +1217,7 @@ def _on_move(self, event): # elif self.button_pressed == 2: # pan view - # project xv,yv,zv -> xw,yw,zw + # project xv, yv, zv -> xw, yw, zw # pan # pass @@ -2609,7 +2607,7 @@ def quiver(self, *args, normalize : bool When True, all of the arrows will be the same length. This defaults to False, where the arrows will be different lengths - depending on the values of u,v,w. + depending on the values of u, v, w. **kwargs Any additional keyword arguments are delegated to @@ -2620,7 +2618,7 @@ def calc_arrow(uvw, angle=15): To calculate the arrow head. uvw should be a unit vector. We normalize it here: """ - # get unit direction vector perpendicular to (u,v,w) + # get unit direction vector perpendicular to (u, v, w) norm = np.linalg.norm(uvw[:2]) if norm > 0: x = uvw[1] / norm @@ -2734,9 +2732,9 @@ def voxels(self, *args, facecolors=None, edgecolors=None, shade=True, Plot a set of filled voxels - All voxels are plotted as 1x1x1 cubes on the axis, with filled[0,0,0] - placed with its lower corner at the origin. Occluded faces are not - plotted. + All voxels are plotted as 1x1x1 cubes on the axis, with + ``filled[0, 0, 0]`` placed with its lower corner at the origin. + Occluded faces are not plotted. .. versionadded:: 2.1 @@ -2788,11 +2786,11 @@ def voxels(self, *args, facecolors=None, edgecolors=None, shade=True, Returns ------- faces : dict - A dictionary indexed by coordinate, where ``faces[i,j,k]`` is a + A dictionary indexed by coordinate, where ``faces[i, j, k]`` is a `Poly3DCollection` of the faces drawn for the voxel - ``filled[i,j,k]``. If no faces were drawn for a given voxel, either - because it was not asked to be drawn, or it is fully occluded, then - ``(i,j,k) not in faces``. + ``filled[i, j, k]``. If no faces were drawn for a given voxel, + either because it was not asked to be drawn, or it is fully + occluded, then ``(i, j, k) not in faces``. Examples -------- diff --git a/lib/mpl_toolkits/mplot3d/proj3d.py b/lib/mpl_toolkits/mplot3d/proj3d.py index e9081b9a6e51..65d3081df4de 100644 --- a/lib/mpl_toolkits/mplot3d/proj3d.py +++ b/lib/mpl_toolkits/mplot3d/proj3d.py @@ -98,12 +98,12 @@ def view_transformation(E, R, V): n = (E - R) ## new # n /= np.linalg.norm(n) -# u = np.cross(V,n) +# u = np.cross(V, n) # u /= np.linalg.norm(u) -# v = np.cross(n,u) -# Mr = np.diag([1.]*4) -# Mt = np.diag([1.]*4) -# Mr[:3,:3] = u,v,n +# v = np.cross(n, u) +# Mr = np.diag([1.] * 4) +# Mt = np.diag([1.] * 4) +# Mr[:3,:3] = u, v, n # Mt[:3,-1] = -E ## end new @@ -209,7 +209,7 @@ def proj_transform_clip(xs, ys, zs, M): """ Transform the points by the projection matrix and return the clipping result - returns txs,tys,tzs,tis + returns txs, tys, tzs, tis """ vec = _vec_pad_ones(xs, ys, zs) return _proj_transform_vec_clip(vec, M) diff --git a/tutorials/advanced/path_tutorial.py b/tutorials/advanced/path_tutorial.py index e0444c5e1cae..7d67b05b38bb 100644 --- a/tutorials/advanced/path_tutorial.py +++ b/tutorials/advanced/path_tutorial.py @@ -9,9 +9,9 @@ the :class:`~matplotlib.path.Path`, which supports the standard set of moveto, lineto, curveto commands to draw simple and compound outlines consisting of line segments and splines. The ``Path`` is instantiated -with a (N,2) array of (x,y) vertices, and a N-length array of path -codes. For example to draw the unit rectangle from (0,0) to (1,1), we -could use this code +with a (N, 2) array of (x, y) vertices, and a N-length array of path +codes. For example to draw the unit rectangle from (0, 0) to (1, 1), we +could use this code: """ import matplotlib.pyplot as plt @@ -159,14 +159,14 @@ # codes = np.ones(nverts, int) * path.Path.LINETO # codes[0::5] = path.Path.MOVETO # codes[4::5] = path.Path.CLOSEPOLY -# verts[0::5,0] = left -# verts[0::5,1] = bottom -# verts[1::5,0] = left -# verts[1::5,1] = top -# verts[2::5,0] = right -# verts[2::5,1] = top -# verts[3::5,0] = right -# verts[3::5,1] = bottom +# verts[0::5, 0] = left +# verts[0::5, 1] = bottom +# verts[1::5, 0] = left +# verts[1::5, 1] = top +# verts[2::5, 0] = right +# verts[2::5, 1] = top +# verts[3::5, 0] = right +# verts[3::5, 1] = bottom # # All that remains is to create the path, attach it to a # :class:`~matplotlib.patch.PathPatch`, and add it to our axes:: diff --git a/tutorials/colors/colorbar_only.py b/tutorials/colors/colorbar_only.py index 9f9f3e948ecd..e22431eb2651 100644 --- a/tutorials/colors/colorbar_only.py +++ b/tutorials/colors/colorbar_only.py @@ -48,7 +48,7 @@ # set of listed colors, :func:`colors.BoundaryNorm` which generates a colormap # index based on discrete intervals and extended ends to show the "over" and # "under" value colors. Over and under are used to display data outside of the -# normalized [0,1] range. Here we pass colors as gray shades as a string +# normalized [0, 1] range. Here we pass colors as gray shades as a string # encoding a float in the 0-1 range. # # If a :class:`~matplotlib.colors.ListedColormap` is used, the length of the diff --git a/tutorials/colors/colormapnorms.py b/tutorials/colors/colormapnorms.py index c5929ad1f025..4ef2498c9a7f 100644 --- a/tutorials/colors/colormapnorms.py +++ b/tutorials/colors/colormapnorms.py @@ -12,7 +12,7 @@ case). Matplotlib does this mapping in two steps, with a normalization from -[0,1] occurring first, and then mapping onto the indices in the +[0, 1] occurring first, and then mapping onto the indices in the colormap. Normalizations are classes defined in the :func:`matplotlib.colors` module. The default, linear normalization is :func:`matplotlib.colors.Normalize`. diff --git a/tutorials/intermediate/artists.py b/tutorials/intermediate/artists.py index 7f1f88a483e7..1b5fa0c05177 100644 --- a/tutorials/intermediate/artists.py +++ b/tutorials/intermediate/artists.py @@ -420,7 +420,7 @@ class in the matplotlib API, and the one you will be working with most # In [262]: fig, ax = plt.subplots() # # # create a rectangle instance -# In [263]: rect = matplotlib.patches.Rectangle( (1,1), width=5, height=12) +# In [263]: rect = matplotlib.patches.Rectangle((1, 1), width=5, height=12) # # # by default the axes instance is None # In [264]: print(rect.axes) diff --git a/tutorials/intermediate/constrainedlayout_guide.py b/tutorials/intermediate/constrainedlayout_guide.py index 535f85006fb5..be897b7bb6f1 100644 --- a/tutorials/intermediate/constrainedlayout_guide.py +++ b/tutorials/intermediate/constrainedlayout_guide.py @@ -636,7 +636,7 @@ def docomplicated(suptitle=None): # # Each `~matplotlib.axes.Axes` has *two* layoutboxes. The first one, # ``ax._layoutbox`` represents the outside of the Axes and all its -# decorations (i.e. ticklabels,axis labels, etc.). +# decorations (i.e. ticklabels, axis labels, etc.). # The second layoutbox corresponds to the Axes' ``ax.position``, which sets # where in the figure the spines are placed. # diff --git a/tutorials/intermediate/legend_guide.py b/tutorials/intermediate/legend_guide.py index b0f005431db8..0a8a5a37946f 100644 --- a/tutorials/intermediate/legend_guide.py +++ b/tutorials/intermediate/legend_guide.py @@ -49,15 +49,15 @@ For full control of what is being added to the legend, it is common to pass the appropriate handles directly to :func:`legend`:: - line_up, = plt.plot([1,2,3], label='Line 2') - line_down, = plt.plot([3,2,1], label='Line 1') + line_up, = plt.plot([1, 2, 3], label='Line 2') + line_down, = plt.plot([3, 2, 1], label='Line 1') plt.legend(handles=[line_up, line_down]) In some cases, it is not possible to set the label of the handle, so it is possible to pass through the list of labels to :func:`legend`:: - line_up, = plt.plot([1,2,3], label='Line 2') - line_down, = plt.plot([3,2,1], label='Line 1') + line_up, = plt.plot([1, 2, 3], label='Line 2') + line_down, = plt.plot([3, 2, 1], label='Line 1') plt.legend([line_up, line_down], ['Line Up', 'Line Down']) diff --git a/tutorials/introductory/pyplot.py b/tutorials/introductory/pyplot.py index af4bdd2f34e2..7fa2744361e9 100644 --- a/tutorials/introductory/pyplot.py +++ b/tutorials/introductory/pyplot.py @@ -47,7 +47,7 @@ # sequence of y values, and automatically generates the x values for # you. Since python ranges start with 0, the default x vector has the # same length as y but starts with 0. Hence the x data are -# ``[0,1,2,3]``. +# ``[0, 1, 2, 3]``. # # :func:`~matplotlib.pyplot.plot` is a versatile command, and will take # an arbitrary number of arguments. For example, to plot x versus y, @@ -384,7 +384,7 @@ def f(t): # functionality to make annotations easy. In an annotation, there are # two points to consider: the location being annotated represented by # the argument ``xy`` and the location of the text ``xytext``. Both of -# these arguments are ``(x,y)`` tuples. +# these arguments are ``(x, y)`` tuples. ax = plt.subplot(111) diff --git a/tutorials/introductory/usage.py b/tutorials/introductory/usage.py index 4b5780c5f1ac..4dc40c839afa 100644 --- a/tutorials/introductory/usage.py +++ b/tutorials/introductory/usage.py @@ -732,7 +732,7 @@ def my_plotter(ax, data1, data2, param_dict): # # Setup, and create the data to plot # y = np.random.rand(100000) # y[50000:] *= 2 -# y[np.logspace(1,np.log10(50000), 400).astype(int)] = -1 +# y[np.logspace(1, np.log10(50000), 400).astype(int)] = -1 # mpl.rcParams['path.simplify'] = True # # mpl.rcParams['agg.path.chunksize'] = 0 diff --git a/tutorials/text/annotations.py b/tutorials/text/annotations.py index e7cf5601929f..6d041d492077 100644 --- a/tutorials/text/annotations.py +++ b/tutorials/text/annotations.py @@ -19,7 +19,7 @@ to make annotations easy. In an annotation, there are two points to consider: the location being annotated represented by the argument ``xy`` and the location of the text ``xytext``. Both of these -arguments are ``(x,y)`` tuples. +arguments are ``(x, y)`` tuples. .. figure:: ../../gallery/pyplots/images/sphx_glr_annotation_basic_001.png :target: ../../gallery/pyplots/annotation_basic.html @@ -34,17 +34,17 @@ system of ``xy`` and ``xytext`` with one of the following strings for ``xycoords`` and ``textcoords`` (default is 'data') -==================== ==================================================== -argument coordinate system -==================== ==================================================== - 'figure points' points from the lower left corner of the figure - 'figure pixels' pixels from the lower left corner of the figure - 'figure fraction' 0,0 is lower left of figure and 1,1 is upper right - 'axes points' points from lower left corner of axes - 'axes pixels' pixels from lower left corner of axes - 'axes fraction' 0,0 is lower left of axes and 1,1 is upper right - 'data' use the axes data coordinate system -==================== ==================================================== +================== ======================================================== +argument coordinate system +================== ======================================================== +'figure points' points from the lower left corner of the figure +'figure pixels' pixels from the lower left corner of the figure +'figure fraction' (0, 0) is lower left of figure and (1, 1) is upper right +'axes points' points from lower left corner of axes +'axes pixels' pixels from lower left corner of axes +'axes fraction' (0, 0) is lower left of axes and (1, 1) is upper right +'data' use the axes data coordinate system +================== ======================================================== For example to place the text coordinates in fractional axes coordinates, one could do:: @@ -315,8 +315,8 @@ By default, the starting point is set to the center of the text extent. This can be adjusted with ``relpos`` key value. The values -are normalized to the extent of the text. For example, (0,0) means -lower-left corner and (1,1) means top-right. +are normalized to the extent of the text. For example, (0, 0) means +lower-left corner and (1, 1) means top-right. .. figure:: ../../gallery/userdemo/images/sphx_glr_annotate_simple04_001.png :target: ../../gallery/userdemo/annotate_simple04.html @@ -394,7 +394,7 @@ from mpl_toolkits.axes_grid1.anchored_artists import AnchoredAuxTransformBox box = AnchoredAuxTransformBox(ax.transData, loc='upper left') - el = Ellipse((0,0), width=0.1, height=0.4, angle=30) # in data coordinates! + el = Ellipse((0, 0), width=0.1, height=0.4, angle=30) # in data coordinates! box.drawing_area.add_artist(el) The ellipse in the above example will have width and height @@ -451,8 +451,8 @@ an1 = ax.annotate("Test 1", xy=(0.5, 0.5), xycoords="data", va="center", ha="center", bbox=dict(boxstyle="round", fc="w")) - an2 = ax.annotate("Test 2", xy=(1, 0.5), xycoords=an1, # (1,0.5) of the an1's bbox - xytext=(30,0), textcoords="offset points", + an2 = ax.annotate("Test 2", xy=(1, 0.5), xycoords=an1, # (1, 0.5) of the an1's bbox + xytext=(30, 0), textcoords="offset points", va="center", ha="left", bbox=dict(boxstyle="round", fc="w"), arrowprops=dict(arrowstyle="->")) @@ -479,9 +479,9 @@ identical results :: an2 = ax.annotate("Test 2", xy=(1, 0.5), xycoords=an1, - xytext=(30,0), textcoords="offset points") + xytext=(30, 0), textcoords="offset points") an2 = ax.annotate("Test 2", xy=(1, 0.5), xycoords=an1.get_window_extent, - xytext=(30,0), textcoords="offset points") + xytext=(30, 0), textcoords="offset points") 4. A tuple of two coordinate specifications. The first item is for the diff --git a/tutorials/text/text_props.py b/tutorials/text/text_props.py index 1ba9fe1eab85..ce3fd0b9eea6 100644 --- a/tutorials/text/text_props.py +++ b/tutorials/text/text_props.py @@ -56,7 +56,7 @@ :func:`~matplotlib.pyplot.text` command to show the various alignment possibilities. The use of ``transform=ax.transAxes`` throughout the code indicates that the coordinates are given relative to the axes -bounding box, with 0,0 being the lower left of the axes and 1,1 the +bounding box, with (0, 0) being the lower left of the axes and (1, 1) the upper right. """ @@ -72,7 +72,7 @@ fig = plt.figure() ax = fig.add_axes([0, 0, 1, 1]) -# axes coordinates are 0,0 is bottom left and 1,1 is upper right +# axes coordinates: (0, 0) is bottom left and (1, 1) is upper right p = patches.Rectangle( (left, bottom), width, height, fill=False, transform=ax.transAxes, clip_on=False diff --git a/tutorials/toolkits/axes_grid.py b/tutorials/toolkits/axes_grid.py index 36c3a31de4ea..2a56dfa9d276 100644 --- a/tutorials/toolkits/axes_grid.py +++ b/tutorials/toolkits/axes_grid.py @@ -7,6 +7,7 @@ .. _axes_grid1_users-guide-index: + What is axes_grid1 toolkit? =========================== @@ -38,7 +39,6 @@ ImageGrid --------- - A class that creates a grid of Axes. In matplotlib, the axes location (and size) is specified in the normalized figure coordinates. This may not be ideal for images that needs to be displayed with a given aspect @@ -77,25 +77,20 @@ your mouse in interactive backends) of one axes will affect all other shared axes. - - When initialized, ImageGrid creates given number (*ngrids* or *ncols* * *nrows* if *ngrids* is None) of Axes instances. A sequence-like interface is provided to access the individual Axes instances (e.g., grid[0] is the first Axes in the grid. See below for the order of axes). - - ImageGrid takes following arguments, - ============= ======== ================================================ Name Default Description ============= ======== ================================================ fig rect - nrows_ncols number of rows and cols. e.g., (2,2) + nrows_ncols number of rows and cols. e.g., (2, 2) ngrids None number of grids. nrows x ncols if None direction "row" increasing direction of axes number. [row|column] axes_pad 0.02 pad between axes in inches @@ -152,8 +147,6 @@ right, or top. The axes for each colorbar is stored as a *cbar_axes* attribute. - - The examples below show what you can do with ImageGrid. .. figure:: ../../gallery/axes_grid1/images/sphx_glr_demo_axes_grid_001.png @@ -176,19 +169,15 @@ which can be useful. It takes a existing axes instance and create a divider for it. :: - ax = subplot(1,1,1) + ax = subplot(1, 1, 1) divider = make_axes_locatable(ax) - - - *make_axes_locatable* returns an instance of the AxesLocator class, derived from the Locator. It provides *append_axes* method that creates a new axes on the given side of ("top", "right", "bottom" and "left") of the original axes. - colorbar whose height (or width) in sync with the master axes ------------------------------------------------------------- @@ -200,8 +189,6 @@ Simple Colorbar - - scatter_hist.py with AxesDivider ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -223,7 +210,6 @@ axHistx.hist(x, bins=bins) axHisty.hist(y, bins=bins, orientation='horizontal') - See the full source code below. .. figure:: ../../gallery/axes_grid1/images/sphx_glr_scatter_hist_locatable_axes_001.png @@ -233,7 +219,6 @@ Scatter Hist - The scatter_hist using the AxesDivider has some advantage over the original scatter_hist.py in mpl. For example, you can set the aspect ratio of the scatter plot, even with the x-axis or y-axis is shared @@ -273,6 +258,7 @@ Parasite Simple + Example 2. twin ~~~~~~~~~~~~~~~ @@ -294,8 +280,6 @@ Simple Axisline4 - - A more sophisticated example using twin. Note that if you change the x-limit in the host axes, the x-limit of the parasite axes will change accordingly. @@ -391,7 +375,7 @@ fig = plt.figure() ax = RGBAxes(fig, [0.1, 0.1, 0.8, 0.8]) - r, g, b = get_rgb() # r,g,b are 2-d images + r, g, b = get_rgb() # r, g, b are 2-d images ax.imshow_rgb(r, g, b, origin="lower", interpolation="nearest") @@ -430,24 +414,24 @@ for example,:: rect = [0.2, 0.2, 0.6, 0.6] - horiz=[h0, h1, h2, h3] - vert=[v0, v1, v2] + horiz = [h0, h1, h2, h3] + vert = [v0, v1, v2] divider = Divider(fig, rect, horiz, vert) -where, rect is a bounds of the box that will be divided and h0,..h3, -v0,..v2 need to be an instance of classes in the +where rect is a bounds of the box that will be divided and h0, ..., h3, +v0, ..., v2 need to be instance of classes in the :mod:`~mpl_toolkits.axes_grid1.axes_size`. They have *get_size* method that returns a tuple of two floats. The first float is the relative size, and the second float is the absolute size. Consider a following grid. -+-----+-----+-----+-----+ -| v0 | | | | -+-----+-----+-----+-----+ -| v1 | | | | -+-----+-----+-----+-----+ -|h0,v2| h1 | h2 | h3 | -+-----+-----+-----+-----+ ++------+-----+-----+-----+ +| v0 | | | | ++------+-----+-----+-----+ +| v1 | | | | ++------+-----+-----+-----+ +|h0, v2| h1 | h2 | h3 | ++------+-----+-----+-----+ * v0 => 0, 2 @@ -462,7 +446,6 @@ determined. When the aspect ratio is set, the total height (or width) will be adjusted accordingly. - The :mod:`mpl_toolkits.axes_grid1.axes_size` contains several classes that can be used to set the horizontal and vertical configurations. For example, for vertical configuration one could use:: diff --git a/tutorials/toolkits/axisartist.py b/tutorials/toolkits/axisartist.py index 46a5aae62883..e07461c07e1f 100644 --- a/tutorials/toolkits/axisartist.py +++ b/tutorials/toolkits/axisartist.py @@ -290,7 +290,7 @@ Same as the original mpl's axes.:: - ax.set_xticks([1,2,3]) + ax.set_xticks([1, 2, 3]) 2. Changing axis properties like color, etc. @@ -519,7 +519,7 @@ def tr(x, y): return x, y-x # from rectlinear coordinate to curved coordinate. - def inv_tr(x,y): + def inv_tr(x, y): x, y = np.asarray(x), np.asarray(y) return x, y+x @@ -557,8 +557,8 @@ def inv_tr(x,y): # minute, second). The argument is a approximate number of grids. grid_locator1 = angle_helper.LocatorDMS(12) - # And also uses an appropriate formatter. Note that,the - # acceptable Locator and Formatter class is a bit different than + # And also uses an appropriate formatter. Note that the + # acceptable Locator and Formatter classes are different than # that of mpl's, and you cannot directly use mpl's Locator and # Formatter here (but may be possible in the future). tick_formatter1 = angle_helper.FormatterDMS()