Skip to content

Pylab example moves 2 #8857

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

# Data for plotting
t = np.arange(0.0, 2.0, 0.01)
s = 1 + np.sin(2*np.pi*t)
s = 1 + np.sin(2 * np.pi * t)

# Note that using plt.subplots below is equivalent to using
# fig = plt.figure and then ax = fig.add_subplot(111)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
import matplotlib.pyplot as plt


data = [[ 66386, 174296, 75131, 577908, 32015],
Copy link
Member

Choose a reason for hiding this comment

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

🚲 🏚️ minor preference for leaving this formatting the way it is for human readability.

[ 58230, 381139, 78045, 99308, 160454],
[ 89135, 80552, 152558, 497981, 603535],
[ 78415, 81858, 150656, 193263, 69638],
[ 139361, 331509, 343164, 781380, 52269]]
data = [[ 66386, 174296, 75131, 577908, 32015],
[ 58230, 381139, 78045, 99308, 160454],
[ 89135, 80552, 152558, 497981, 603535],
[ 78415, 81858, 150656, 193263, 69638],
[139361, 331509, 343164, 781380, 52269]]

columns = ('Freeze', 'Wind', 'Flood', 'Quake', 'Hail')
rows = ['%d year' % x for x in (100, 50, 20, 10, 5)]
Expand All @@ -36,7 +36,7 @@
for row in range(n_rows):
plt.bar(index, data[row], bar_width, bottom=y_offset, color=colors[row])
y_offset = y_offset + data[row]
cell_text.append(['%1.1f' % (x/1000.0) for x in y_offset])
cell_text.append(['%1.1f' % (x / 1000.0) for x in y_offset])
# Reverse colors and text labels to display the last value at the top.
colors = colors[::-1]
cell_text.reverse()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
=========

Make a pie charts of varying size - see
http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.pie for the docstring.
https://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.pie for the
docstring.

This example shows a basic pie charts with labels optional features,
like autolabeling the percentage, offsetting a slice with "explode"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
ax = plt.subplot(111, projection='polar')
ax.plot(theta, r)
ax.set_rmax(2)
ax.set_rticks([0.5, 1, 1.5, 2]) # less radial ticks
ax.set_rlabel_position(-22.5) # get radial labels away from plotted line
ax.set_rticks([0.5, 1, 1.5, 2]) # Less radial ticks
ax.set_rlabel_position(-22.5) # Move radial labels away from plotted line
ax.grid(True)

ax.set_title("A line plot on a polar axis", va='bottom')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
projection='polar', facecolor='#d5de9c')

r = np.arange(0, 3.0, 0.01)
theta = 2*np.pi*r
theta = 2 * np.pi * r
ax.plot(theta, r, color='#ee8d18', lw=3, label='a line')
ax.plot(0.5*theta, r, color='blue', ls='--', lw=3, label='another line')
ax.plot(0.5 * theta, r, color='blue', ls='--', lw=3, label='another line')
ax.legend()

show()
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,27 @@
Log Bar
=======

Plotting a bar chart with a logarithmic y-axis.
"""
import matplotlib.pyplot as plt
import numpy as np

data = ((3, 1000), (10, 3), (100, 30), (500, 800), (50, 1))

plt.xlabel("FOO")
Copy link
Member

Choose a reason for hiding this comment

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

Can we just change these to not 'FOO'? It is good practice to always label your axes 😈

plt.ylabel("FOO")
plt.title("Testing")
plt.yscale('log')

dim = len(data[0])
w = 0.75
dimw = w / dim

fig, ax = plt.subplots()
x = np.arange(len(data))
for i in range(len(data[0])):
y = [d[i] for d in data]
b = plt.bar(x + i * dimw, y, dimw, bottom=0.001)
b = ax.bar(x + i * dimw, y, dimw, bottom=0.001)

ax.set_xticks(x + dimw / 2, map(str, x))
ax.set_yscale('log')

plt.xticks(x + dimw / 2, map(str, x))
ax.set_xlabel('x')
ax.set_ylabel('y')

plt.show()
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@
fig.subplots_adjust(hspace=0.5)

# log y axis
ax1.semilogy(t, np.exp(-t/5.0))
ax1.semilogy(t, np.exp(-t / 5.0))
ax1.set(title='semilogy')
ax1.grid()

# log x axis
ax2.semilogx(t, np.sin(2*np.pi*t))
ax2.semilogx(t, np.sin(2 * np.pi * t))
ax2.set(title='semilogx')
ax2.grid()

# log x and y axis
ax3.loglog(t, 20*np.exp(-t/10.0), basex=2)
ax3.loglog(t, 20 * np.exp(-t / 10.0), basex=2)
ax3.set(title='loglog base 2 on x')
ax3.grid()

Expand All @@ -42,7 +42,7 @@
ax4.set_xscale("log", nonposx='clip')
ax4.set_yscale("log", nonposy='clip')
ax4.set(title='Errorbars go negative')
ax4.errorbar(x, y, xerr=0.1*x, yerr=5.0 + 0.75*y)
ax4.errorbar(x, y, xerr=0.1 * x, yerr=5.0 + 0.75 * y)
# ylim must be set after errorbar to allow errorbar to autoscale limits
ax4.set_ylim(ymin=0.1)

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

XY = np.hstack((X.ravel()[:, np.newaxis], Y.ravel()[:, np.newaxis]))

ww = X/10.0
hh = Y/15.0
aa = X*9
ww = X / 10.0
hh = Y / 15.0
aa = X * 9


fig, ax = plt.subplots()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

NUM = 250

ells = [Ellipse(xy=np.random.rand(2)*10,
ells = [Ellipse(xy=np.random.rand(2) * 10,
width=np.random.rand(), height=np.random.rand(),
angle=np.random.rand()*360)
angle=np.random.rand() * 360)
for i in range(NUM)]

fig, ax = plt.subplots(subplot_kw={'aspect': 'equal'})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
spacing = 1.2

figheight = (spacing * len(styles) + .5)
fig1 = plt.figure(1, (4/1.5, figheight/1.5))
fig1 = plt.figure(1, (4 / 1.5, figheight / 1.5))
fontsize = 0.3 * 72

for i, stylename in enumerate(sorted(styles)):
Expand Down Expand Up @@ -65,8 +65,8 @@ def test1(ax):
size=10, transform=ax.transAxes)

# draws control points for the fancy box.
#l = p_fancy.get_path().vertices
#ax.plot(l[:,0], l[:,1], ".")
# l = p_fancy.get_path().vertices
# ax.plot(l[:,0], l[:,1], ".")

# draw the original bbox in black
draw_bbox(ax, bb)
Expand All @@ -90,15 +90,15 @@ def test2(ax):

p_fancy.set_boxstyle("round,pad=0.1, rounding_size=0.2")
# or
#p_fancy.set_boxstyle("round", pad=0.1, rounding_size=0.2)
# p_fancy.set_boxstyle("round", pad=0.1, rounding_size=0.2)

ax.text(0.1, 0.8,
' boxstyle="round,pad=0.1\n rounding_size=0.2"',
size=10, transform=ax.transAxes)

# draws control points for the fancy box.
#l = p_fancy.get_path().vertices
#ax.plot(l[:,0], l[:,1], ".")
# l = p_fancy.get_path().vertices
# ax.plot(l[:,0], l[:,1], ".")

draw_bbox(ax, bb)

Expand All @@ -122,8 +122,8 @@ def test3(ax):
size=10, transform=ax.transAxes)

# draws control points for the fancy box.
#l = p_fancy.get_path().vertices
#ax.plot(l[:,0], l[:,1], ".")
# l = p_fancy.get_path().vertices
# ax.plot(l[:,0], l[:,1], ".")

draw_bbox(ax, bb)

Expand Down Expand Up @@ -192,4 +192,5 @@ def test_all():
plt.draw()
plt.show()


test_all()
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def bullseye_plot(ax, data, segBold=None, cmap=None, norm=None):
if norm is None:
norm = mpl.colors.Normalize(vmin=data.min(), vmax=data.max())

theta = np.linspace(0, 2*np.pi, 768)
theta = np.linspace(0, 2 * np.pi, 768)
r = np.linspace(0.2, 1, 4)

# Create the bound for the segment 17
Expand All @@ -76,52 +76,52 @@ def bullseye_plot(ax, data, segBold=None, cmap=None, norm=None):
r0 = np.repeat(r0[:, np.newaxis], 128, axis=1).T
for i in range(6):
# First segment start at 60 degrees
theta0 = theta[i*128:i*128+128] + np.deg2rad(60)
theta0 = theta[i * 128:i * 128 + 128] + np.deg2rad(60)
theta0 = np.repeat(theta0[:, np.newaxis], 2, axis=1)
z = np.ones((128, 2))*data[i]
z = np.ones((128, 2)) * data[i]
ax.pcolormesh(theta0, r0, z, cmap=cmap, norm=norm)
if i+1 in segBold:
ax.plot(theta0, r0, '-k', lw=linewidth+2)
ax.plot(theta0[0], [r[2], r[3]], '-k', lw=linewidth+1)
ax.plot(theta0[-1], [r[2], r[3]], '-k', lw=linewidth+1)
if i + 1 in segBold:
ax.plot(theta0, r0, '-k', lw=linewidth + 2)
ax.plot(theta0[0], [r[2], r[3]], '-k', lw=linewidth + 1)
ax.plot(theta0[-1], [r[2], r[3]], '-k', lw=linewidth + 1)

# Fill the segments 7-12
r0 = r[1:3]
r0 = np.repeat(r0[:, np.newaxis], 128, axis=1).T
for i in range(6):
# First segment start at 60 degrees
theta0 = theta[i*128:i*128+128] + np.deg2rad(60)
theta0 = theta[i * 128:i * 128 + 128] + np.deg2rad(60)
theta0 = np.repeat(theta0[:, np.newaxis], 2, axis=1)
z = np.ones((128, 2))*data[i+6]
z = np.ones((128, 2)) * data[i + 6]
ax.pcolormesh(theta0, r0, z, cmap=cmap, norm=norm)
if i+7 in segBold:
ax.plot(theta0, r0, '-k', lw=linewidth+2)
ax.plot(theta0[0], [r[1], r[2]], '-k', lw=linewidth+1)
ax.plot(theta0[-1], [r[1], r[2]], '-k', lw=linewidth+1)
if i + 7 in segBold:
ax.plot(theta0, r0, '-k', lw=linewidth + 2)
ax.plot(theta0[0], [r[1], r[2]], '-k', lw=linewidth + 1)
ax.plot(theta0[-1], [r[1], r[2]], '-k', lw=linewidth + 1)

# Fill the segments 13-16
r0 = r[0:2]
r0 = np.repeat(r0[:, np.newaxis], 192, axis=1).T
for i in range(4):
# First segment start at 45 degrees
theta0 = theta[i*192:i*192+192] + np.deg2rad(45)
theta0 = theta[i * 192:i * 192 + 192] + np.deg2rad(45)
theta0 = np.repeat(theta0[:, np.newaxis], 2, axis=1)
z = np.ones((192, 2))*data[i+12]
z = np.ones((192, 2)) * data[i + 12]
ax.pcolormesh(theta0, r0, z, cmap=cmap, norm=norm)
if i+13 in segBold:
ax.plot(theta0, r0, '-k', lw=linewidth+2)
ax.plot(theta0[0], [r[0], r[1]], '-k', lw=linewidth+1)
ax.plot(theta0[-1], [r[0], r[1]], '-k', lw=linewidth+1)
if i + 13 in segBold:
ax.plot(theta0, r0, '-k', lw=linewidth + 2)
ax.plot(theta0[0], [r[0], r[1]], '-k', lw=linewidth + 1)
ax.plot(theta0[-1], [r[0], r[1]], '-k', lw=linewidth + 1)

# Fill the segments 17
if data.size == 17:
r0 = np.array([0, r[0]])
r0 = np.repeat(r0[:, np.newaxis], theta.size, axis=1).T
theta0 = np.repeat(theta[:, np.newaxis], 2, axis=1)
z = np.ones((theta.size, 2))*data[16]
z = np.ones((theta.size, 2)) * data[16]
ax.pcolormesh(theta0, r0, z, cmap=cmap, norm=norm)
if 17 in segBold:
ax.plot(theta0, r0, '-k', lw=linewidth+2)
ax.plot(theta0, r0, '-k', lw=linewidth + 2)

ax.set_ylim([0, 1])
ax.set_yticklabels([])
Expand Down Expand Up @@ -188,7 +188,7 @@ def bullseye_plot(ax, data, segBold=None, cmap=None, norm=None):
cb3 = mpl.colorbar.ColorbarBase(axl3, cmap=cmap3, norm=norm3,
# to use 'extend', you must
# specify two extra boundaries:
boundaries=[0]+bounds+[18],
boundaries=[0] + bounds + [18],
extend='both',
ticks=bounds, # optional
spacing='proportional',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
fig, axs = plt.subplots(1, 2)

x = np.arange(0.0, 2.0, 0.02)
y1 = np.sin(2*np.pi*x)
y1 = np.sin(2 * np.pi * x)
y2 = np.exp(-x)
l1, l2 = axs[0].plot(x, y1, 'rs-', x, y2, 'go')

y3 = np.sin(4*np.pi*x)
y4 = np.exp(-2*x)
y3 = np.sin(4 * np.pi * x)
y4 = np.exp(-2 * x)
l3, l4 = axs[1].plot(x, y3, 'yd-', x, y4, 'k^')

fig.legend((l1, l2), ('Line 1', 'Line 2'), 'upper left')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
def setfont(font):
return r'\font\a %s at 14pt\a ' % font


for y, font, text in zip(range(5),
['ptmr8r', 'ptmri8r', 'ptmro8r', 'ptmr8rn', 'ptmrr8re'],
['ptmr8r', 'ptmri8r', 'ptmro8r',
'ptmr8rn', 'ptmrr8re'],
['Nimbus Roman No9 L ' + x for x in
['', 'Italics (real italics for comparison)',
'(slanted)', '(condensed)', '(extended)']]):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@


t = np.arange(0.0, 100.0, 0.1)
s = np.sin(0.1*np.pi*t)*np.exp(-t*0.01)
s = np.sin(0.1 * np.pi * t) * np.exp(-t * 0.01)

fig, ax = plt.subplots()
ax.plot(t, s)
Expand Down Expand Up @@ -73,7 +73,7 @@


t = np.arange(0.0, 100.0, 0.01)
s = np.sin(2*np.pi*t)*np.exp(-t*0.01)
s = np.sin(2 * np.pi * t) * np.exp(-t * 0.01)

fig, ax = plt.subplots()
ax.plot(t, s)
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/ticker.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
ax.yaxis.set_major_formatter( ymajorFormatter )
ax.yaxis.set_minor_formatter( yminorFormatter )

See :ref:`sphx_glr_gallery_pylab_examples_major_minor_demo.py` for an
See :ref:`sphx_glr_gallery_ticks_and_spines_major_minor_demo.py` for an
example of setting major and minor ticks. See the :mod:`matplotlib.dates`
module for more information and examples of using date locators and formatters.
"""
Expand Down
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ pep8ignore =
tutorials/* E402 E501

*examples/* E501 E402
*examples/pylab_examples/table_demo.py E201
*examples/misc/table_demo.py E201
*examples/images_contours_and_fields/tricontour_demo.py E201
*examples/images_contours_and_fields/tripcolor_demo.py E201
*examples/images_contours_and_fields/triplot_demo.py E201
Expand Down
Loading