Skip to content

fix: accept integer capsize in errorbar (#2020)#2024

Merged
krystophny merged 1 commit into
mainfrom
fix/2020-errorbar-capsize
Jun 15, 2026
Merged

fix: accept integer capsize in errorbar (#2020)#2024
krystophny merged 1 commit into
mainfrom
fix/2020-errorbar-capsize

Conversation

@krystophny

Copy link
Copy Markdown
Collaborator

Closes #2020.

Problem

matplotlib's idiomatic errorbar(..., capsize=4) (integer) failed to
compile in fortplot:

call errorbar(x, y, yerr=yerr, capsize=4)
                                        1
Error: There is no specific subroutine for the generic 'errorbar' at (1)

capsize was declared real(wp) only, so an integer literal matched no
specific procedure of the errorbar / add_errorbar generics. The reporter
read this as "errorbar does not support caps". (Caps render correctly when
capsize is passed as a real, e.g. capsize=4.0_wp.)

Fix

Add integer-capsize overloads for errorbar and add_errorbar (both the
RGB-triple and string color forms) as thin shims that convert to real and
forward to the existing specifics. The integer capsize argument is
required (not optional) in each new variant, which keeps it distinguishable
from its real-capsize counterpart and from the no-capsize call, so generic
resolution stays unambiguous.

Verification

Build (serial to avoid the unrelated fpm parallel-build SIGABRT):

OMP_NUM_THREADS=1 fpm build

Failing before the fix:

$ fpm build   # program calling errorbar(x, y, yerr=yerr, capsize=4)
Error: There is no specific subroutine for the generic 'errorbar'

Passing after the fix:

$ fpm test --target test_errorbar_capsize_integer
 PASS: integer capsize accepted and matches real capsize

The new test (test/plot_types/errorbar/test_errorbar_capsize_integer.f90)
asserts capsize=4 compiles and stores the same cap length (4.0) as
capsize=4.0_wp, read back via figure_t%get_plots().

Existing errorbar tests pass unchanged: test_errorbar_defaults,
test_errorbar_ascii_rendering, test_errorbar_pdf_rendering,
test_errorbar_legend_entry, test_errorbar_barsabove_warning,
test_stateful_api_fast. Rendering gate (make verify-artifacts) passes.
A manual render with capsize=4 shows the horizontal caps drawn at the
error-bar ends.

matplotlib's idiomatic errorbar(..., capsize=4) failed to compile because
capsize was real-only, so the integer literal matched no specific procedure
of the errorbar/add_errorbar generics ("no specific subroutine for the
generic errorbar"). Users read this as "errorbar does not support caps".

Add integer-capsize overloads for errorbar and add_errorbar (RGB and string
color forms) as thin shims that forward to the real-capsize specifics. The
integer capsize argument is required (not optional), so each integer variant
stays distinguishable from its real-capsize counterpart and from the
no-capsize call.
@krystophny krystophny merged commit b7a69b6 into main Jun 15, 2026
6 checks passed
@krystophny krystophny deleted the fix/2020-errorbar-capsize branch June 15, 2026 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Errorbar unterstützt keine Caps?

1 participant