Unable to change file name while saving matplotlib digits on Mac system

After running the show () command in Python, I can save the numbers only as figure_1.png I cannot change the file name. You cannot enter text next to "Save As:". How to enable input of my file name at this moment?

Sorry I need at least 10 reputations to post a screenshot.

+6
source share
4 answers

I had exactly the same problem with mine, I found the answer in solving the main problem with the matplotlib backend (by default, "macosx" by default "causes this problem"). The solution is to change the baseline in the matplotlibrc file, which you can find by running

import matplotlib matplotlib.matplotlib_fname() 

in python terminal. In the matplotlibrc file, find and change the line

 backend : macosx 

to (for example):

 backend : TkAgg 

All problems should disappear. It worked for me, hope it will be useful.

+5
source

Try it. I do not know if you use pyplot, but it is quite common. Make sure that you do not show () a digit anywhere in the code - this prevents the savefig () function from working. This worked for me and saved myfigure.png in the directory in which I ran the code.

 import matplotlib.pyplot as plt # make a figure with 1 row and 1 column fig, myplot = plt.subplots( nrows=1, ncols =1) # simple plot t = arange(0.0,2.0,0.01) s = sin(2*pi*t) myplot = plot(t,s) # save figure with specified filename plt.savefig('myfigure.png') # close figure plt.close(fig) 
0
source

Just found a solution for this:

Use conda install python.app to install pythonw .

Then use pythonw instead of python in your terminal.

eg.

 pythonw my_plot.py 

Hope this helps

0
source

For some, this discussion may answer the question: https://matplotlib.org/faq/osx_framework.html

Without creating the Python framework, matplotlib does not work properly in OS X. Anaconda does not provide a framework assembly, so the problem is ... although I don't remember that this is a problem until recently!

Despite using Python 3, I actually cannot make the virtual environment fix suggested in the link for me.

-1
source

Source: https://habr.com/ru/post/986259/


All Articles