Skip to content

Commit

Permalink
chore(SBR): use Line2D in plot legend
Browse files Browse the repository at this point in the history
  • Loading branch information
RDWimmers committed Jul 15, 2024
1 parent 9cfba54 commit 731ee77
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
23 changes: 20 additions & 3 deletions src/pyvibracore/results/nuisance.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from matplotlib.lines import Line2D
from numpy.typing import NDArray
from scipy.interpolate import interp1d
from shapely.geometry import LineString, Point, Polygon
Expand Down Expand Up @@ -259,14 +260,17 @@ def map_nuisance(
"source_location": {"label": "Trillingsbron", "color": "blue"},
"levels": [
{
"key": "<= 1 day",
"label": "<= 1 day",
"color": "darkred",
},
{
"key": ">= 6 days; <26 days",
"label": ">= 6 days; <26 days",
"color": "orange",
},
{
"key": ">= 26 days; <78 days",
"label": ">= 26 days; <78 days",
"color": "green",
},
Expand All @@ -284,14 +288,17 @@ def map_nuisance(
"source_location": {"label": "Trillingsbron", "color": "blue"},
"levels": [
{
"key": "<= 1 day",
"label": "<= 1 day",
"color": "darkred",
},
{
"key": ">= 6 days; <26 days",
"label": ">= 6 days; <26 days",
"color": "orange",
},
{
"key": ">= 26 days; <78 days",
"label": ">= 26 days; <78 days",
"color": "green",
},
Expand Down Expand Up @@ -327,7 +334,7 @@ def map_nuisance(
_get_target_value(
vibration_type,
building_function=building["gebruiksdoel"].item(),
)[values["label"]]
)[values["key"]]
for values in settings["levels"]
]
arr = np.array(response_dict["data"]["vibrationVelocity"]) / response_dict[
Expand Down Expand Up @@ -372,12 +379,22 @@ def map_nuisance(
loc="lower right",
handles=[
patches.Patch(
facecolor=value["color"],
label=value["label"],
facecolor=settings["source_location"]["color"],
label=settings["source_location"]["label"],
alpha=0.9,
linewidth=2,
edgecolor="black",
)
]
+ [
Line2D(
[0],
[0],
color=value["color"],
label=value["label"],
alpha=0.9,
linewidth=2,
)
for value in settings["levels"]
],
)
Expand Down
15 changes: 13 additions & 2 deletions src/pyvibracore/results/sound_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from matplotlib.lines import Line2D
from numpy.typing import NDArray
from scipy import interpolate
from shapely.geometry import LineString, Point, Polygon
Expand Down Expand Up @@ -220,12 +221,22 @@ def map_sound(
loc="lower right",
handles=[
patches.Patch(
facecolor=value["color"],
label=value["label"],
facecolor=settings["source_location"]["color"],
label=settings["source_location"]["label"],
alpha=0.9,
linewidth=2,
edgecolor="black",
)
]
+ [
Line2D(
[0],
[0],
color=value["color"],
label=value["label"],
alpha=0.9,
linewidth=2,
)
for value in settings["levels"]
],
)
Expand Down

0 comments on commit 731ee77

Please sign in to comment.