Skip to content

Commit c470514

Browse files
committed
Merge branch 'develop' of https://github.com/PlotPyStack/PlotPy into develop
2 parents 6ca198d + 7f6b428 commit c470514

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

plotpy/styles/base.py

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,15 @@ def style_generator(color_keys="bgrcmykG"):
168168
yield color + linestyle
169169

170170

171-
def update_style_attr(style, param):
172-
"""Parse a MATLAB-like style string and
173-
update the color, linestyle, marker attributes of the param
174-
object
171+
def update_style_attr(style: str, param) -> None:
172+
"""Parse a MATLAB-like style string.
173+
174+
Example: 'r--o' for red dashed line with circle markers
175+
176+
Also accepts HTML colors like '#ff0000'.
177+
178+
Args:
179+
style: style string
175180
"""
176181
for marker in list(MARKERS.keys()):
177182
if marker in style:
@@ -185,12 +190,18 @@ def update_style_attr(style, param):
185190
break
186191
else:
187192
param.line.style = "NoPen"
188-
for color in list(COLORS.keys()):
189-
if color in style:
190-
param.line.color = COLORS[color]
191-
param.symbol.facecolor = COLORS[color]
192-
param.symbol.edgecolor = COLORS[color]
193+
color = "black"
194+
for style_str in style:
195+
if style_str.startswith("#"): # HTML color
196+
color = style_str[:7]
197+
break
198+
for color_letter in list(COLORS.keys()):
199+
if color_letter in style:
200+
color = COLORS[color_letter]
193201
break
202+
param.line.color = color
203+
param.symbol.facecolor = color
204+
param.symbol.edgecolor = color
194205

195206

196207
class ItemParameters:

0 commit comments

Comments
 (0)