简体   繁体   English

如何更改matplotlibrc默认目录

[英]how to change matplotlibrc default directory

I'm currently using anaconda and python 3.6 on windows bash. 我目前在Windows bash上使用anaconda和python 3.6。 Every time i want to use matplotlib I have to paste a copy of the matplotlibrc file into my working directory otherwise my code won't run or plot and I get the warning - /home/computer/anaconda3/lib/python3.6/site-packages/matplotlib/ init .py:1022: UserWarning: could not find rc file;returning defaults 每次我想使用matplotlib时,都必须将matplotlibrc文件的副本粘贴到我的工作目录中,否则我的代码将无法运行或绘图,并且会收到警告-/home/computer/anaconda3/lib/python3.6/site -packages / matplotlib / init .py:1022:UserWarning:找不到rc文件;返回默认值

my matplotlibrc file is located at C:\\Users\\user\\AppData\\Local\\lxss\\home\\puter\\anaconda3\\lib\\python3.6\\site-packages\\matplotlib\\mpl-data 我的matplotlibrc文件位于C:\\ Users \\ user \\ AppData \\ Local \\ lxss \\ home \\ puter \\ anaconda3 \\ lib \\ python3.6 \\ site-packages \\ matplotlib \\ mpl-data

I thought to fix this I could edit my .condarc file and set it to look for matplotlibrc in the correct directory. 我想解决此问题,我可以编辑.condarc文件并将其设置为在正确的目录中查找matplotlibrc。 Could anyone tell me how to do this? 谁能告诉我该怎么做?

It looks like when anaconda or matplotlib was installed it's created the matplotlibrc file in C:\\Users\\user\\AppData\\Local\\lxss\\home\\puter\\anaconda3\\lib\\py‌​thon3.6\\site-package‌​s\\matplotlib\\mpl-dat‌​a using the windows environment. 看起来像安装了anaconda或matplotlib时,是在C:\\ Users \\ user \\ AppData \\ Local \\ lxss \\ home \\ puter \\ anaconda3 \\ lib \\ py‌thon3.6 \\ site-package‌s \\ matplotlib \\中创建了matplotlibrc文件使用Windows环境的mpl-dat‌a。 This has caused the file not to be recognised in WSL. 这导致该文件在WSL中无法识别。

To fix this create another matplotlibrc file in bash or whatever shell you're using. 要解决此问题,请在bash或您使用的任何shell中创建另一个matplotlibrc文件。 In the directory listed above copy the contents of the previously created matplotlibrc file into your new matplotlibrc file. 在上面列出的目录中,将以前创建的matplotlibrc文件的内容复制到新的matplotlibrc文件中。 Make sure you don't create this file in the windows environment otherwise it won't be recognised. 确保不要在Windows环境中创建此文件,否则将无法识别该文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM