I run the python code for Matplotlib plotting from thisfilename.py. Is there a variable that stores this filename without file path? As I want to save the plot as thisfilename.png without typing the file name like this every time?
if __name__ == '__main__':
...
plt.savefig('thisfilename.png')
I want to change the last line to something like
# pseudocode
plt.savefig(variable, '.png')
I tested
plt.savefig(__file__, ".png")
The saved filename had .py, the file path, and the space before .png which I don't want