Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
MLAir
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
esde
machine-learning
MLAir
Commits
9bf9966b
Commit
9bf9966b
authored
5 years ago
by
lukas leufen
Browse files
Options
Downloads
Patches
Plain Diff
legend on top
parent
45ce6195
No related branches found
No related tags found
3 merge requests
!90
WIP: new release update
,
!89
Resolve "release branch / CI on gpu"
,
!88
added summary and combined Gantt plot
Pipeline
#34335
passed
5 years ago
Stage: test
Stage: pages
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/plotting/postprocessing_plotting.py
+17
-14
17 additions, 14 deletions
src/plotting/postprocessing_plotting.py
with
17 additions
and
14 deletions
src/plotting/postprocessing_plotting.py
+
17
−
14
View file @
9bf9966b
...
...
@@ -16,6 +16,7 @@ import pandas as pd
import
seaborn
as
sns
import
xarray
as
xr
from
matplotlib.backends.backend_pdf
import
PdfPages
import
matplotlib.patches
as
mpatches
from
src
import
helpers
from
src.helpers
import
TimeTracking
,
TimeTrackingWrapper
...
...
@@ -33,14 +34,14 @@ class AbstractPlotClass:
def
_plot
(
self
,
*
args
):
raise
NotImplementedError
def
_save
(
self
):
def
_save
(
self
,
**
kwargs
):
"""
Standard save method to store plot locally. Name of and path to plot need to be set on initialisation
"""
plot_name
=
os
.
path
.
join
(
os
.
path
.
abspath
(
self
.
plot_folder
),
f
"
{
self
.
plot_name
}
.pdf
"
)
logging
.
debug
(
f
"
... save plot to
{
plot_name
}
"
)
plt
.
savefig
(
plot_name
,
dpi
=
self
.
resolution
)
plt
.
savefig
(
plot_name
,
dpi
=
self
.
resolution
,
**
kwargs
)
plt
.
close
(
'
all
'
)
...
...
@@ -632,18 +633,18 @@ class PlotAvailability(AbstractPlotClass):
super
().
__init__
(
plot_folder
,
"
data_availability
"
)
self
.
sampling
=
self
.
_get_sampling
(
sampling
)
plot_dict
=
self
.
_prepare_data
(
generators
)
self
.
_plot
(
plot_dict
)
self
.
_save
()
lgd
=
self
.
_plot
(
plot_dict
)
self
.
_save
(
bbox_extra_artists
=
(
lgd
,
),
bbox_inches
=
"
tight
"
)
# create summary Gantt plot (is data in at least one station available)
self
.
plot_name
+=
"
_summary
"
plot_dict_summary
=
self
.
_summarise_data
(
generators
,
summary_name
)
self
.
_plot
(
plot_dict_summary
)
self
.
_save
()
lgd
=
self
.
_plot
(
plot_dict_summary
)
self
.
_save
(
bbox_extra_artists
=
(
lgd
,
),
bbox_inches
=
"
tight
"
)
# combination of station and summary plot, last element is summary broken bar
self
.
plot_name
=
"
data_availability_combined
"
plot_dict_summary
.
update
(
plot_dict
)
self
.
_plot
(
plot_dict_summary
)
self
.
_save
()
lgd
=
self
.
_plot
(
plot_dict_summary
)
self
.
_save
(
bbox_extra_artists
=
(
lgd
,
),
bbox_inches
=
"
tight
"
)
@staticmethod
def
_get_sampling
(
sampling
):
...
...
@@ -698,14 +699,14 @@ class PlotAvailability(AbstractPlotClass):
def
_plot
(
self
,
plt_dict
):
# colors = {"train": "orange", "val": "
sky
blue", "test": "blue
ishgreen
"} # color names
colors
=
{
"
train
"
:
"
#e69f00
"
,
"
val
"
:
"
#
56b4e9
"
,
"
test
"
:
"
#
009e73
"
}
# hex code
# colors = {"train": (230, 159, 0), "val": (
86
, 1
80, 233
), "test": (
0
, 1
58, 115
)} # in rgb but as abs values
# colors = {"train": "orange", "val": "blue
ishgreen
", "test": "
sky
blue"} # color names
colors
=
{
"
train
"
:
"
#e69f00
"
,
"
val
"
:
"
#
009e73
"
,
"
test
"
:
"
#
56b4e9
"
}
# hex code
# colors = {"train": (230, 159, 0), "val": (
0
, 1
58, 115
), "test": (
86
, 1
80, 233
)} # in rgb but as abs values
pos
=
0
height
=
0.8
# should be <= 1
yticklabels
=
[]
number_of_stations
=
len
(
plt_dict
.
keys
())
fig
,
ax
=
plt
.
subplots
(
figsize
=
(
10
,
max
([
number_of_stations
/
3
,
1
])
))
fig
,
ax
=
plt
.
subplots
(
figsize
=
(
10
,
number_of_stations
/
3
))
for
station
,
d
in
sorted
(
plt_dict
.
items
(),
reverse
=
True
):
pos
+=
1
for
subset
,
color
in
colors
.
items
():
...
...
@@ -718,4 +719,6 @@ class PlotAvailability(AbstractPlotClass):
ax
.
set_ylim
([
height
,
number_of_stations
+
1
])
ax
.
set_yticks
(
np
.
arange
(
len
(
plt_dict
.
keys
()))
+
1
+
height
/
2
)
ax
.
set_yticklabels
(
yticklabels
)
plt
.
tight_layout
()
handles
=
[
mpatches
.
Patch
(
color
=
c
,
label
=
k
)
for
k
,
c
in
colors
.
items
()]
lgd
=
plt
.
legend
(
handles
=
handles
,
bbox_to_anchor
=
(
0
,
1
,
1
,
0.2
),
loc
=
"
lower center
"
,
ncol
=
len
(
handles
))
return
lgd
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