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

Skip to content

Commit 92b4b95

Browse files
authored
Merge pull request #25467 from jklymak/doc-suptitle-update
DOC: update suptitle example to remove percent_bachelors_degrees csv
2 parents 370547e + 85db363 commit 92b4b95

File tree

2 files changed

+13
-66
lines changed

2 files changed

+13
-66
lines changed

galleries/examples/subplots_axes_and_figures/figure_title.py

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -33,31 +33,21 @@
3333
# A global x- or y-label can be set using the `.FigureBase.supxlabel` and
3434
# `.FigureBase.supylabel` methods.
3535

36-
fig, axs = plt.subplots(3, 5, figsize=(8, 5), layout='constrained',
37-
sharex=True, sharey=True)
3836

39-
fname = get_sample_data('percent_bachelors_degrees_women_usa.csv',
40-
asfileobj=False)
41-
gender_degree_data = np.genfromtxt(fname, delimiter=',', names=True)
37+
def convertdate(x):
38+
return np.datetime64(x, 'D')
4239

43-
majors = ['Health Professions', 'Public Administration', 'Education',
44-
'Psychology', 'Foreign Languages', 'English',
45-
'Art and Performance', 'Biology',
46-
'Agriculture', 'Business',
47-
'Math and Statistics', 'Architecture', 'Physical Sciences',
48-
'Computer Science', 'Engineering']
40+
fname = get_sample_data('Stocks.csv', asfileobj=False)
41+
stocks = np.genfromtxt(fname, encoding='utf-8', delimiter=',',
42+
names=True, dtype=None, converters={0: convertdate},
43+
skip_header=1)
4944

45+
fig, axs = plt.subplots(4, 2, figsize=(9, 5), layout='constrained',
46+
sharex=True, sharey=True)
5047
for nn, ax in enumerate(axs.flat):
51-
ax.set_xlim(1969.5, 2011.1)
52-
column = majors[nn]
53-
column_rec_name = column.replace('\n', '_').replace(' ', '_')
54-
55-
line, = ax.plot('Year', column_rec_name, data=gender_degree_data,
56-
lw=2.5)
57-
ax.set_title(column, fontsize='small', loc='left')
58-
ax.set_ylim([0, 100])
59-
ax.grid()
48+
column_name = stocks.dtype.names[1+nn]
49+
y = stocks[column_name]
50+
line, = ax.plot(stocks['Date'], y / np.nanmax(y), lw=2.5)
51+
ax.set_title(column_name, fontsize='small', loc='left')
6052
fig.supxlabel('Year')
61-
fig.supylabel('Percent Degrees Awarded To Women')
62-
63-
plt.show()
53+
fig.supylabel('Stock price relative to max')

lib/matplotlib/mpl-data/sample_data/percent_bachelors_degrees_women_usa.csv

Lines changed: 0 additions & 43 deletions
This file was deleted.

0 commit comments

Comments
 (0)