Skip to content

Commit bfc3921

Browse files
committed
fix(legend): use correct marker colors and ignore 'none' linestyle\n\n- Set legend marker edge/face colors from entry color before drawing\n- Treat 'none'/'None' as no line in legend line samples
1 parent 4a9a365 commit bfc3921

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/ui/fortplot_legend.f90

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -315,9 +315,9 @@ subroutine render_legend_line(entry, backend, line_x1, line_x2, line_center_y)
315315
! Set color
316316
call backend%color(entry%color(1), entry%color(2), entry%color(3))
317317

318-
! Draw line if style permits
318+
! Draw line if style permits (treat 'none'/'None' as no line)
319319
if (allocated(entry%linestyle)) then
320-
if (entry%linestyle /= 'None') then
320+
if (trim(entry%linestyle) /= 'None' .and. trim(entry%linestyle) /= 'none') then
321321
call backend%line(line_x1, line_center_y, line_x2, line_center_y)
322322
end if
323323
else
@@ -331,9 +331,12 @@ subroutine render_legend_marker(entry, backend, line_x1, line_x2, line_center_y)
331331
class(plot_context), intent(inout) :: backend
332332
real(wp), intent(in) :: line_x1, line_x2, line_center_y
333333

334-
! Draw marker in the middle of the line
334+
! Draw marker in the middle of the line, using entry color
335335
if (allocated(entry%marker)) then
336-
if (entry%marker /= 'None') then
336+
if (trim(entry%marker) /= 'None' .and. trim(entry%marker) /= 'none' .and. &
337+
len_trim(entry%marker) > 0) then
338+
call backend%set_marker_colors(entry%color(1), entry%color(2), entry%color(3), &
339+
entry%color(1), entry%color(2), entry%color(3))
337340
call backend%draw_marker((line_x1 + line_x2) / 2.0_wp, &
338341
line_center_y, entry%marker)
339342
end if
@@ -466,4 +469,4 @@ pure function get_ascii_marker_char(marker_style) result(marker_char)
466469
end select
467470
end function get_ascii_marker_char
468471

469-
end module fortplot_legend
472+
end module fortplot_legend

0 commit comments

Comments
 (0)