Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[ENH]: Different edgecolor and hatch color in bar plot #26074

Closed
@99991

Description

@99991

Problem

Colored edges look ugly:

colored hatch

I want bars with black edges and colored hatch:

colored hatch, black edge

My current workaround is to draw the bars twice, once with colored hatch and then a second time only with black edges:

importmatplotlib.pyplotaspltimportnumpyasnpwidth=0.35x=np.arange(4)+1y_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 ahatchcolor parameter which is independent ofedgecolor.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp