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

Skip to content

cleaned up 3 examples [MEP12] #6488

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

Closed
wants to merge 3 commits into from
Closed
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
8 changes: 8 additions & 0 deletions examples/showcase/bachelors_degrees_by_gender.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
"""Timeline graph comparison with aligned colored annotation.

This example shows lines tracking change over time. It features dashed
lines at fixed increments on the Y axis.
Copy link
Member

Choose a reason for hiding this comment

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

being a bit pedantic here, but this paragraph could be used to describe just about any plot. I would just leave it out, or add a some info that is more specific to this example. In particular, with MEP12, we are looking for descriptions that not only describe the figure, but also describe what feature of matplotlib is being showcased.

Copy link
Member

Choose a reason for hiding this comment

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

This one is a particularly flexibility testing example.

Copy link
Contributor

Choose a reason for hiding this comment

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

What about something like...
"""
A graph of multiple time series which demonstrates extensive custom
styling of plot frame, tick lines and labels, and line graph properties.

Also demonstrates the custom placement of text labels along the right edge
as an alternative to a conventional legend.
"""

Copy link
Member

Choose a reason for hiding this comment

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

Perfect!


It adds a text label at the right end of every line in the corresponding color.
"""

import matplotlib.pyplot as plt
from matplotlib.mlab import csv2rec
from matplotlib.cbook import get_sample_data
Expand Down
6 changes: 3 additions & 3 deletions examples/statistics/boxplot_color_demo.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Box plots with custom fill colors
"""Box plots with custom fill colors."""
Copy link
Member

Choose a reason for hiding this comment

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

It would be worth having a small description here as well.

Copy link
Member

Choose a reason for hiding this comment

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

@NelleV Any suggestions?

Copy link
Member

Choose a reason for hiding this comment

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

You are making me work :)

Something like:
"This plot illustrates how to create two types of boxplots (rectangular and notch), and how to fill them with custom colors by accessing some properties of the artists of the boxplots."
If we'd go with this description, I'd replace the title with something shorter: "Colored box plots"

But with this description, I'd remove the horizontal grid lines and replace the setp with ax.set_xticklabels.

Copy link
Member

Choose a reason for hiding this comment

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

I'm not convinced, @WeatherGod what do you think?


import matplotlib.pyplot as plt
import numpy as np
Expand Down Expand Up @@ -29,12 +29,12 @@
# adding horizontal grid lines
for ax in axes:
ax.yaxis.grid(True)
ax.set_xticks([y+1 for y in range(len(all_data))], )
ax.set_xticks([y + 1 for y in range(len(all_data))], )
ax.set_xlabel('xlabel')
ax.set_ylabel('ylabel')

# add x-tick labels
plt.setp(axes, xticks=[y+1 for y in range(len(all_data))],
plt.setp(axes, xticks=[y + 1 for y in range(len(all_data))],
xticklabels=['x1', 'x2', 'x3', 'x4'])

plt.show()
24 changes: 13 additions & 11 deletions examples/statistics/boxplot_vs_violin_demo.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
# Box plot - violin plot comparison
#
# Note that although violin plots are closely related to Tukey's (1977) box plots,
# they add useful information such as the distribution of the sample data (density trace).
#
# By default, box plots show data points outside 1.5 x the inter-quartile range as outliers
# above or below the whiskers wheras violin plots show the whole range of the data.
#
# Violin plots require matplotlib >= 1.4.
"""Box plot - violin plot comparison.

Note that although violin plots are closely related to Tukey's (1977) box
plots, they add useful information such as the distribution of the sample
data (density trace).

By default, box plots show data points outside 1.5 x the inter-quartile range
as outliers above or below the whiskers wheras violin plots show the whole
range of the data.

Violin plots require matplotlib >= 1.4.
"""
import matplotlib.pyplot as plt
import numpy as np

Expand All @@ -29,11 +31,11 @@
# adding horizontal grid lines
for ax in axes:
ax.yaxis.grid(True)
ax.set_xticks([y+1 for y in range(len(all_data))])
ax.set_xticks([y + 1 for y in range(len(all_data))])
ax.set_xlabel('xlabel')
ax.set_ylabel('ylabel')

# add x-tick labels
plt.setp(axes, xticks=[y+1 for y in range(len(all_data))],
plt.setp(axes, xticks=[y + 1 for y in range(len(all_data))],
xticklabels=['x1', 'x2', 'x3', 'x4'])
plt.show()