您好,登錄后才能下訂單哦!
這期內(nèi)容當(dāng)中小編將會給大家?guī)碛嘘P(guān)怎么在matplotlib中獲取相關(guān)系統(tǒng)目錄,文章內(nèi)容豐富且以專業(yè)的角度為大家分析和敘述,閱讀完這篇文章希望大家可以有所收獲。
導(dǎo)入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
配置目錄獲取比較復(fù)雜,遵循以下規(guī)律:
如果設(shè)置了MPLCONFIGDIR 環(huán)境變量,那么配置目錄就是該變量對應(yīng)目錄。如果沒有選擇,那么配置目錄為$HOME/.matplotlib。
In [4]: matplotlib.get_configdir() Out[4]: 'C:\\Users\\adminstrator\\.matplotlib'
一般情況下,get_cachedir()和get_configdir()返回同一個(gè)目錄,特例是在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_fname()獲取的即配置文件matplotlibrc文件所在位置。
In [6]: matplotlib.matplotlib_fname() Out[6]: 'd:\\ProgramData\\Anaconda3\\lib\\site-packages\\matplotlib\\mpl-data\\m atplotlibrc'
matplotlib安裝時(shí)附帶了一些數(shù)據(jù),比如字體、導(dǎo)航界面圖片、樣本數(shù)據(jù)、繪圖風(fēng)格等,在Windows平臺中,rc文件默認(rèn)也保存在該目錄。該目錄結(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'
上述就是小編為大家分享的怎么在matplotlib中獲取相關(guān)系統(tǒng)目錄了,如果剛好有類似的疑惑,不妨參照上述分析進(jìn)行理解。如果想知道更多相關(guān)知識,歡迎關(guān)注億速云行業(yè)資訊頻道。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。