Skip to content

Commit

Permalink
fix: fixes lines between layers in cross-sections
Browse files Browse the repository at this point in the history
  • Loading branch information
mdtanker committed Jan 29, 2024
1 parent 48ce7a7 commit 7eaaf64
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions src/polartoolkit/profile.py
Expand Up @@ -769,25 +769,26 @@ def plot_profile(

# plot colored df_layers
for i, (k, v) in enumerate(layers_dict.items()):
# fill in layers and draw lines between
if kwargs.get("fill_layers", True) is True:
fig.plot(
x=df_layers.dist,
y=df_layers[k],
# close the polygons,
close="+yb",
close="+yb", # close the polygons,
fill=v["color"],
frame=kwargs.get("layers_frame", ["nSew", "a"]),
transparency=kwargs.get(
"layer_transparency", [0] * len(layers_dict.items())
)[i],
label=v["name"],
)
# plot lines between df_layers
layers_pen = kwargs.get("layers_pen")
if isinstance(layers_pen, list):
layers_pen = layers_pen[i]
# if pen properties supplied, use then
if layers_pen is not None:
pen = layers_pen
# if not, get pen properties from kwargs
else:
thick = kwargs.get("layers_pen_thickness", 1)
if isinstance(thick, (float, int)):
Expand All @@ -797,27 +798,34 @@ def plot_profile(
if isinstance(color, list):
color = color[i]
if color is None:
# color = v["color"]
color = "black"

style = kwargs.get("layers_pen_style", None)
if isinstance(style, list):
style = style[i]
if style is None:
style = ""
pen = f"{thick[i]}p,{color},{style}"
pen = f"{thick[i]}p,{color},{style}"

layers_line_style = kwargs.get("layers_line_style", None)
if isinstance(layers_line_style, list):
layers_line_style = layers_line_style[i]

# plot lines between df_layers
fig.plot(
x=df_layers.dist,
y=df_layers[k],
pen=pen,
style=layers_line_style,
)

# plot transparent lines to get legend
fig.plot(
x=df_layers.dist,
y=df_layers[k],
pen=f"5p,{v['color']}",
label=v["name"],
transparency=100,
)
# dont fill layers, just draw lines
else:
if kwargs.get("layers_line_cmap", None) is None:
# get pen properties
Expand All @@ -842,7 +850,7 @@ def plot_profile(
style = style[i]
if style is None:
style = ""
pen = f"{thick[i]}p,{color},{style}"
pen = f"{thick[i]}p,{color},{style}"

fig.plot(
x=df_layers.dist,
Expand All @@ -865,7 +873,7 @@ def plot_profile(
y=df_layers[k],
pen=f"{kwargs.get('layer_pen', [1]*len(layers_dict.items()))[i]}p,+z", # noqa: E501
frame=kwargs.get("layers_frame", ["nSew", "a"]),
label=v["name"],
# label=v["name"],
cmap=True,
zvalue=v["color"],
)
Expand Down

0 comments on commit 7eaaf64

Please sign in to comment.