merged in all the code from ariel's branches and moved wikibios to a subdir
[matplotlib-cdsw] / 003-plot-timeseries.py
1 """ 
2 003-plot-timeseries.py 
3
4 Plot data from the Harry Potter data-set as a time-series
5
6 """ 
7
8
9 import matplotlib.pyplot as plt 
10 import load_hp_data as hp
11
12 # We can play with styles:
13 #plt.style.use('bmh')
14 plt.style.use('ggplot') 
15 # To see available styles, type: 
16 #plt.style.available
17
18 fig, ax = plt.subplots(1)
19 ax.plot(hp.columns['timestamp'],  hp.columns['size'])
20 ax.set_xlabel('Time')
21 ax.set_ylabel('Size of the edit')
22
23 plt.show()
24
25
26 # Challenge: Is edit size related to how long it's been since the last edit? 
27 # => Plot the relationship between edit size and the time since the last edit:
28
29 ## Hint 1: the number of seconds between two edits is: 
30
31 #delta_time1 = (hp.columns['timestamp'][1] - hp.columns['timestamp'][0]).total_seconds()
32
33 ## Hint 2: 
34
35 # You can give `plt.plot` more arguments to control the shape/size/color 
36 # of the markers used. For example, try: 
37
38 # ax.plot([1,2,3], [2,4,8], '.')
39 # ax.plot([1,2,3], [2,4,8], 'r.')
40
41 # And see online documentation here: 
42 # http://matplotlib.org/api/pyplot_summary.html
43 # http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.plot
44
45

Benjamin Mako Hill || Want to submit a patch?