Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
uahil
CPUnetPLOT
Commits
5bf8866a
Commit
5bf8866a
authored
Aug 11, 2014
by
Mario Hock
Browse files
some very basic matplotlib output
parent
8da0be9f
Changes
1
Hide whitespace changes
Inline
Side-by-side
simple_plotter.py
View file @
5bf8866a
...
...
@@ -2,11 +2,22 @@
# -*- coding:utf-8 -*-
import
sys
import
matplotlib
import
matplotlib
.pyplot
as
plt
from
cnl_library
import
CNLParser
def
append_twice
(
base_list
,
extend_list
):
if
(
isinstance
(
extend_list
,
list
)
):
for
x
in
extend_list
:
base_list
.
append
(
x
)
base_list
.
append
(
x
)
else
:
base_list
.
append
(
extend_list
)
base_list
.
append
(
extend_list
)
## MAIN ##
if
__name__
==
"__main__"
:
...
...
@@ -27,8 +38,37 @@ if __name__ == "__main__":
## Display some csv/data fields.
names
=
None
names
=
[
"eth0.send"
,
"eth0.receive"
]
names
=
[
"begin"
,
"end"
,
"eth0.send"
,
"eth0.receive"
]
print
(
names
)
### Prepare lists for matplotlib.
#x_values = list()
#y1_values = list()
#y2_values = list()
#for x in cnl_file.get_csv_iterator(names):
#x_values.extend( x[0:2] )
#append_twice( y1_values, x[2] )
#append_twice( y2_values, x[3] )
## Prepare lists for matplotlib.
x_values
=
list
()
y1_values
=
list
()
y2_values
=
list
()
for
x
in
cnl_file
.
get_csv_iterator
(
names
):
print
(
", "
.
join
(
x
)
)
x_values
.
append
(
x
[
1
]
)
y1_values
.
append
(
x
[
2
]
)
y2_values
.
append
(
x
[
3
]
)
## Plot with matplotlib.
print
(
x_values
)
print
(
y1_values
)
print
(
y2_values
)
plt
.
plot
(
x_values
,
y1_values
)
plt
.
plot
(
x_values
,
y2_values
)
#plt.ylabel('some numbers')
plt
.
show
()
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment