Legend module following SOLID principles
Single Responsibility: Legend rendering and positioning Open/Closed: Extensible legend types via interfaces Liskov Substitution: Legend renderers work across backends Interface Segregation: Focused legend interface Dependency Inversion: Depends on abstractions, not concrete backends
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer, | public, | parameter | :: | LEGEND_UPPER_LEFT | = | 1 | |
| integer, | public, | parameter | :: | LEGEND_UPPER_RIGHT | = | 2 | |
| integer, | public, | parameter | :: | LEGEND_LOWER_LEFT | = | 3 | |
| integer, | public, | parameter | :: | LEGEND_LOWER_RIGHT | = | 4 | 
Single Responsibility: Represents one legend entry
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| character(len=:), | public, | allocatable | :: | label | |||
| real(kind=wp), | public, | dimension(3) | :: | color | |||
| character(len=:), | public, | allocatable | :: | linestyle | |||
| character(len=:), | public, | allocatable | :: | marker | 
Single Responsibility: Legend layout and rendering coordination
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| type(legend_entry_t), | public, | allocatable | :: | entries(:) | |||
| integer, | public | :: | position | = | LEGEND_UPPER_RIGHT | ||
| integer, | public | :: | num_entries | = | 0 | ||
| real(kind=wp), | public | :: | x_offset | = | 10.0_wp | ||
| real(kind=wp), | public | :: | y_offset | = | 10.0_wp | ||
| real(kind=wp), | public | :: | entry_height | = | 20.0_wp | ||
| real(kind=wp), | public | :: | line_length | = | 30.0_wp | ||
| real(kind=wp), | public | :: | text_padding | = | 10.0_wp | 
| procedure, public :: add_entry => legend_add_entry | |
| procedure, public :: render => legend_render | |
| procedure, public :: set_position => legend_set_position | |
| procedure, public :: clear => legend_clear | 
Render legend following Liskov Substitution Works with any backend that implements plot_context interface
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(legend_t), | intent(in) | :: | this | |||
| class(plot_context), | intent(inout) | :: | backend | 
Render compact ASCII legend with proper formatting
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(legend_t), | intent(in) | :: | legend | |||
| class(plot_context), | intent(inout) | :: | backend | |||
| real(kind=wp), | intent(in) | :: | legend_x | |||
| real(kind=wp), | intent(in) | :: | legend_y | 
Render standard legend for PNG/PDF backends with improved sizing Refactored to be under 100 lines (QADS compliance)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(legend_t), | intent(in) | :: | legend | |||
| class(plot_context), | intent(inout) | :: | backend | |||
| real(kind=wp), | intent(in) | :: | legend_x | |||
| real(kind=wp), | intent(in) | :: | legend_y |