Skip to content

Commit 0cfc7a8

Browse files
authored
Merge pull request #6874 from anntzer/update-bachelors-degree-by-gender
DOC: Update bachelors_degree_by_gender example.
2 parents 88ce601 + ac6fc05 commit 0cfc7a8

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

examples/showcase/bachelors_degrees_by_gender.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,20 @@
3030
fig.subplots_adjust(left=.06, right=.75, bottom=.02, top=.94)
3131
# Limit the range of the plot to only where the data is.
3232
# Avoid unnecessary whitespace.
33-
ax.set_xlim(1968.5, 2011.1)
33+
ax.set_xlim(1969.5, 2011.1)
3434
ax.set_ylim(-0.25, 90)
35-
ax.get_xaxis().get_major_formatter().set_useOffset(False)
3635

3736
# Make sure your axis ticks are large enough to be easily read.
3837
# You don't want your viewers squinting to read your plot.
3938
plt.xticks(range(1970, 2011, 10), fontsize=14)
40-
plt.yticks(range(0, 91, 10), ['{0}%'.format(x)
41-
for x in range(0, 91, 10)], fontsize=14)
39+
plt.yticks(range(0, 91, 10), fontsize=14)
40+
ax.xaxis.set_major_formatter(plt.FuncFormatter('{:.0f}'.format))
41+
ax.yaxis.set_major_formatter(plt.FuncFormatter('{:.0f}%'.format))
4242

4343
# Provide tick lines across the plot to help your viewers trace along
4444
# the axis ticks. Make sure that the lines are light and small so they
4545
# don't obscure the primary data lines.
46-
for y in range(10, 91, 10):
47-
plt.plot(range(1969, 2012), [y] * len(range(1969, 2012)), '--',
48-
lw=0.5, color='black', alpha=0.3)
46+
plt.grid(True, 'major', 'y', ls='--', lw=.5, c='k', alpha=.3)
4947

5048
# Remove the tick marks; they are unnecessary with the tick lines we just
5149
# plotted.
@@ -100,3 +98,4 @@
10098
# You can also save it as a PDF, JPEG, etc.
10199
# Just change the file extension in this call.
102100
# plt.savefig('percent-bachelors-degrees-women-usa.png', bbox_inches='tight')
101+
plt.show()

0 commit comments

Comments
 (0)