Skip to content

Commit

Permalink
🐛 Fix ZoneStyle definition when linewidth is 0
Browse files Browse the repository at this point in the history
and linestyle remains the default (passing inconsistent params to matplotlib)
  • Loading branch information
azogue committed Jun 13, 2023
1 parent 1e2d691 commit 954f29f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- ✨ Add new kind of overlay **zone 'dbt-wmax'**, to define chart areas delimited between db-temps and absolute humidity values, solving #28
- 🐛 Enable zones defined by 2 points (assume a rectangle defined by left-bottom/right-top coords)
- 🐛 Fix logic for plot regeneration, to plot again if config changes _AFTER_ plotting the chart
- 🐛 Fix ZoneStyle definition when linewidth is 0 and linestyle remains the default (passing inconsistent params to matplotlib)

## [0.9.0] - ✨ More kinds of chart zones + CSS for SVG styling - 2023-06-12

Expand Down
5 changes: 4 additions & 1 deletion psychrochart/models/styles.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,8 @@ def _color_arr(cls, v, values):
return parse_color(v)

@root_validator(pre=True)
def _remove_aliases(cls, values):
def _remove_aliases_and_fix_defaults(cls, values):
if values.get("linewidth", 2) == 0:
# avoid matplotlib error with inconsistent line parameters
values["linestyle"] = "-"
return reduce_field_abrs(values)
7 changes: 1 addition & 6 deletions tests/test_chart_zones.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,12 +252,7 @@ def test_sat_no_sat_zones():
zone_type="dbt-wmax",
points_x=[chart.config.dbt_min, chart.config.dbt_max],
points_y=[chart.config.w_min, chart.config.w_max],
style=ZoneStyle(
edgecolor="none",
facecolor="#C8E44088",
linewidth=0,
linestyle="-",
),
style=ZoneStyle(edgecolor="k", facecolor="#e4a039", linewidth=0),
)
)
chart.plot_over_saturated_zone(color_fill="#5A90E4")
Expand Down

0 comments on commit 954f29f

Please sign in to comment.