Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Examples #6505

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 3 commits into from
Jun 6, 2016
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
6 changes: 1 addition & 5 deletions examples/color/named_colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
ncols = 4
nrows = int(np.ceil(1. * n / ncols))

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

X, Y = fig.get_dpi() * fig.get_size_inches()

Expand All @@ -49,10 +49,6 @@
horizontalalignment='left',
verticalalignment='center')

# Add extra black line a little bit thicker to make
# clear colors more visible.
ax.hlines(
y, xi_line, xf_line, color='black', linewidth=(h * 0.7))
ax.hlines(
y + h * 0.1, xi_line, xf_line, color=colors[name], linewidth=(h * 0.6))

Expand Down
20 changes: 10 additions & 10 deletions examples/pylab_examples/csd_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
import numpy as np
import matplotlib.pyplot as plt


fig, (ax1, ax2) = plt.subplots(2, 1)
# make a little extra space between the subplots
plt.subplots_adjust(wspace=0.5)
fig.subplots_adjust(hspace=0.5)

dt = 0.01
t = np.arange(0, 30, dt)
Expand All @@ -21,14 +23,12 @@
s1 = 0.01*np.sin(2*np.pi*10*t) + cnse1
s2 = 0.01*np.sin(2*np.pi*10*t) + cnse2

plt.subplot(211)
plt.plot(t, s1, t, s2)
plt.xlim(0, 5)
plt.xlabel('time')
plt.ylabel('s1 and s2')
plt.grid(True)
ax1.plot(t, s1, t, s2)
ax1.set_xlim(0, 5)
ax1.set_xlabel('time')
ax1.set_ylabel('s1 and s2')
ax1.grid(True)

plt.subplot(212)
cxy, f = plt.csd(s1, s2, 256, 1./dt)
plt.ylabel('CSD (db)')
cxy, f = ax2.csd(s1, s2, 256, 1./dt)
ax2.set_ylabel('CSD (db)')
plt.show()
12 changes: 7 additions & 5 deletions examples/showcase/bachelors_degrees_by_gender.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@
ax.get_xaxis().tick_bottom()
ax.get_yaxis().tick_left()

fig.subplots_adjust(left=.06, right=.75, bottom=.02, top=.94)
# Limit the range of the plot to only where the data is.
# Avoid unnecessary whitespace.
plt.xlim(1968.5, 2011.1)
plt.ylim(-0.25, 90)
ax.set_xlim(1968.5, 2011.1)
ax.set_ylim(-0.25, 90)
ax.get_xaxis().get_major_formatter().set_useOffset(False)

# Make sure your axis ticks are large enough to be easily read.
# You don't want your viewers squinting to read your plot.
Expand Down Expand Up @@ -91,10 +93,10 @@

# Note that if the title is descriptive enough, it is unnecessary to include
# axis labels; they are self-evident, in this plot's case.
plt.title('Percentage of Bachelor\'s degrees conferred to women in '
'the U.S.A. by major (1970-2011)\n', fontsize=18, ha='center')
fig.suptitle('Percentage of Bachelor\'s degrees conferred to women in '
'the U.S.A. by major (1970-2011)\n', fontsize=18, ha='center')

# Finally, save the figure as a PNG.
# You can also save it as a PDF, JPEG, etc.
# Just change the file extension in this call.
plt.savefig('percent-bachelors-degrees-women-usa.png', bbox_inches='tight')
# plt.savefig('percent-bachelors-degrees-women-usa.png', bbox_inches='tight')