pyplot_documentation.py 408 B

123456789101112131415
  1. from nicegui import ui
  2. from ...model import UiElementDocumentation
  3. class PyplotDocumentation(UiElementDocumentation, element=ui.pyplot):
  4. def main_demo(self) -> None:
  5. import numpy as np
  6. from matplotlib import pyplot as plt
  7. with ui.pyplot(figsize=(3, 2)):
  8. x = np.linspace(0.0, 5.0)
  9. y = np.cos(2 * np.pi * x) * np.exp(-x)
  10. plt.plot(x, y, '-')