Closed
Description
Problem
Colored edges look ugly:
I want bars with black edges and colored hatch:
My current workaround is to draw the bars twice, once with colored hatch and then a second time only with black edges:
import matplotlib.pyplot as plt
import numpy as np
width = 0.35
x = np.arange(4) + 1
y_red = [1, 3, 1, 4]
y_blue = [2, 2, 4, 1]
plt.bar(x - 0.5 * width, y_red, width, label="Height of red bars", hatch="////", facecolor=(0, 0, 0, 0), edgecolor="red")
plt.bar(x - 0.5 * width, y_red, width, facecolor=(0, 0, 0, 0), edgecolor="black")
plt.bar(x + 0.5 * width, y_blue, width, label="Height of blue bars", hatch=r"\\", facecolor=(0, 0, 0, 0), edgecolor="blue")
plt.bar(x + 0.5 * width, y_blue, width, facecolor=(0, 0, 0, 0), edgecolor="black")
plt.xticks(x)
plt.yticks([0, 1, 2, 3, 4])
plt.legend()
plt.savefig("hatch.png")
plt.show()
This workaround is not optimal because the legend is wrong.
Proposed solution
I propose a hatchcolor
parameter which is independent of edgecolor
.