I am running a set of python scripts on my visual studio code on windows 10. It seems that there is a bug in matplotlib
package of the anaconda3. Specifically, I notice that saving a figure as a .png
utilizing matplotlib.pyplot.savefig
function produces a segmentation fault error message as the following. I search alot in the past few days and still could not figure out what is the issue. Specifically, the following explanation (#12286) helped me to understand the issue but did not give me any workaround. I would need your help on this matter.
Update1: Here is the content of Plotter module:
import faulthandler
faulthandler.enable()
from Utilities import *
class Plotter:
def __init__(self, lst1: list, lst2: list, lst3: list):
self.lst1 = lst1
self.lst2 = lst2
self.lst3 = lst3
def plotterFunc(self) -> mpl.pyplot.axes:
fig, ax = mpl.pyplot.subplots(figsize=(12, 12))
setScaleLabelTickLimit(ax, t3)
ax.set_ylabel('Intensity [$\\frac{{W}}{{cm^{{2}}}}$]')
plotter2(ax, x3, self.lst3)
mpl.pyplot.savefig(PLOT_DIR/'Intensity/Intensity.png',
orientation='landscape', bbox_inches='tight')
mpl.pyplot.clf()
def plotterFunc2():
pass
def plotterFunc3():
pass
--Thank you,
Windows fatal exception: access violation
Current thread 0x0001fb6c (most recent call first):
File "C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\backends\backend_agg.py", line 240 in get_text_width_height_descent
File "C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\text.py", line 306 in _get_layout
File "C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\text.py", line 903 in get_window_extent
File "C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\axis.py", line 1068 in
File "C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\axis.py", line 1068 in _get_tick_bboxes
File "C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\axis.py", line 1142 in draw
File "C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\artist.py", line 51 in draw_wrapper
File "C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\image.py", line 132 in _draw_list_compositing_images
File "C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\axes_base.py", line 2921 in draw
File "C:\ProgramData\Anaconda3\lib\site-packages\matplotlib_api\deprecation.py", line 431 in wrapper
File "C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\artist.py", line 51 in draw_wrapper File "C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\image.py", line 132 in _draw_list_compositing_images
File "C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\figure.py", line 2790 in draw
File "C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\artist.py", line 51 in draw_wrapper
File "C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\artist.py", line 74 in draw_wrapper
File "C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\backend_bases.py", line 2230 in print_figure
File "C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\backends\backend_qt5agg.py", line 78 in print_figure
File "C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\figure.py", line 3015 in savefig
File "C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\pyplot.py", line 966 in savefig
File "c:\Users\username...\Plotter.py", line 41 in plotterFunc
File "c:/Users/username/.../my_script.py", line 199 in main
File "c:/Users/username/.../my_script.py", line 211 in
Segmentation fault