2016-07-03 41 views

回答

10

疊加柱狀圖中兩次:

import matplotlib.pyplot as plt 
from matplotlib.patches import Ellipse, Polygon 

fig = plt.figure() 
ax1 = fig.add_subplot(111) 
# draw hatch 
ax1.bar(range(1, 5), range(1, 5), color='none', edgecolor='red', hatch="/", lw=1., zorder = 0) 
# draw edge 
ax1.bar(range(1, 5), range(1, 5), color='none', edgecolor='k', zorder=1, lw=2.) 

ax1.set_xticks([1.5, 2.5, 3.5, 4.5]) 
plt.show() 

enter image description here

+0

非常感謝!這正是我需要的。 –

+0

你對這個傳說有什麼建議嗎?我仍然在那裏得到紅色邊緣和紅色邊緣 –

+0

添加到傳說中的黑色邊緣補丁。 – Serenity

3

在Matplotlib 2.0,現在您可以用configure the hatch colour directly rcParams。

在填充圖案線條的顏色和寬度是現在由rcParams hatch.colorhatch.linewidth配置的,用黑色和1點的默認值,分別...有艙口顏色的無API級控制或行寬。

無論DPI如何,陰影模式現在都呈現一致的密度。以前,高DPI數字比默認數字更密集,低DPI數字密度會更低。這種舊行爲不能直接恢復,但可以通過重複填充說明符來增加密度。

+2

配置孵化顏色,這意味着我只能在每個小區中以一種顏色孵化...這很煩人...... – mathause

+1

似乎在2.0.1版本中計劃https:/ /github.com/matplotlib/matplotlib/issues/7901 – mathause