Skip to content

Add error bar plotting support #52

@krystophny

Description

@krystophny

Feature Request: Error Bar Plotting Support

Description

Add support for error bars to represent uncertainty and variability in data. Error bars are critical for scientific plotting and data analysis, allowing visualization of confidence intervals, standard deviations, and measurement uncertainties.

Proposed API

\! Symmetric error bars
call fig%errorbar(x, y, yerr=error_values, label='Experimental data')
call fig%errorbar(x, y, xerr=x_errors, yerr=y_errors)

\! Asymmetric error bars
call fig%errorbar(x, y, yerr_lower=lower_err, yerr_upper=upper_err)

\! Error bars with line/marker customization
call fig%errorbar(x, y, yerr=errors, linestyle='-', marker='o', &
                  capsize=5, elinewidth=1.5)

Requirements

  • Symmetric error bars (±same value)
  • Asymmetric error bars (different +/- values)
  • X-axis, Y-axis, or both error bars
  • Customizable cap size and line width
  • Integration with existing line/marker plotting
  • Support for all backends (PNG, PDF, ASCII)

Implementation Notes

  • Error bars should be drawn with appropriate caps
  • Should handle NaN values in error data gracefully
  • Consider both absolute and relative error specifications
  • ASCII backend may need creative character representation
  • Performance considerations for large datasets with errors

Test Requirements

  • Comprehensive test coverage required
    • Test symmetric and asymmetric error bars
    • Test x-only, y-only, and combined error bars
    • Test error bar customization (cap size, line width, style)
    • Test integration with line plots and scatter plots
    • Test NaN handling in error data
    • Test all backends (PNG, PDF, ASCII)
    • Test edge cases (zero errors, very large errors, negative values)
    • Test performance with large datasets

Example Requirements

  • Simple, clear example required
    • Demonstrate basic symmetric error bars
    • Show asymmetric error bar usage
    • Include both x and y error bars
    • Show customization options (cap size, colors)
    • Compare with and without error bars
    • Generate output in all supported formats
    • Add to example/ directory as errorbar_demo.f90

Related

This addresses a critical need for scientific and engineering applications. Error bars are essential for:

  • Experimental data visualization
  • Statistical analysis and confidence intervals
  • Measurement uncertainty representation
  • Scientific publication quality plots
  • Quality control and process monitoring

Acceptance Criteria

  • Implementation follows SOLID principles
  • Comprehensive test suite with >90% coverage
  • Working example demonstrating key features
  • Documentation updated
  • All backends supported
  • Proper error bar rendering with caps
  • Performance acceptable for datasets with 10^4+ points
  • Integration with existing plotting functions

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions