一、獲取matplotlib的安裝位置
導(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
二、獲取matplotlib的配置目錄
配置目錄獲取比較復(fù)雜,遵循以下規(guī)律:
如果設(shè)置了MPLCONFIGDIR 環(huán)境變量,那么配置目錄就是該變量對(duì)應(yīng)目錄。如果沒(méi)有選擇,那么配置目錄為$HOME/.matplotlib。
In [4]: matplotlib.get_configdir()
Out[4]: 'C:\\Users\\adminstrator\\.matplotlib'
三、獲取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的配置文件路徑
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í)附帶了一些數(shù)據(jù),比如字體、導(dǎo)航界面圖片、樣本數(shù)據(jù)、繪圖風(fēng)格等,在Windows平臺(tái)中,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'
到此這篇關(guān)于matplotlib相關(guān)系統(tǒng)目錄獲取方式小結(jié)的文章就介紹到這了,更多相關(guān)matplotlib相關(guān)系統(tǒng)目錄獲取內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
您可能感興趣的文章:- python matplotlib坐標(biāo)軸設(shè)置的方法
- Python設(shè)置matplotlib.plot的坐標(biāo)軸刻度間隔以及刻度范圍
- Python使用matplotlib繪制多個(gè)圖形單獨(dú)顯示的方法示例
- python使用matplotlib繪制柱狀圖教程
- python學(xué)習(xí)之matplotlib繪制散點(diǎn)圖實(shí)例
- 用matplotlib畫(huà)等高線圖詳解
- python Matplotlib畫(huà)圖之調(diào)整字體大小的示例
- Python使用matplotlib繪制動(dòng)畫(huà)的方法
- python繪圖庫(kù)Matplotlib的安裝
- Python繪圖Matplotlib之坐標(biāo)軸及刻度總結(jié)