Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DetectorWriteSim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
EWMSCP
DetectorWriteSim
Commits
fe9e532c
Commit
fe9e532c
authored
1 year ago
by
Michael Reuscher
Browse files
Options
Downloads
Patches
Plain Diff
New save for Plots
parent
a21584d8
No related branches found
No related tags found
1 merge request
!4
Python driver and data analysis part
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
visualizer/visualizer/SeabornPlotter.py
+20
-9
20 additions, 9 deletions
visualizer/visualizer/SeabornPlotter.py
visualizer/visualizer/main.py
+5
-3
5 additions, 3 deletions
visualizer/visualizer/main.py
with
25 additions
and
12 deletions
visualizer/visualizer/SeabornPlotter.py
+
20
−
9
View file @
fe9e532c
import
numpy
as
np
import
matplotlib.pyplot
as
plt
import
pandas
as
pd
import
seaborn
as
sns
from
matplotlib.offsetbox
import
OffsetImage
,
AnnotationBbox
import
os
...
...
@@ -8,9 +7,16 @@ sns.set_theme()
class
SeabornPlotter
:
def
__init__
(
self
,
dataframe
,
name
):
def
__init__
(
self
,
dataframe
,
name
,
data_path
):
self
.
dataframe
=
dataframe
self
.
name
=
name
self
.
path
=
os
.
path
.
join
(
data_path
,
"
Plots
"
)
def
_make_folder
(
self
,
folder_name
):
folder
=
os
.
path
.
join
(
self
.
path
,
folder_name
)
if
not
os
.
path
.
exists
(
folder
):
os
.
makedirs
(
folder
)
return
folder
@staticmethod
def
_add_logo
(
logo_path
,
logo_size
,
logo_x
,
logo_y
):
...
...
@@ -33,6 +39,7 @@ class SeabornPlotter:
def
plot_histogram_various
(
self
):
df
=
self
.
dataframe
folder
=
self
.
_make_folder
(
'
Various_Events
'
)
x
=
df
[
'
size
'
]
y
=
df
[
'
duration
'
]
title
=
"
Procedure: {}
"
.
format
(
self
.
name
)
...
...
@@ -47,11 +54,13 @@ class SeabornPlotter:
plt
.
title
(
title
)
plt
.
grid
(
True
)
plt
.
xticks
(
rotation
=
45
)
plt
.
savefig
(
title
+
"
.svg
"
,
format
=
'
svg
'
)
plt
.
show
()
plt
.
savefig
(
os
.
path
.
join
(
folder
,
f
"
{
title
}
.svg
"
))
plt
.
close
()
def
plot_histogram_long
(
self
):
df
=
self
.
dataframe
folder
=
self
.
_make_folder
(
'
Long_Events
'
)
x
=
df
[
'
seconds_since_start
'
]
y
=
df
[
'
duration
'
]
title
=
"
Long Procedure: {}
"
.
format
(
self
.
name
)
...
...
@@ -65,12 +74,13 @@ class SeabornPlotter:
plt
.
title
(
title
)
plt
.
grid
(
True
)
plt
.
xticks
(
rotation
=
45
)
plt
.
savefig
(
title
+
"
.svg
"
,
format
=
'
svg
'
)
plt
.
show
()
plt
.
savefig
(
os
.
path
.
join
(
folder
,
f
"
{
title
}
.svg
"
))
plt
.
close
()
def
plot_statistics
(
self
):
dataframes
=
self
.
dataframe
folder
=
self
.
_make_folder
(
'
Statistics
'
)
for
df_key
,
df
in
dataframes
.
items
():
operations
=
df
[
'
Group
'
].
unique
()
num_plots
=
len
(
operations
)
...
...
@@ -93,5 +103,6 @@ class SeabornPlotter:
ax
.
grid
(
True
)
ax
.
set_ylim
(
bottom
=
global_min_speed
,
top
=
global_max_speed
)
# Set the Y-axis limits
plt
.
savefig
(
df_key
+
"
.svg
"
,
format
=
'
svg
'
)
plt
.
show
()
plt
.
savefig
(
os
.
path
.
join
(
folder
,
f
"
{
df_key
}
.svg
"
))
plt
.
close
()
This diff is collapsed.
Click to expand it.
visualizer/visualizer/main.py
+
5
−
3
View file @
fe9e532c
import
argparse
import
os
import
matplotlib
from
.DataFrameCreator
import
DataFrameCreator
from
.SeabornPlotter
import
SeabornPlotter
...
...
@@ -13,13 +14,14 @@ def main():
parser
.
add_argument
(
"
-d
"
,
"
--data_path
"
,
required
=
True
,
help
=
"
path to Data from Sim
"
)
args
=
parser
.
parse_args
()
data_path
=
args
.
data_path
statistics_path
=
os
.
path
.
abspath
(
os
.
path
.
join
(
data_path
,
os
.
pardir
))
# Import Data
creator
=
DataFrameCreator
(
data_path
)
v_dataframes
,
l_dataframes
,
s_dataframes
=
creator
.
create
()
# Plot Statistics
s_plotter
=
SeabornPlotter
(
s_dataframes
,
'
statistics
'
)
s_plotter
=
SeabornPlotter
(
s_dataframes
,
'
statistics
'
,
statistics_path
)
s_plotter
.
plot_statistics
()
# Plot Data
...
...
@@ -27,7 +29,7 @@ def main():
if
not
v_dataframes
[
frame
].
empty
:
# Setup Plotter
frame_name
=
frame
v_plotter
=
SeabornPlotter
(
v_dataframes
[
frame
],
frame_name
)
v_plotter
=
SeabornPlotter
(
v_dataframes
[
frame
],
frame_name
,
statistics_path
)
# Plotter run
v_plotter
.
plot_histogram_various
()
...
...
@@ -35,7 +37,7 @@ def main():
if
not
v_dataframes
[
frame
].
empty
:
# Setup Plotter
frame_name
=
frame
l_plotter
=
SeabornPlotter
(
l_dataframes
[
frame
],
frame_name
)
l_plotter
=
SeabornPlotter
(
l_dataframes
[
frame
],
frame_name
,
statistics_path
)
# Plotter run
l_plotter
.
plot_histogram_long
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment