Update bachelors_degree_by_gender example. #6874

Merged
merged 1 commit into from Aug 1, 2016

Conversation

Projects
None yet
5 participants
Contributor

anntzer commented Jul 31, 2016

Use plt.grid() instead of manually adding grid lines (this requires
slightly changing the xlims to have a similar spacing).

Use FuncFormatters instead of fixed tick labels, both for generality and so
that the interactive cursor position text is properly formatted.

Add a show() at the end.

@anntzer anntzer Update bachelors_degree_by_gender example.
Use plt.grid() instead of manually adding grid lines (this requires
slightly changing the xlims to have a similar spacing).

Use FuncFormatters instead of fixed tick labels, both for generality and so
that the interactive cursor position text is properly formatted.

Add a `show()` at the end.
ac6fc05

mdboom added the needs_review label Jul 31, 2016

@Kojoley Kojoley commented on the diff Jul 31, 2016

examples/showcase/bachelors_degrees_by_gender.py
# Make sure your axis ticks are large enough to be easily read.
# You don't want your viewers squinting to read your plot.
plt.xticks(range(1970, 2011, 10), fontsize=14)
-plt.yticks(range(0, 91, 10), ['{0}%'.format(x)
- for x in range(0, 91, 10)], fontsize=14)
+plt.yticks(range(0, 91, 10), fontsize=14)
+ax.xaxis.set_major_formatter(plt.FuncFormatter('{:.0f}'.format))
+ax.yaxis.set_major_formatter(plt.FuncFormatter('{:.0f}%'.format))
@Kojoley

Kojoley Jul 31, 2016

Member

You can simply use '{:.0%}'

@anntzer

anntzer Jul 31, 2016

Contributor

No, because this would multiply the entries by 100 (they are in [0, 100], not [0, 1]).

@Kojoley

Kojoley Jul 31, 2016

Member

Ahh, yes, sorry.

@tacaswell tacaswell merged commit 0cfc7a8 into matplotlib:master Aug 1, 2016

3 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage decreased (-0.002%) to 70.448%
Details

tacaswell removed the needs_review label Aug 1, 2016

@tacaswell tacaswell added a commit that referenced this pull request Aug 1, 2016

@tacaswell tacaswell Merge pull request #6874 from anntzer/update-bachelors-degree-by-gender
DOC: Update bachelors_degree_by_gender example.
be37777
Owner

tacaswell commented Aug 1, 2016

backported to v2.x as be37777

anntzer deleted the anntzer:update-bachelors-degree-by-gender branch Aug 1, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment