code: def test_charts(pl):
      win_size = pl.window_size
      top_left = pv.Chart2D(size=(0.5, 0.5), loc=(0, 0.5))
      bottom_right = pv.Chart2D(size=(0.5, 0.5), loc=(0.5, 0))
  
      # Test add_chart
      pl.add_chart(top_left)
      assert pl.renderer.__this__ == top_left._renderer.__this__
      assert (
          pl.renderer._charts._scene.__this__
          == top_left._scene.__this__
      )
      pl.add_chart(bottom_right)
      assert len(pl.renderer._charts) == 2
  
      # Test get_charts_by_pos
      pl.show(
          auto_close=False
      )  # We need to plot once to let the charts compute their true geometry
      cs = pl.renderer._get_charts_by_pos(
          (0.75 * win_size[0], 0.25 * win_size[1])
      )
      assert len(cs) == 1
      assert bottom_right in cs
      cs = pl.renderer._get_charts_by_pos((0, 0))
      assert not cs
  
      # Test remove_chart
      pl.remove_chart(1)
      assert len(pl.renderer._charts) == 1
      assert pl.renderer._charts[0] == top_left
      assert top_left in pl.renderer._charts
      pl.remove_chart(top_left)
      assert len(pl.renderer._charts) == 0
  
      # Test deep_clean
      pl.add_chart(top_left, bottom_right)
      pl.deep_clean()
      assert pl.renderer._charts is None
  
      pl.add_chart(top_left, bottom_right)
      pl.clear()  # also calls deep_clean()
      assert len(pl.renderer._charts) == 0
      assert pl.renderer._charts._scene is None
  
imports: import itertools
  import platform
  import weakref
  import numpy
  import pytest
  from vtkmodules.vtkRenderingContext2D import vtkPen
  import pyvista
  from pyvista import examples
  from pyvista.plotting import charts
  from pyvista.plotting.colors import COLOR_SCHEMES
label_desc: Use image node_id 47 for calling a global function with example usage: test_charts(pl) without return types