fix

涓婄骇 c0b7cf20
......@@ -6,13 +6,13 @@
> 鍗忚锛歔CC BY-NC-SA 4.0](http://creativecommons.org/licenses/by-nc-sa/4.0/)
鏈夎澶氬畨瑁 matplotlib 鐨勪笉鍚屾柟娉曪紝鏈濂界殑鏂规硶鍙栧喅浜浣跨敤鐨勬搷浣滅郴缁燂紝宸茬粡瀹夎鐨勫唴瀹逛互鍙婂浣曚娇鐢ㄥ畠銆 涓轰簡閬垮厤娑夊強鏈〉涓婄殑鎵鏈夌粏鑺傦紙鍜屾綔鍦ㄧ殑澶嶆潅鎬э級锛屾湁鍑犱釜鏂逛究鐨勯夐」銆
鏈夎澶氬畨瑁 matplotlib 鐨勪笉鍚屾柟娉曪紝鏈濂界殑鏂规硶鍙栧喅浜浣跨敤鐨勬搷浣滅郴缁燂紝宸茬粡瀹夎鐨勫唴瀹逛互鍙婂浣曚娇鐢ㄥ畠銆 涓轰簡閬垮厤娑夊強鏈〉涓婄殑鎵鏈夌粏鑺傦紙鍜屾綔鍦ㄧ殑澶嶆潅鎬э級锛屾湁鍑犱釜鏂逛究鐨勯夐」銆
## 瀹夎棰勬瀯寤哄寘
### 澶氭暟骞冲彴锛歅ython 绉戝鍒嗗彂鍖
绗竴涓夐」鏄娇鐢ㄥ凡缁忓唴缃 matplotlib 鐨勯鎵撳寘鐨 Python 鍒嗗彂鍖呫 `Continuum.io` Python 鍒嗗彂鍖咃紙Anaconda 鎴 miniconda锛夊拰 Enthought 鍒嗗彂鍖咃紙Canopy锛夐兘鏄鈥滃湪 Windows锛孫SX 鍜屼富娴 Linux 骞冲彴寮绠卞嵆鐢ㄥ苟姝e父宸ヤ綔鈥鐨勫嚭鑹查夋嫨銆 杩欎袱涓垎鍙戝寘鍖呮嫭 matplotlib 鍜岃澶氬叾浠栨湁鐢ㄧ殑宸ュ叿銆
绗竴涓夐」鏄娇鐢ㄥ凡缁忓唴缃 matplotlib 鐨勯鎵撳寘鐨 Python 鍒嗗彂鍖呫 `Continuum.io` Python 鍒嗗彂鍖咃紙Anaconda 鎴 miniconda锛夊拰 Enthought 鍒嗗彂鍖咃紙Canopy锛夐兘鏄銆庡湪 Windows锛孫SX 鍜屼富娴 Linux 骞冲彴寮绠卞嵆鐢ㄥ苟姝e父宸ヤ綔銆鐨勫嚭鑹查夋嫨銆 杩欎袱涓垎鍙戝寘鍖呮嫭 matplotlib 鍜岃澶氬叾浠栨湁鐢ㄧ殑宸ュ叿銆
### Linux锛氫娇鐢ㄤ綘鐨勫寘绠$悊鍣
......@@ -40,7 +40,7 @@ python -m pip install matplotlib
Matplotlib 渚濊禆浜 Pillow 鏉ヨ鍙栧拰淇濆瓨 JPEG锛孊MP 鍜 TIFF 鍥惧儚鏂囦欢銆 Matplotlib 闇瑕 MiKTeX 鍜 GhostScript 鏉ヤ娇鐢↙aTeX娓叉煋鏂囨湰銆傚姩鐢绘ā鍧楅渶瑕 FFmpeg锛宎vconv锛宮encoder 鎴 ImageMagick銆
浠ヤ笅鍚庣搴旇寮绠卞嵆鐢細agg锛宼kagg锛宲s锛宲df 鍜 svg銆傚浜庡叾浠栧悗绔紝鍙兘闇瑕佸畨瑁 pycairo锛孭yQt4锛孭yQt5锛孭ySide锛寃xPython锛孭yGTK锛孴ornado 鎴 GhostScript銆
浠ヤ笅鍚庣搴旇寮绠卞嵆鐢細agg锛宼kagg锛宲s锛宲df 鍜 svg銆傚浜庡叾浠栧悗绔紝鍙兘闇瑕佸畨瑁 pycairo锛孭yQt4锛孭yQt5锛孭ySide锛寃xPython锛孭yGTK锛孴ornado 鎴 GhostScript銆
TkAgg 鍙兘鏄潵鑷爣鍑 Python shell 鎴 IPython 鐨勶紝鐢ㄤ簬浜や簰寮忕殑鏈浣冲悗绔傚畠琚惎鐢ㄤ负瀹樻柟浜岃繘鍒舵枃浠剁殑榛樿鍚庣銆 Windows 涓嶆敮鎸 GTK3銆
......@@ -64,13 +64,13 @@ python setup.py build
python setup.py install
```
鎴戜滑鎻愪緵涓`setup.py`涓璧蜂娇鐢ㄧ殑`setup.cfg`鏂囦欢锛鍙互浣跨敤瀹冩潵鑷畾涔夋瀯寤鸿繃绋嬨 渚嬪锛岃浣跨敤鐨勯粯璁ゅ悗绔紝鏄惁瀹夎 matplotlib 闄勫甫鐨勬煇浜涘彲閫夊簱锛岀瓑绛夈 杩欎釜鏂囦欢浼氬閭d簺鍖呰 matplotlib 鐨勪笢瑗跨壒鍒湁鐢ㄣ
鎴戜滑鎻愪緵涓`setup.py`涓璧蜂娇鐢ㄧ殑`setup.cfg`鏂囦欢锛鍙互浣跨敤瀹冩潵鑷畾涔夋瀯寤鸿繃绋嬨 渚嬪锛岃浣跨敤鐨勯粯璁ゅ悗绔紝鏄惁瀹夎 matplotlib 闄勫甫鐨勬煇浜涘彲閫夊簱锛岀瓑绛夈 杩欎釜鏂囦欢浼氬閭d簺鍖呰 matplotlib 鐨勪笢瑗跨壒鍒湁鐢ㄣ
濡傛灉宸茬粡涓洪潪鏍囧噯璁炬柦瀹夎浜嗗繀澶囩粍浠讹紝骞堕渶瑕侀氱煡 matplotlib 瀹冧滑鍦ㄥ摢閲岋紝璇风紪杈`setupext.py`骞跺皢鍩烘湰璺緞娣诲姞涓`sys.platform``basedir`瀛楀吀鏉$洰銆 渚嬪锛屽鏋滄煇浜涙墍闇搴撶殑澶存枃浠朵綅浜`/some/path/include/someheader.h`涓紝璇峰湪鐨勫钩鍙扮殑`basedir`鍒楄〃涓緭鍏`/some/path`
濡傛灉宸茬粡涓洪潪鏍囧噯璁炬柦瀹夎浜嗗繀澶囩粍浠讹紝骞堕渶瑕侀氱煡 matplotlib 瀹冧滑鍦ㄥ摢閲岋紝璇风紪杈`setupext.py`骞跺皢鍩烘湰璺緞娣诲姞涓`sys.platform``basedir`瀛楀吀鏉$洰銆 渚嬪锛屽鏋滄煇浜涙墍闇搴撶殑澶存枃浠朵綅浜`/some/path/include/someheader.h`涓紝璇峰湪鐨勫钩鍙扮殑`basedir`鍒楄〃涓緭鍏`/some/path`
### 鏋勫缓闇姹
杩欎簺鏄閮ㄨ蒋浠跺寘锛鎮ㄩ渶瑕佸湪瀹夎 matplotlib 涔嬪墠瀹夎瀹冧滑銆 濡傛灉鎮ㄥ湪 OSX 涓婃瀯寤猴紝璇峰弬闃[鍦 OSX 涓婃瀯寤](http://matplotlib.org/users/installing.html#build-osx)銆 濡傛灉鎮鍦 Windows 涓婃瀯寤猴紝璇峰弬闃[鍦 Windows 涓婃瀯寤](http://matplotlib.org/users/installing.html#build-windows)銆 濡傛灉鍦 Linux 涓婁娇鐢ㄨ蒋浠跺寘绠$悊鍣ㄥ畨瑁呬緷璧栭」锛屽垯闄や簡搴撴湰韬箣澶栵紝杩樺彲鑳介渶瑕佸畨瑁呭紑鍙戝寘锛堟煡鎵`-dev`鍚庣紑锛夈
杩欎簺鏄閮ㄨ蒋浠跺寘锛浣犻渶瑕佸湪瀹夎 matplotlib 涔嬪墠瀹夎瀹冧滑銆 濡傛灉浣犲湪 OSX 涓婃瀯寤猴紝璇峰弬闃[鍦 OSX 涓婃瀯寤](http://matplotlib.org/users/installing.html#build-osx)銆 濡傛灉浣鍦 Windows 涓婃瀯寤猴紝璇峰弬闃[鍦 Windows 涓婃瀯寤](http://matplotlib.org/users/installing.html#build-windows)銆 濡傛灉鍦 Linux 涓婁娇鐢ㄨ蒋浠跺寘绠$悊鍣ㄥ畨瑁呬緷璧栭」锛屽垯闄や簡搴撴湰韬箣澶栵紝杩樺彲鑳介渶瑕佸畨瑁呭紑鍙戝寘锛堟煡鎵`-dev`鍚庣紑锛夈
#### 鎵闇渚濊禆
......@@ -127,7 +127,7 @@ setuptools 涓 Python 鍖呭畨瑁呮彁渚涙墿灞
#### 鍙夌殑 GUI 妗嗘灦
杩欎簺鏄彲閫夎蒋浠跺寘锛鍙兘甯屾湜瀹夎杩欎簺杞欢鍖呮潵浣 鐢╩atplotlib 鍜岀敤鎴风晫闈㈠伐鍏峰寘銆 鏈夊叧 matplotlib 鍙夊悗绔拰鎵鎻愪緵鍔熻兘鐨勬洿澶氳缁嗕俊鎭紝璇峰弬闃[浠涔堟槸鍚庣](http://matplotlib.org/faq/usage_faq.html#what-is-a-backend)
杩欎簺鏄彲閫夎蒋浠跺寘锛鍙兘甯屾湜瀹夎杩欎簺杞欢鍖呮潵浣 鐢╩atplotlib 鍜岀敤鎴风晫闈㈠伐鍏峰寘銆 鏈夊叧 matplotlib 鍙夊悗绔拰鎵鎻愪緵鍔熻兘鐨勬洿澶氳缁嗕俊鎭紝璇峰弬闃[浠涔堟槸鍚庣](http://matplotlib.org/faq/usage_faq.html#what-is-a-backend)
[tk](http://matplotlib.org/glossary/index.html#term-tk) 8.3 鎴栨洿鏂帮紝涓嶅寘鎷 8.6.0 鍜 8.6.1
......@@ -201,7 +201,7 @@ su -c "yum-builddep python-matplotlib"
### 鍦 OSX 涓婃瀯寤
鐢变簬鍙互鑾峰彇`libpng``freetype`闇姹傦紙darwinports锛宖ink锛/usr/X11R6锛夌殑涓嶅悓浣嶇疆锛屼笉鍚岀殑鏋舵瀯锛堜緥濡 x86锛宲pc锛寀niversal锛夊拰涓嶅悓鐨 OSX 鐗堟湰 10.4 鍜 10.5锛夛紝OSX 鐨勬瀯寤烘儏鍐靛緢澶嶆潅銆傛垜浠缓璁浣跨敤鎴戜滑瀵 OSX 鐗堟湰鎵鍋氱殑鏂瑰紡鏉ユ瀯寤猴細浠`tarball``git`浠撳簱鑾峰彇婧愪唬鐮侊紝骞舵寜鐓`README.osx`涓殑璇存槑杩涜鎿嶄綔銆
鐢变簬鍙互鑾峰彇`libpng``freetype`闇姹傦紙darwinports锛宖ink锛/usr/X11R6锛夌殑涓嶅悓浣嶇疆锛屼笉鍚岀殑鏋舵瀯锛堜緥濡 x86锛宲pc锛寀niversal锛夊拰涓嶅悓鐨 OSX 鐗堟湰 10.4 鍜 10.5锛夛紝OSX 鐨勬瀯寤烘儏鍐靛緢澶嶆潅銆傛垜浠缓璁浣跨敤鎴戜滑瀵 OSX 鐗堟湰鎵鍋氱殑鏂瑰紡鏉ユ瀯寤猴細浠`tarball``git`浠撳簱鑾峰彇婧愪唬鐮侊紝骞舵寜鐓`README.osx`涓殑璇存槑杩涜鎿嶄綔銆
### 鍦 Windows 涓婃瀯寤
......
......@@ -50,3 +50,59 @@ fig, axs = plt.subplots(2, 2, sharex=True, sharey=True)
axs[0,0].plot(x)
```
## 淇甯歌鐨勬棩鏈熼棶棰
matplotlib 鍏佽浣犳湰鍦扮粯鍒 python datetime 瀹炰緥锛屽苟涓斿湪澶у鏁版儏鍐典笅锛屽彲浠ュ緢濂藉湴鎸戦夊埢搴︿綅缃拰瀛楃涓叉牸寮忋 浣嗘湁鍑犱欢浜嬫儏瀹冧笉鑳藉Ε鍠勫鐞嗭紝杩欓噷鏈変竴浜涙妧宸э紝鐢ㄤ簬甯姪浣犺В鍐充粬浠 鎴戜滑灏嗗湪`numpy`璁板綍鏁扮粍涓姞杞戒竴浜涘寘鍚`datetime.date`瀵硅薄鐨勭ず渚嬫棩鏈熸暟鎹細
```py
In [63]: datafile = cbook.get_sample_data('goog.npy')
In [64]: r = np.load(datafile).view(np.recarray)
In [65]: r.dtype
Out[65]: dtype([('date', '|O4'), ('', '|V4'), ('open', '<f8'),
('high', '<f8'), ('low', '<f8'), ('close', '<f8'),
('volume', '<i8'), ('adj_close', '<f8')])
In [66]: r.date
Out[66]:
array([2004-08-19, 2004-08-20, 2004-08-23, ..., 2008-10-10, 2008-10-13,
2008-10-14], dtype=object)
```
瀛楁鏃ユ湡鐨`numpy`璁板綍鏁扮粍鐨`dtype``| O4`锛岃繖鎰忓懗鐫瀹冩槸涓涓 4 瀛楄妭鐨 python 瀵硅薄鎸囬拡; 鍦ㄨ繖绉嶆儏鍐典笅锛屽璞℃槸`datetime.date`瀹炰緥锛屽綋鎴戜滑鍦 ipython 缁堢绐楀彛涓墦鍗颁竴浜涙牱鏈椂锛屾垜浠彲浠ョ湅鍒般
濡傛灉浣犵粯鍒舵暟鎹紝
```py
In [67]: plot(r.date, r.close)
Out[67]: [<matplotlib.lines.Line2D object at 0x92a6b6c>]
```
浣犱細鐪嬪埌 x 杞存爣绛鹃噸鍚堝埌涓璧枫
![](http://matplotlib.org/_images/recipes-2.png)
鍙︿竴涓夯鐑︽槸锛屽鏋滀綘灏嗛紶鏍囨偓鍋滃湪绐楀彛涓婏紝骞跺湪 x 鍜 y 鍧愭爣澶勬煡鐪 matplotlib 宸ュ叿鏍忥紙[浜や簰寮忓鑸](http://matplotlib.org/users/navigation_toolbar.html#navigation-toolbar)锛夌殑鍙充笅瑙掞紝鎮ㄤ細鐪嬪埌 x 浣嶇疆鐨勬牸寮忎笌鍒诲害鏍囩鐨勬牸寮忕浉鍚岋紝 渚嬪锛屸淒ec 2004鈥濄 鎴戜滑鎯宠鐨勬槸宸ュ叿鏍忎腑鐨勪綅缃叿鏈夋洿楂樼殑绮剧‘搴︼紝渚嬪锛岄紶鏍囨偓鍋滃湪涓婇潰鏃剁粰鎴戜滑纭垏鐨勬棩鏈熴 涓轰簡瑙e喅绗竴涓棶棰橈紝鎴戜滑鍙互浣跨敤[`matplotlib.figure.Figure.autofmt_xdate()`](http://matplotlib.org/api/figure_api.html#matplotlib.figure.Figure.autofmt_xdate)銆備慨澶嶇浜屼釜闂锛屾垜浠彲浠ヤ娇鐢`ax.fmt_xdata`灞炴э紝璇ュ睘鎬у彲浠ヨ缃负浠讳綍鎺ュ彈鏍囬噺骞惰繑鍥炲瓧绗︿覆鐨勫嚱鏁般 matplotlib 鏈変竴浜涘唴缃殑鏃ユ湡鏍煎紡鍖栧櫒锛屾墍浠ユ垜浠皢浣跨敤鍏朵腑鐨勪竴涓
```py
plt.close('all')
fig, ax = plt.subplots(1)
ax.plot(r.date, r.close)
# rotate and align the tick labels so they look better
fig.autofmt_xdate()
# use a more precise date string for the x axis locations in the
# toolbar
import matplotlib.dates as mdates
ax.fmt_xdata = mdates.DateFormatter('%Y-%m-%d')
plt.title('fig.autofmt_xdate fixes the labels')
```
![](http://matplotlib.org/_images/recipes-3.png)
鐜板湪锛屽綋鎮ㄥ皢榧犳爣鎮仠鍦ㄧ粯鍒剁殑鏁版嵁涓婏紝鎮ㄥ皢鍦ㄥ伐鍏锋爮涓湅鍒板`2004-12-01`鐨勬棩鏈熸牸寮忓瓧绗︿覆銆
## 閫忔槑搴﹀~鍏
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
鍏堝畬鎴愭娑堟伅鐨勭紪杈戯紒
鎯宠璇勮璇 娉ㄥ唽