File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- #!/usr/bin/env python
2- # -*- noplot -*-
31import time
4- from pylab import *
2+ import matplotlib .pyplot as plt
3+ import numpy as np
54
65
76def get_memory ():
87 "Simulate a function that returns system memory"
9- return 100 * (0.5 + 0.5 * sin (0.5 * pi * time .time ()))
8+ return 100 * (0.5 + 0.5 * np . sin (0.5 * np . pi * time .time ()))
109
1110
1211def get_cpu ():
1312 "Simulate a function that returns cpu usage"
14- return 100 * (0.5 + 0.5 * sin (0.2 * pi * (time .time () - 0.25 )))
13+ return 100 * (0.5 + 0.5 * np . sin (0.2 * np . pi * (time .time () - 0.25 )))
1514
1615
1716def get_net ():
1817 "Simulate a function that returns network bandwidth"
19- return 100 * (0.5 + 0.5 * sin (0.7 * pi * (time .time () - 0.1 )))
18+ return 100 * (0.5 + 0.5 * np . sin (0.7 * np . pi * (time .time () - 0.1 )))
2019
2120
2221def get_stats ():
2322 return get_memory (), get_cpu (), get_net ()
2423
24+
2525# turn interactive mode on for dynamic updates. If you aren't in
2626# interactive mode, you'll need to use a GUI event handler/timer.
27- ion ()
27+ plt . ion ()
2828
2929fig , ax = plt .subplots ()
30- ind = arange (1 , 4 )
31- pm , pc , pn = bar (ind , get_stats ())
30+ ind = np . arange (1 , 4 )
31+ pm , pc , pn = plt . bar (ind , get_stats ())
3232centers = ind + 0.5 * pm .get_width ()
3333pm .set_facecolor ('r' )
3434pc .set_facecolor ('g' )
@@ -48,4 +48,4 @@ def get_stats():
4848 pn .set_height (n )
4949 ax .set_ylim ([0 , 100 ])
5050
51- draw ()
51+ plt . draw ()
You can’t perform that action at this time.
0 commit comments