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
aab22316
Commit
aab22316
authored
Aug 15, 2014
by
Mario Hock
Browse files
sharex/y, legend placement, (QT)
parent
cec11b63
Changes
1
Hide whitespace changes
Inline
Side-by-side
simple_plotter.py
View file @
aab22316
...
...
@@ -3,10 +3,12 @@
import
sys
import
matplotlib
import
matplotlib.pyplot
as
plt
from
cnl_library
import
CNLParser
,
calc_ema
## matplotlib.use('QT4Agg') # override matplotlibrc
import
matplotlib.pyplot
as
plt
def
append_twice
(
base_list
,
extend_list
):
if
(
isinstance
(
extend_list
,
list
)
):
...
...
@@ -68,9 +70,10 @@ def plot_net(ax, x_values, cols, active_cols):
for
col_name
in
active_cols
:
ax
.
plot
(
x_values
,
cols
[
col_name
],
label
=
col_name
)
ax
.
plot
(
x_values
,
calc_ema
(
cols
[
col_name
],
0.2
),
label
=
col_name
+
" (ema)"
)
#
ax.plot(x_values , calc_ema(cols[col_name], 0.2), label=col_name+" (ema)")
ax
.
legend
()
#ax.legend(loc=0)
ax
.
legend
(
loc
=
8
)
def
plot_cpu
(
ax
,
x_values
,
cols
,
active_cols
):
...
...
@@ -81,7 +84,8 @@ def plot_cpu(ax, x_values, cols, active_cols):
ax
.
plot
(
x_values
,
cols
[
col_name
],
label
=
col_name
)
#ax2.plot(x_values , calc_ema(cols[col_name], 0.2), label=col_name+" (ema)")
ax
.
legend
()
#ax.legend(loc=0)
ax
.
legend
(
loc
=
1
)
...
...
@@ -95,7 +99,8 @@ if __name__ == "__main__":
fig
=
plt
.
figure
()
fig
.
canvas
.
set_window_title
(
'CPUnetPlot'
)
old_ax_net
=
None
old_ax_cpu
=
None
for
i
in
range
(
1
,
num_files
+
1
):
## Read file
filename
=
sys
.
argv
[
i
]
...
...
@@ -110,8 +115,8 @@ if __name__ == "__main__":
## Prepare subplots
ax_net
=
fig
.
add_subplot
(
2
,
num_files
,
i
)
ax_cpu
=
fig
.
add_subplot
(
2
,
num_files
,
i
+
num_files
,
sharex
=
ax_net
)
ax_net
=
fig
.
add_subplot
(
2
,
num_files
,
i
,
sharex
=
old_ax_net
,
sharey
=
old_ax_net
)
ax_cpu
=
fig
.
add_subplot
(
2
,
num_files
,
i
+
num_files
,
sharex
=
ax_net
,
sharey
=
old_ax_cpu
)
#ax_net = fig.add_subplot(111) ## twin
#ax_cpu = ax_net.twinx() ## twin
...
...
@@ -119,4 +124,17 @@ if __name__ == "__main__":
plot_net
(
ax_net
,
cnl_file
.
x_values
,
cnl_file
.
cols
,
cnl_file
.
net_col_names
)
plot_cpu
(
ax_cpu
,
cnl_file
.
x_values
,
cnl_file
.
cols
,
cnl_file
.
cpu_col_names
)
old_ax_net
=
ax_net
old_ax_cpu
=
ax_cpu
## maximiza window
if
(
num_files
>
1
):
try
:
figManager
=
plt
.
get_current_fig_manager
()
figManager
.
window
.
showMaximized
()
except
:
pass
# show plot
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