Skip to content

Add Agnostic Plotting Protocol#843

Open
ChadThackray wants to merge 2 commits intopolakowo:masterfrom
ChadThackray:feature/plotting-protocol
Open

Add Agnostic Plotting Protocol#843
ChadThackray wants to merge 2 commits intopolakowo:masterfrom
ChadThackray:feature/plotting-protocol

Conversation

@ChadThackray
Copy link
Copy Markdown
Contributor

As progress towards #815, this PR introduces a new Protocol, FigureProtocol, which lays out the contract that any plotting backend should fulfill.

In this PR I have focused on creating the protocol itself as well as adding PlotlyFigureProtocolMixin, which implements the FigureProtocol for plotly specifically. This is purely additive, no user facing changes.

We also setup the machinery for plugging in new backends later with a registry.

Next steps would be migrating internal callers to use the protocol as opposed to direct plotly calls where possible, which will help refine the design of the protocol before adding lightweight charts support

As always let me know any suggestions or if a different direction would be preferred.

- Define FigureProtocol with Capability flags for backend-neutral plotting
- Add plot_line, plot_markers, plot_area, plot_ohlc, plot_histogram,
  plot_bars, plot_hline, and plot_zone methods to FigureMixin
- Implement backend registry (register_backend, get_backend, list_backends)
  with Plotly registered as the default built-in backend
- Add create_figure() factory that routes through the registry and respects
  settings['plotting']['default_backend']
- Add resolve_backend/resolve_backend_for_fig helpers for downstream
  migration of existing plot methods
- Add assert_plotly_only_kwargs/assert_plotly_only_method guards for
  graceful non-Plotly backend error reporting
- Expose new API surface on vbt.plotting.* and top-level vbt.*
- Add default_backend='plotly' to plotting settings
- Add comprehensive test suites for protocol conformance and backend registry
- Add hover_text sequence length validation in plot_markers to raise
  ValueError on mismatched lengths
- Add plot_zone tests: minimal, color/opacity, None-param omission,
  subplot domain resolution
- Add subplot column routing tests (1x2 and 2x2 layouts) to catch
  regressions that ignore the col dimension
- Add use_widgets_setting fixture to parametrize subplot tests over
  both Figure and FigureWidget
- Add create_figure tests for rows-only, cols-only, and figure= kwarg
  routing through make_subplots
- Add backend registry tests for kwarg forwarding and unregistered
  default backend error handling
- Add to_html protocol conformance test
- Add None-param omission tests for plot_histogram and plot_area
- Fix test_unknown_backend_raises_keyerror to assert correct key name
- Compare add_hline compat test against go.Figure reference instead of
  hardcoded Plotly internals
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.

1 participant