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
1acada96
Commit
1acada96
authored
Sep 09, 2014
by
Mario Hock
Browse files
set_xlim
parent
5e6e7e80
Changes
1
Hide whitespace changes
Inline
Side-by-side
simple_plotter.py
View file @
1acada96
...
@@ -56,6 +56,8 @@ def parse_cnl_file(filename):
...
@@ -56,6 +56,8 @@ def parse_cnl_file(filename):
return
cnl_file
return
cnl_file
def
get_min_max_x
(
cnl_file
):
return
(
cnl_file
.
cols
[
"begin"
][
0
],
cnl_file
.
cols
[
"end"
][
-
1
]
)
def
plot
(
ax
,
x_values
,
cols
,
active_cols
,
alpha
,
**
kwargs
):
def
plot
(
ax
,
x_values
,
cols
,
active_cols
,
alpha
,
**
kwargs
):
...
@@ -176,6 +178,9 @@ if __name__ == "__main__":
...
@@ -176,6 +178,9 @@ if __name__ == "__main__":
num_cols
=
2
num_cols
=
2
min_x
=
None
max_x
=
None
old_ax_net
=
None
old_ax_net
=
None
old_ax_cpu
=
None
old_ax_cpu
=
None
for
i
in
range
(
0
,
num_files
):
for
i
in
range
(
0
,
num_files
):
...
@@ -183,10 +188,22 @@ if __name__ == "__main__":
...
@@ -183,10 +188,22 @@ if __name__ == "__main__":
filename
=
args
.
files
[
i
]
filename
=
args
.
files
[
i
]
cnl_file
=
parse_cnl_file
(
filename
)
cnl_file
=
parse_cnl_file
(
filename
)
## update min_x / max_x
min_max
=
get_min_max_x
(
cnl_file
)
if
(
not
min_x
or
min_x
>
min_max
[
0
]
):
min_x
=
min_max
[
0
]
if
(
not
max_x
or
max_x
<
min_max
[
1
]
):
max_x
=
min_max
[
1
]
## show some output
print
(
filename
)
print
(
filename
)
print
(
pretty_json
(
cnl_file
.
get_general_header
())
)
print
(
pretty_json
(
cnl_file
.
get_general_header
())
)
print
()
print
()
## Plot with matplotlib.
## Plot with matplotlib.
## Draw comment on the figure (use absolute positioning).
## Draw comment on the figure (use absolute positioning).
...
@@ -217,6 +234,11 @@ if __name__ == "__main__":
...
@@ -217,6 +234,11 @@ if __name__ == "__main__":
old_ax_cpu
=
ax_cpu
old_ax_cpu
=
ax_cpu
## set min/max (remember: The x-axis is shared.)
margin
=
max
(
(
max_x
-
min_x
)
*
0.03
,
10
)
ax_net
.
set_xlim
(
min_x
-
margin
,
max_x
+
margin
)
## If we have only one input file, plot CPU area charts.
## If we have only one input file, plot CPU area charts.
if
(
num_files
==
1
):
if
(
num_files
==
1
):
ax1
=
fig
.
add_subplot
(
2
,
num_cols
,
2
,
sharex
=
old_ax_net
,
sharey
=
old_ax_cpu
)
ax1
=
fig
.
add_subplot
(
2
,
num_cols
,
2
,
sharex
=
old_ax_net
,
sharey
=
old_ax_cpu
)
...
@@ -227,12 +249,11 @@ if __name__ == "__main__":
...
@@ -227,12 +249,11 @@ if __name__ == "__main__":
## maximize window
## maximize window
if
(
num_files
>
1
or
True
):
## XXX always maximize?
try
:
try
:
figManager
=
plt
.
get_current_fig_manager
()
figManager
=
plt
.
get_current_fig_manager
()
figManager
.
window
.
showMaximized
()
figManager
.
window
.
showMaximized
()
except
:
except
:
pass
pass
# show plot
# show plot
plt
.
show
()
plt
.
show
()
Write
Preview
Markdown
is supported
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