sand_subplots.py 878 B

12345678910111213141516171819202122232425262728293031
  1. # Demo of issue that you can't adjust and get back subplot layout ratios
  2. import numpy as np
  3. from imgui_bundle import imgui, immapp, implot
  4. x = np.log(np.arange(100))
  5. y = np.sin(x)
  6. y2 = y+1
  7. scater_values = np.array([x,y2]).transpose()
  8. ratios = implot.SubplotsRowColRatios()
  9. ratios.row_ratios = [.6, .4]
  10. ratios.col_ratios = [.75, .25]
  11. def gui():
  12. "Our gui function, which will be invoked by the application loop"
  13. if implot.begin_subplots("Subplots - try and adjust plot sizes", rows=2, cols=2, size=imgui.ImVec2(-1,-1),
  14. row_col_ratios=ratios):
  15. for i in range(4):
  16. if implot.begin_plot(f"Play with me {i}"):
  17. implot.plot_line("line plot", x, y2)
  18. implot.plot_scatter("scatter plot", x, y)
  19. implot.end_plot()
  20. implot.end_subplots()
  21. immapp.run(gui, with_implot=True)