Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
uyegy
CPUnetPLOT
Commits
e4427ec8
Commit
e4427ec8
authored
Aug 13, 2014
by
Mario Hock
Browse files
some improvements/cleanups after reading the docu
- subplot - twin axes - text
parent
d3a66a1d
Changes
1
Hide whitespace changes
Inline
Side-by-side
simple_plotter.py
View file @
e4427ec8
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
# -*- coding:utf-8 -*-
# -*- coding:utf-8 -*-
import
sys
import
sys
import
matplotlib
import
matplotlib.pyplot
as
plt
import
matplotlib.pyplot
as
plt
from
cnl_library
import
CNLParser
,
calc_ema
from
cnl_library
import
CNLParser
,
calc_ema
...
@@ -58,35 +59,40 @@ if __name__ == "__main__":
...
@@ -58,35 +59,40 @@ if __name__ == "__main__":
## Plot with matplotlib.
## Plot with matplotlib.
#
Twin plot
#
# Create figure (window/file)
# (see http://matplotlib.org/examples/api/two_scales.html
)
fig
=
plt
.
figure
(
)
#
fig, ax1 = plt.subplots() ## twin
#
# Draw comment on the figure.
fig
,
axes
=
plt
.
subplots
(
2
,
1
,
sharex
=
True
)
t
=
matplotlib
.
text
.
Text
(
10
,
10
,
"Comment: "
+
cnl_file
.
get_comment
(),
figure
=
fig
)
(
ax1
,
ax2
)
=
axes
fig
.
texts
.
append
(
t
)
#plt.title( cnl_file.get_comment() )
#plt.title( cnl_file.get_comment() )
plt
.
figtext
(
0.01
,
0.02
,
"Comment: "
+
cnl_file
.
get_comment
())
#plt.figtext(0.01, 0.02, "Comment: " + cnl_file.get_comment())
#plt.figtext(0.01, 0.99, "Hallo ;-)")
plt
.
ylim
(
0
,
10
**
10
)
ax_net
=
fig
.
add_subplot
(
211
)
ax1
.
set_ylabel
(
'Throughput (Bit/s)'
)
#ax_net = fig.add_subplot(111) ## twin
ax_net
.
set_ylim
(
0
,
10
**
10
)
ax_net
.
set_ylabel
(
'Throughput (Bit/s)'
)
for
col_name
in
net_cols
:
for
col_name
in
net_cols
:
ax1
.
plot
(
x_values
,
cols
[
col_name
],
label
=
col_name
)
ax_net
.
plot
(
x_values
,
cols
[
col_name
],
label
=
col_name
)
ax1
.
plot
(
x_values
,
calc_ema
(
cols
[
col_name
],
0.2
),
label
=
col_name
+
" (ema)"
)
ax_net
.
plot
(
x_values
,
calc_ema
(
cols
[
col_name
],
0.2
),
label
=
col_name
+
" (ema)"
)
ax_net
.
legend
()
ax1
.
legend
()
#ax2 = ax1.twinx() ## twin
#ax_cpu = ax_net.twinx() ## twin
plt
.
ylim
(
0
,
100
)
ax_cpu
=
fig
.
add_subplot
(
212
,
sharex
=
ax_net
)
ax2
.
set_ylabel
(
'CPU util (%)'
)
ax_cpu
.
set_ylim
(
0
,
100
)
ax_cpu
.
set_ylabel
(
'CPU util (%)'
)
for
col_name
in
cpu_cols
:
for
col_name
in
cpu_cols
:
ax
2
.
plot
(
x_values
,
cols
[
col_name
],
label
=
col_name
)
ax
_cpu
.
plot
(
x_values
,
cols
[
col_name
],
label
=
col_name
)
#ax2.plot(x_values , calc_ema(cols[col_name], 0.2), label=col_name+" (ema)")
#ax2.plot(x_values , calc_ema(cols[col_name], 0.2), label=col_name+" (ema)")
ax
2
.
legend
()
ax
_cpu
.
legend
()
plt
.
show
()
plt
.
show
()
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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