matplotlib相關(guān)系統(tǒng)目錄獲取方式小結(jié)
一、獲取matplotlib的安裝位置
導入matplotlib,打印__file__屬性,即可顯示matplotlib包的安裝位置。
In [1]: import matplotlib In [2]: matplotlib.__version__ Out[2]: '3.3.2' In [3]: matplotlib.__file__ Out[3]: 'd:\\ProgramData\\Anaconda3\\lib\\site-packages\\matplotlib\\__init__.py
二、獲取matplotlib的配置目錄
配置目錄獲取比較復雜,遵循以下規(guī)律:
如果設(shè)置了MPLCONFIGDIR 環(huán)境變量,那么配置目錄就是該變量對應目錄。如果沒有選擇,那么配置目錄為$HOME/.matplotlib。
In [4]: matplotlib.get_configdir() Out[4]: 'C:\\Users\\adminstrator\\.matplotlib'
三、獲取matplotlib的緩存目錄
一般情況下,get_cachedir()和get_configdir()返回同一個目錄,特例是在linux中,如果設(shè)置環(huán)境變量$XDG_CACHE_HOME/$HOME/.cache,則使用環(huán)境變量設(shè)置的目錄。
matplotlib的字體緩存存放在該目錄。
In [5]: matplotlib.get_cachedir() Out[5]: 'C:\\Users\\adminstrator\\.matplotlib'
四、獲取matplotlib的配置文件路徑
matplotlib_fname()獲取的即配置文件matplotlibrc文件所在位置。
In [6]: matplotlib.matplotlib_fname() Out[6]: 'd:\\ProgramData\\Anaconda3\\lib\\site-packages\\matplotlib\\mpl-data\\m atplotlibrc'
五、獲取matplotlib的數(shù)據(jù)文件目錄
matplotlib安裝時附帶了一些數(shù)據(jù),比如字體、導航界面圖片、樣本數(shù)據(jù)、繪圖風格等,在Windows平臺中,rc文件默認也保存在該目錄。該目錄結(jié)構(gòu)如下:
├─mpl-data │ ├─fonts │ │ ├─afm │ │ ├─pdfcorefonts │ │ └─ttf │ ├─images │ ├─sample_data │ │ └─axes_grid │ └─stylelib
In [7]: matplotlib.get_data_path() Out[7]: 'd:\\ProgramData\\Anaconda3\\lib\\site-packages\\matplotlib\\mpl-data'
到此這篇關(guān)于matplotlib相關(guān)系統(tǒng)目錄獲取方式小結(jié)的文章就介紹到這了,更多相關(guān)matplotlib相關(guān)系統(tǒng)目錄獲取內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Pyspark獲取并處理RDD數(shù)據(jù)代碼實例
這篇文章主要介紹了Pyspark獲取并處理RDD數(shù)據(jù)代碼實例,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下2020-03-03Python腳本修改Maya ASCII文件路徑方法實現(xiàn)
本文主要介紹了Python腳本修改Maya ASCII文件路徑方法實現(xiàn),文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2023-02-02