Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 29a495a

Browse filesBrowse files
committed
removing url dependency and resizing fig
1 parent 4e60dfb commit 29a495a
Copy full SHA for 29a495a

File tree

Expand file treeCollapse file tree

1 file changed

+16
-14
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+16
-14
lines changed

‎examples/lines_bars_and_markers/timeline.py

Copy file name to clipboardExpand all lines: examples/lines_bars_and_markers/timeline.py
+16-14Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,23 @@
1414
import numpy as np
1515
import matplotlib.dates as mdates
1616
from datetime import datetime
17-
import urllib.request
18-
import json
1917

20-
# Grab a list of Matplotlib releases
21-
url = 'https://api.github.com/repos/matplotlib/matplotlib/releases'
22-
data = json.loads(urllib.request.urlopen(url).read().decode())
18+
# A list of Matplotlib releases and their dates
19+
# Taken from https://api.github.com/repos/matplotlib/matplotlib/releases
20+
names = ['v2.2.2', 'v2.2.1', 'v2.2.0', 'v2.1.2', 'v2.1.1', 'v2.1.0', 'v2.0.2',
21+
'v2.0.1', 'v2.0.0', 'v1.5.3', 'v1.5.2', 'v1.5.1', 'v1.5.0', 'v1.4.3',
22+
'v1.4.2', 'v1.4.1', 'v1.4.0']
2323

24-
names = []
25-
dates = []
26-
for irelease in data:
27-
if 'rc' not in irelease['tag_name'] and 'b' not in irelease['tag_name']:
28-
names.append(irelease['tag_name'])
29-
# Convert date strings (e.g. 2014-10-18T18:56:23Z) to datetime
30-
dates.append(datetime.strptime(irelease['published_at'],
31-
"%Y-%m-%dT%H:%M:%SZ"))
24+
dates = ['2018-03-17T03:00:07Z', '2018-03-16T22:06:39Z',
25+
'2018-03-06T12:53:32Z', '2018-01-18T04:56:47Z',
26+
'2017-12-10T04:47:38Z', '2017-10-07T22:35:12Z',
27+
'2017-05-10T02:11:15Z', '2017-05-02T01:59:49Z',
28+
'2017-01-17T02:59:36Z', '2016-09-09T03:00:52Z',
29+
'2016-07-03T15:52:01Z', '2016-01-10T22:38:50Z',
30+
'2015-10-29T21:40:23Z', '2015-02-16T04:22:54Z',
31+
'2014-10-26T03:24:13Z', '2014-10-18T18:56:23Z',
32+
'2014-08-26T21:06:04Z']
33+
dates = [datetime.strptime(ii, "%Y-%m-%dT%H:%M:%SZ") for ii in dates]
3234

3335
##############################################################################
3436
# Next, we'll iterate through each date and plot it on a horizontal line.
@@ -37,7 +39,7 @@
3739
# Note that Matplotlib will automatically plot datetime inputs.
3840

3941
levels = np.array([-5, 5, -3, 3, -1, 1])
40-
fig, ax = plt.subplots(figsize=(20, 5))
42+
fig, ax = plt.subplots(figsize=(8, 5))
4143

4244
# Create the base line
4345
start = min(dates)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.