MatplotlibChart

Displays a [Matplotlib](https://matplotlib.org/) chart.

**Warning:** Requires the matplotlib Python package.

Inherits from GestureDetector.

Properties

  • figure (matplotlib.figure.Figure): The Matplotlib figure to display.
  • Events

  • on_message (EventHandler | None): Triggered on figure message update.
  • on_toolbar_buttons_update (EventHandler | None): Triggers when toolbar buttons status is updated.
  • Methods

  • back(): Navigates to the previous view.
  • download(format: str) -> bytes: Downloads the figure in the specified format (e.g., 'png', 'svg').
  • forward(): Navigates to the next view.
  • home(): Resets the view to the original state.
  • pan(): Activates the pan tool.
  • send_binary(blob): Sends binary data to the frontend.
  • send_json(content): Sends JSON data to the frontend.
  • send_message(message): Sends a message to the figure's canvas manager.
  • zoom(): Activates the zoom tool.
  • Examples

  • **Bar chart:** Basic bar chart creation.
  • **Chart with Toolbar:** Chart with interactive toolbar functionality.
  • **3D chart:** Displays a 3D plot.
  • **Handle events:** Demonstrates handling click and key press events on the chart.
  • **Animated chart:** Shows an animated 3D random walk.
  • **Note:** The MatplotlibChartWithToolbar is a variant used in examples, but the core control is MatplotlibChart.