8000 Hatch pattern changes with dpi · Issue #4108 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
Hatch pattern changes with dpi #4108
Closed
Closed
@jowr

Description

@jowr

Hi, I currently use matplotlib a lot - thanks for your nice work! I noticed that the hatch patterns change with the dpi settings. This is not a big problem as long as you raster the whole plot. However, if you only raster parts of it, you will find that the legend not longer matches the pattern in the bars and that there is a gap at the bottom of the bars.

import matplotlib.pyplot as plt
fig = plt.gcf()
ax = fig.add_subplot(111)
ax.bar(0.7, 5, 0.3, label="raster /", hatch="////", rasterized=True)
ax.bar(1.0, 7, 0.3, label="vector /", hatch="////", rasterized=False)
ax.bar(1.7, 5, 0.3, label="raster .", hatch="....", rasterized=True)
ax.bar(2.0, 7, 0.3, label="vector .", hatch="....", rasterized=False)
ax.bar(2.7, 5, 0.3, label="raster x", hatch="xxxx", rasterized=True)
ax.bar(3.0, 7, 0.3, label="vector x", hatch="xxxx", rasterized=False)
ax.set_ylim([0,10])
plt.tight_layout()
ax.legend(loc=0,ncol=3)
fig.savefig("dpi050.png", dpi=50)
fig.savefig("dpi300.png", dpi=300)
fig.savefig("dpi050.pdf", dpi=50)
fig.savefig("dpi300.pdf", dpi=300)

And this is how dpi050.pdf looks:
dpi050

Metadata

Metadata

Assignees

No one assigned

    Labels

    Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.backend: aggbackend: pdf

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0