diff --git a/examples/color/named_colors.py b/examples/color/named_colors.py index 232b514eda30..2280e6ea18bb 100644 --- a/examples/color/named_colors.py +++ b/examples/color/named_colors.py @@ -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() @@ -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)) diff --git a/examples/pylab_examples/csd_demo.py b/examples/pylab_examples/csd_demo.py index c988e2c1aa69..d5f41c9ab402 100644 --- a/examples/pylab_examples/csd_demo.py +++ b/examples/pylab_examples/csd_demo.py @@ -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) @@ -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() diff --git a/examples/showcase/bachelors_degrees_by_gender.py b/examples/showcase/bachelors_degrees_by_gender.py index c0ea4045ef3c..737c37dd8f59 100644 --- a/examples/showcase/bachelors_degrees_by_gender.py +++ b/examples/showcase/bachelors_degrees_by_gender.py @@ -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. @@ -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')