prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  [bug] Pandapower interferes with matplotlib savefig
  ### Bug report checklis
  
  - [X] Searched the [issues page](https://github.com/e2nIEE/pandapower/issues) for similar reports
  
  - [X] Read the relevant sections of the [documentation](https://pandapower.readthedocs.io/en/latest/about.html)
  
  - [X] Browse the [tutorials](https://github.com/e2nIEE/pandapower/tree/develop/tutorials) and [tests](https://github.com/e2nIEE/pandapower/tree/develop/pandapower/test) for usefull code snippets and examples of use
  
  - [X] Reproduced the issue after updating with `pip install --upgrade pandapower` (or `git pull`)
  
  - [X] Tried basic troubleshooting (if a bug/error) like restarting the interpreter and checking the pythonpath
  
  
  ### Reproducible Example
  
  ```python
  import matplotlib.pyplot as plt
  import pandapower
  
  fig, ax = plt.subplots()
  ax.scatter(range(5), range(5))
  fig.savefig('test.svg')
  ```
  
  
  ### Issue Description and Traceback
  
  When pandapower is imported, matplotlib `savefig()` may run into a bug where the `GraphicsContextBase._capstyle` is set to a `str` instead of a `CapStyle` instance. Calling the proper `set_capstyle()` method solves this issue. Also, somehow, this issue does not arise when calling `fig.savefig('test.png')`. It only arises when the figure save type is SVG.
  
  The following code works fine. Notice that I have commented out `import pandapower`:
  ```python
  import matplotlib.pyplot as plt
  # import pandapower
  
  fig, ax = plt.subplots()
  ax.scatter(range(5), range(5))
  fig.savefig('test.svg')
  ```
  
  However, if I uncomment the `import pandapower` line, then I will get an error:
  ```python
  import matplotlib.pyplot as plt
  import pandapower
  
  fig, ax = plt.subplots()
  ax.scatter(range(5), range(5))
  fig.savefig('test.svg')
  ```
  
  Error:
  
  ```
  Traceback (most recent call last):
    File "/home/user/testenv/test.py", line 6, in <module>
      fig.savefig('test.svg')
    File "/home/user/miniconda3/envs/testenv/lib/python3.10/site-packages/matplotlib/figure.py", line 3378, in savefig
      self.canvas.print_figure(fname, **kwargs)
    File "/home/user/miniconda3/envs/testenv/lib/python3.10/site-packages/matplotlib/backend_bases.py", line 2366, in print_figure
      result = print_method(
    File "/home/user/miniconda3/envs/testenv/lib/python3.10/site-packages/matplotlib/backend_bases.py", line 2232, in <lambda>
      print_method = functools.wraps(meth)(lambda *args, **kwargs: meth(
    File "/home/user/miniconda3/envs/testenv/lib/python3.10/site-packages/matplotlib/backends/backend_svg.py", line 1369, in print_svg
      self.figure.draw(renderer)
    File "/home/user/miniconda3/envs/testenv/lib/python3.10/site-packages/matplotlib/artist.py", line 95, in draw_wrapper
      result = draw(artist, renderer, *args, **kwargs)
    File "/home/user/miniconda3/envs/testenv/lib/python3.10/site-packages/matplotlib/artist.py", line 72, in draw_wrapper
      return draw(artist, renderer)
    File "/home/user/miniconda3/envs/testenv/lib/python3.10/site-packages/matplotlib/figure.py", line 3175, in draw
      mimage._draw_list_compositing_images(
    File "/home/user/miniconda3/envs/testenv/lib/python3.10/site-packages/matplotlib/image.py", line 131, in _draw_list_compositing_images
      a.draw(renderer)
    File "/home/user/miniconda3/envs/testenv/lib/python3.10/site-packages/matplotlib/artist.py", line 72, in draw_wrapper
      return draw(artist, renderer)
    File "/home/user/miniconda3/envs/testenv/lib/python3.10/site-packages/matplotlib/axes/_base.py", line 3064, in draw
      mimage._draw_list_compositing_images(
    File "/home/user/miniconda3/envs/testenv/lib/python3.10/site-packages/matplotlib/image.py", line 131, in _draw_list_compositing_images
      a.draw(renderer)
    File "/home/user/miniconda3/envs/testenv/lib/python3.10/site-packages/matplotlib/artist.py", line 72, in draw_wrapper
      return draw(artist, renderer)
    File "/home/user/miniconda3/envs/testenv/lib/python3.10/site-packages/matplotlib/collections.py", line 972, in draw
      super().draw(renderer)
    File "/home/user/miniconda3/envs/testenv/lib/python3.10/site-packages/matplotlib/artist.py", line 72, in draw_wrapper
      return draw(artist, renderer)
    File "/home/user/miniconda3/envs/testenv/lib/python3.10/site-packages/matplotlib/collections.py", line 405, in draw
      renderer.draw_markers(
    File "/home/user/miniconda3/envs/testenv/lib/python3.10/site-packages/matplotlib/backends/backend_svg.py", line 717, in draw_markers
      style = self._get_style_dict(gc, rgbFace)
    File "/home/user/miniconda3/envs/testenv/lib/python3.10/site-packages/matplotlib/backends/backend_svg.py", line 609, in _get_style_dict
      if gc.get_capstyle() != 'butt':
    File "/home/user/miniconda3/envs/testenv/lib/python3.10/site-packages/matplotlib/backend_bases.py", line 820, in get_capstyle
      return self._capstyle.name
  AttributeError: 'str' object has no attribute 'name'
  ```
  
  ### Expected Behavior
  
  I would expect the following 2 code blocks to produce identical (or at least similar) results:
  
  ```python
  import matplotlib.pyplot as plt
  # import pandapower
  
  fig, ax = plt.subplots()
  ax.scatter(range(5), range(5))
  fig.savefig('test.svg')
  ```
  
  and 
  
  ```python
  import matplotlib.pyplot as plt
  import pandapower
  
  fig, ax = plt.subplots()
  ax.scatter(range(5), range(5))
  fig.savefig('test.svg')
  ```
  
  The 1st code block works fine, whereas the 2nd code block throws an `AttributeError`.
  
  ### Installed Versions
  
  OS: Ubuntu 22.04 LTS
  Python 3.10
  Matplotlib 3.7.2
  Pandapower 2.13.1
  
  ### Label
  
  - [X] Relevant labels are selected
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `pandapower/plotting/__init__.py`
  Content:
  ```
  1 from pandapower.plotting.collections import *
  2 from pandapower.plotting.colormaps import *
  3 from pandapower.plotting.generic_geodata import *
  4 from pandapower.plotting.powerflow_results import *
  5 from pandapower.plotting.simple_plot import *
  6 from pandapower.plotting.plotly import *
  7 from pandapower.plotting.geo import *
  8 from pandapower.plotting.plotting_toolbox import set_line_geodata_from_bus_geodata
  9 from pandapower.plotting.to_html import to_html
  10 
  11 import types
  12 
  13 try:
  14     from matplotlib.backend_bases import GraphicsContextBase, RendererBase
  15 
  16     class GC(GraphicsContextBase):
  17         def __init__(self):
  18             super().__init__()
  19             self._capstyle = 'round'
  20 
  21     def custom_new_gc(self):
  22         return GC()
  23 
  24     RendererBase.new_gc = types.MethodType(custom_new_gc, RendererBase)
  25 
  26 except ImportError:
  27     pass
  28
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/pandapower/plotting/__init__.py b/pandapower/plotting/__init__.py
  --- a/pandapower/plotting/__init__.py
  +++ b/pandapower/plotting/__init__.py
  @@ -16,7 +16,7 @@
       class GC(GraphicsContextBase):
           def __init__(self):
               super().__init__()
  -            self._capstyle = 'round'
  +            self.set_capstyle('round')
   
       def custom_new_gc(self):
           return GC()
  
verification_info: {"golden_diff": "diff --git a/pandapower/plotting/__init__.py b/pandapower/plotting/__init__.py\n--- a/pandapower/plotting/__init__.py\n+++ b/pandapower/plotting/__init__.py\n@@ -16,7 +16,7 @@\n     class GC(GraphicsContextBase):\n         def __init__(self):\n             super().__init__()\n-            self._capstyle = 'round'\n+            self.set_capstyle('round')\n \n     def custom_new_gc(self):\n         return GC()\n", "issue": "[bug] Pandapower interferes with matplotlib savefig\n### Bug report checklis\n\n- [X] Searched the [issues page](https://github.com/e2nIEE/pandapower/issues) for similar reports\n\n- [X] Read the relevant sections of the [documentation](https://pandapower.readthedocs.io/en/latest/about.html)\n\n- [X] Browse the [tutorials](https://github.com/e2nIEE/pandapower/tree/develop/tutorials) and [tests](https://github.com/e2nIEE/pandapower/tree/develop/pandapower/test) for usefull code snippets and examples of use\n\n- [X] Reproduced the issue after updating with `pip install --upgrade pandapower` (or `git pull`)\n\n- [X] Tried basic troubleshooting (if a bug/error) like restarting the interpreter and checking the pythonpath\n\n\n### Reproducible Example\n\n```python\nimport matplotlib.pyplot as plt\r\nimport pandapower\r\n\r\nfig, ax = plt.subplots()\r\nax.scatter(range(5), range(5))\r\nfig.savefig('test.svg')\n```\n\n\n### Issue Description and Traceback\n\nWhen pandapower is imported, matplotlib `savefig()` may run into a bug where the `GraphicsContextBase._capstyle` is set to a `str` instead of a `CapStyle` instance. Calling the proper `set_capstyle()` method solves this issue. Also, somehow, this issue does not arise when calling `fig.savefig('test.png')`. It only arises when the figure save type is SVG.\r\n\r\nThe following code works fine. Notice that I have commented out `import pandapower`:\r\n```python\r\nimport matplotlib.pyplot as plt\r\n# import pandapower\r\n\r\nfig, ax = plt.subplots()\r\nax.scatter(range(5), range(5))\r\nfig.savefig('test.svg')\r\n```\r\n\r\nHowever, if I uncomment the `import pandapower` line, then I will get an error:\r\n```python\r\nimport matplotlib.pyplot as plt\r\nimport pandapower\r\n\r\nfig, ax = plt.subplots()\r\nax.scatter(range(5), range(5))\r\nfig.savefig('test.svg')\r\n```\r\n\r\nError:\r\n\r\n```\r\nTraceback (most recent call last):\r\n  File \"/home/user/testenv/test.py\", line 6, in <module>\r\n    fig.savefig('test.svg')\r\n  File \"/home/user/miniconda3/envs/testenv/lib/python3.10/site-packages/matplotlib/figure.py\", line 3378, in savefig\r\n    self.canvas.print_figure(fname, **kwargs)\r\n  File \"/home/user/miniconda3/envs/testenv/lib/python3.10/site-packages/matplotlib/backend_bases.py\", line 2366, in print_figure\r\n    result = print_method(\r\n  File \"/home/user/miniconda3/envs/testenv/lib/python3.10/site-packages/matplotlib/backend_bases.py\", line 2232, in <lambda>\r\n    print_method = functools.wraps(meth)(lambda *args, **kwargs: meth(\r\n  File \"/home/user/miniconda3/envs/testenv/lib/python3.10/site-packages/matplotlib/backends/backend_svg.py\", line 1369, in print_svg\r\n    self.figure.draw(renderer)\r\n  File \"/home/user/miniconda3/envs/testenv/lib/python3.10/site-packages/matplotlib/artist.py\", line 95, in draw_wrapper\r\n    result = draw(artist, renderer, *args, **kwargs)\r\n  File \"/home/user/miniconda3/envs/testenv/lib/python3.10/site-packages/matplotlib/artist.py\", line 72, in draw_wrapper\r\n    return draw(artist, renderer)\r\n  File \"/home/user/miniconda3/envs/testenv/lib/python3.10/site-packages/matplotlib/figure.py\", line 3175, in draw\r\n    mimage._draw_list_compositing_images(\r\n  File \"/home/user/miniconda3/envs/testenv/lib/python3.10/site-packages/matplotlib/image.py\", line 131, in _draw_list_compositing_images\r\n    a.draw(renderer)\r\n  File \"/home/user/miniconda3/envs/testenv/lib/python3.10/site-packages/matplotlib/artist.py\", line 72, in draw_wrapper\r\n    return draw(artist, renderer)\r\n  File \"/home/user/miniconda3/envs/testenv/lib/python3.10/site-packages/matplotlib/axes/_base.py\", line 3064, in draw\r\n    mimage._draw_list_compositing_images(\r\n  File \"/home/user/miniconda3/envs/testenv/lib/python3.10/site-packages/matplotlib/image.py\", line 131, in _draw_list_compositing_images\r\n    a.draw(renderer)\r\n  File \"/home/user/miniconda3/envs/testenv/lib/python3.10/site-packages/matplotlib/artist.py\", line 72, in draw_wrapper\r\n    return draw(artist, renderer)\r\n  File \"/home/user/miniconda3/envs/testenv/lib/python3.10/site-packages/matplotlib/collections.py\", line 972, in draw\r\n    super().draw(renderer)\r\n  File \"/home/user/miniconda3/envs/testenv/lib/python3.10/site-packages/matplotlib/artist.py\", line 72, in draw_wrapper\r\n    return draw(artist, renderer)\r\n  File \"/home/user/miniconda3/envs/testenv/lib/python3.10/site-packages/matplotlib/collections.py\", line 405, in draw\r\n    renderer.draw_markers(\r\n  File \"/home/user/miniconda3/envs/testenv/lib/python3.10/site-packages/matplotlib/backends/backend_svg.py\", line 717, in draw_markers\r\n    style = self._get_style_dict(gc, rgbFace)\r\n  File \"/home/user/miniconda3/envs/testenv/lib/python3.10/site-packages/matplotlib/backends/backend_svg.py\", line 609, in _get_style_dict\r\n    if gc.get_capstyle() != 'butt':\r\n  File \"/home/user/miniconda3/envs/testenv/lib/python3.10/site-packages/matplotlib/backend_bases.py\", line 820, in get_capstyle\r\n    return self._capstyle.name\r\nAttributeError: 'str' object has no attribute 'name'\r\n```\n\n### Expected Behavior\n\nI would expect the following 2 code blocks to produce identical (or at least similar) results:\r\n\r\n```python\r\nimport matplotlib.pyplot as plt\r\n# import pandapower\r\n\r\nfig, ax = plt.subplots()\r\nax.scatter(range(5), range(5))\r\nfig.savefig('test.svg')\r\n```\r\n\r\nand \r\n\r\n```python\r\nimport matplotlib.pyplot as plt\r\nimport pandapower\r\n\r\nfig, ax = plt.subplots()\r\nax.scatter(range(5), range(5))\r\nfig.savefig('test.svg')\r\n```\r\n\r\nThe 1st code block works fine, whereas the 2nd code block throws an `AttributeError`.\n\n### Installed Versions\n\nOS: Ubuntu 22.04 LTS\r\nPython 3.10\r\nMatplotlib 3.7.2\r\nPandapower 2.13.1\n\n### Label\n\n- [X] Relevant labels are selected\n\n", "before_files": [{"content": "from pandapower.plotting.collections import *\nfrom pandapower.plotting.colormaps import *\nfrom pandapower.plotting.generic_geodata import *\nfrom pandapower.plotting.powerflow_results import *\nfrom pandapower.plotting.simple_plot import *\nfrom pandapower.plotting.plotly import *\nfrom pandapower.plotting.geo import *\nfrom pandapower.plotting.plotting_toolbox import set_line_geodata_from_bus_geodata\nfrom pandapower.plotting.to_html import to_html\n\nimport types\n\ntry:\n    from matplotlib.backend_bases import GraphicsContextBase, RendererBase\n\n    class GC(GraphicsContextBase):\n        def __init__(self):\n            super().__init__()\n            self._capstyle = 'round'\n\n    def custom_new_gc(self):\n        return GC()\n\n    RendererBase.new_gc = types.MethodType(custom_new_gc, RendererBase)\n\nexcept ImportError:\n    pass\n", "path": "pandapower/plotting/__init__.py"}], "after_files": [{"content": "from pandapower.plotting.collections import *\nfrom pandapower.plotting.colormaps import *\nfrom pandapower.plotting.generic_geodata import *\nfrom pandapower.plotting.powerflow_results import *\nfrom pandapower.plotting.simple_plot import *\nfrom pandapower.plotting.plotly import *\nfrom pandapower.plotting.geo import *\nfrom pandapower.plotting.plotting_toolbox import set_line_geodata_from_bus_geodata\nfrom pandapower.plotting.to_html import to_html\n\nimport types\n\ntry:\n    from matplotlib.backend_bases import GraphicsContextBase, RendererBase\n\n    class GC(GraphicsContextBase):\n        def __init__(self):\n            super().__init__()\n            self.set_capstyle('round')\n\n    def custom_new_gc(self):\n        return GC()\n\n    RendererBase.new_gc = types.MethodType(custom_new_gc, RendererBase)\n\nexcept ImportError:\n    pass\n", "path": "pandapower/plotting/__init__.py"}]}