hatch can not be saved as eps

Linux 2.6.32-25-generic #45-Ubuntu SMP Sat Oct 16 19:48:22 UTC 2010 i686 GNU/Linux
matplotlib 0.99.1.1
The script below is copied from
http://matplotlib.sourceforge.net/examples/pylab_examples/hatch_demo.html
It works. But it can not be saved as an eps file.
I have a lot of histogram plots using “hatch” needed to be saved as eps, is it possible to fix this bug?
Thanks.

"""

Hatching (pattern filled polygons) is supported currently in the PS,
PDF, SVG and Agg backends only.
"""
import matplotlib.pyplot as plt

from matplotlib.patches import Ellipse, Polygon

fig = plt.figure()

ax1 = fig.add_subplot(131)
ax1.bar(range(1,5), range(1,5), color='red', edgecolor='black', hatch="/")

ax1.bar(range(1,5), [6] * 4, bottom=range(1,5), color='blue', edgecolor='black', hatch='//')

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

ax2 = fig.add_subplot(132)
bars = ax2.bar(range(1,5), range(1,5), color='yellow', ecolor='black') + \

    ax2.bar(range(1, 5), [6] * 4, bottom=range(1,5), color='green', ecolor='black')

ax2.set_xticks([1.5,2.5,3.5,4.5])

patterns = ('-', '+', 'x', '\\', '*', 'o', 'O', '.')

for bar, pattern in zip(bars, patterns):

     bar.set_hatch(pattern)

ax3 = fig.add_subplot(133)

ax3.fill([1,3,3,1],[1,1,2,2], fill=False, hatch='\\')

ax3.add_patch(Ellipse((4,1.5), 4, 0.5, fill=False, hatch='*'))

ax3.add_patch(Polygon([[0,0],[4,1.1],[6,2.5],[2,1.4]], closed=True,

                      fill=False, hatch='/'))

ax3.set_xlim((0,6))
ax3.set_ylim((0,2.5))

plt.show()

I was able to run this script and save the eps file just fine. However, the resulting image is completely wrong. I have attached a screenshot of the eps file as viewed in evince. Essentially, all of the hatching elements are not at all what they are supposed to be.

Ben Root

···

On Wed, Dec 15, 2010 at 6:25 AM, Teng Liu <lewtonstein@…1972…> wrote:

Linux 2.6.32-25-generic #45-Ubuntu SMP Sat Oct 16 19:48:22 UTC 2010 i686 GNU/Linux
matplotlib 0.99.1.1
The script below is copied from
http://matplotlib.sourceforge.net/examples/pylab_examples/hatch_demo.html

It works. But it can not be saved as an eps file.
I have a lot of histogram plots using “hatch” needed to be saved as eps, is it possible to fix this bug?
Thanks.

"""



Hatching (pattern filled polygons) is supported currently in the PS,
PDF, SVG and Agg backends only.
"""
import matplotlib.pyplot as plt



from matplotlib.patches import Ellipse, Polygon

fig = plt.figure()



ax1 = fig.add_subplot(131)
ax1.bar(range(1,5), range(1,5), color='red', edgecolor='black', hatch="/")



ax1.bar(range(1,5), [6] * 4, bottom=range(1,5), color='blue', edgecolor='black', hatch='//')



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


ax2 = fig.add_subplot(132)
bars = ax2.bar(range(1,5), range(1,5), color='yellow', ecolor='black') + \



    ax2.bar(range(1, 5), [6] * 4, bottom=range(1,5), color='green', ecolor='black')



ax2.set_xticks([1.5,2.5,3.5,4.5])


patterns = ('-', '+', 'x', '\\', '*', 'o', 'O', '.')



for bar, pattern in zip(bars, patterns):

     bar.set_hatch(pattern)

ax3 = fig.add_subplot(133)



ax3.fill([1,3,3,1],[1,1,2,2], fill=False, hatch='\\')



ax3.add_patch(Ellipse((4,1.5), 4, 0.5, fill=False, hatch='*'))



ax3.add_patch(Polygon([[0,0],[4,1.1],[6,2.5],[2,1.4]], closed=True,



                      fill=False, hatch='/'))

ax3.set_xlim((0,6))
ax3.set_ylim((0,2.5))




plt.show()



I am re-pinging this issue. Could it be a path simplification issue?

Ben Root

···

On Wed, Dec 15, 2010 at 9:47 AM, Benjamin Root <ben.root@…3146…4…> wrote:

On Wed, Dec 15, 2010 at 6:25 AM, Teng Liu <lewtonstein@…287…> wrote:

Linux 2.6.32-25-generic #45-Ubuntu SMP Sat Oct 16 19:48:22 UTC 2010 i686 GNU/Linux
matplotlib 0.99.1.1
The script below is copied from
http://matplotlib.sourceforge.net/examples/pylab_examples/hatch_demo.html

It works. But it can not be saved as an eps file.
I have a lot of histogram plots using “hatch” needed to be saved as eps, is it possible to fix this bug?
Thanks.

"""




Hatching (pattern filled polygons) is supported currently in the PS,
PDF, SVG and Agg backends only.
"""
import matplotlib.pyplot as plt




from matplotlib.patches import Ellipse, Polygon

fig = plt.figure()




ax1 = fig.add_subplot(131)
ax1.bar(range(1,5), range(1,5), color='red', edgecolor='black', hatch="/")




ax1.bar(range(1,5), [6] * 4, bottom=range(1,5), color='blue', edgecolor='black', hatch='//')




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


ax2 = fig.add_subplot(132)
bars = ax2.bar(range(1,5), range(1,5), color='yellow', ecolor='black') + \




    ax2.bar(range(1, 5), [6] * 4, bottom=range(1,5), color='green', ecolor='black')




ax2.set_xticks([1.5,2.5,3.5,4.5])


patterns = ('-', '+', 'x', '\\', '*', 'o', 'O', '.')




for bar, pattern in zip(bars, patterns):

     bar.set_hatch(pattern)

ax3 = fig.add_subplot(133)




ax3.fill([1,3,3,1],[1,1,2,2], fill=False, hatch='\\')




ax3.add_patch(Ellipse((4,1.5), 4, 0.5, fill=False, hatch='*'))




ax3.add_patch(Polygon([[0,0],[4,1.1],[6,2.5],[2,1.4]], closed=True,




                      fill=False, hatch='/'))

ax3.set_xlim((0,6))
ax3.set_ylim((0,2.5))





plt.show()



I was able to run this script and save the eps file just fine. However, the resulting image is completely wrong. I have attached a screenshot of the eps file as viewed in evince. Essentially, all of the hatching elements are not at all what they are supposed to be.

Ben Root

Can you elaborate what you mean by this?

Does it raise an exception? Or the output is wrong?

-JJ

···

On Wed, Dec 15, 2010 at 9:25 PM, Teng Liu <lewtonstein@...287...> wrote:

But it can not be saved as an eps file.

Benjamin,
Can you post the eps file?

With matplotlib from the svn, everything is fine in my system.

Regards,

-JJ

···

On Thu, Dec 16, 2010 at 12:47 AM, Benjamin Root <ben.root@...1304...> wrote:

On Wed, Dec 15, 2010 at 6:25 AM, Teng Liu <lewtonstein@...287...> wrote:

Linux 2.6.32-25-generic #45-Ubuntu SMP Sat Oct 16 19:48:22 UTC 2010 i686
GNU/Linux
matplotlib 0.99.1.1
The script below is copied from
http://matplotlib.sourceforge.net/examples/pylab_examples/hatch_demo.html
It works. But it can not be saved as an eps file.
I have a lot of histogram plots using "hatch" needed to be saved as eps,
is it possible to fix this bug?
Thanks.

"""

Hatching (pattern filled polygons) is supported currently in the PS,
PDF, SVG and Agg backends only.
"""
import matplotlib.pyplot as plt

from matplotlib.patches import Ellipse, Polygon

fig = plt.figure()

ax1 = fig.add_subplot(131)
ax1.bar(range(1,5), range(1,5), color='red', edgecolor='black', hatch="/")

ax1.bar(range(1,5), [6] * 4, bottom=range(1,5), color='blue',
edgecolor='black', hatch='//')

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

ax2 = fig.add_subplot(132)
bars = ax2.bar(range(1,5), range(1,5), color='yellow', ecolor='black') + \

    ax2.bar(range(1, 5), [6] * 4, bottom=range(1,5), color='green',
ecolor='black')

ax2.set_xticks([1.5,2.5,3.5,4.5])

patterns = ('-', '+', 'x', '\\', '*', 'o', 'O', '.')

for bar, pattern in zip(bars, patterns):

     bar.set_hatch(pattern)

ax3 = fig.add_subplot(133)

ax3.fill([1,3,3,1],[1,1,2,2], fill=False, hatch='\\')

ax3.add_patch(Ellipse((4,1.5), 4, 0.5, fill=False, hatch='*'))

ax3.add_patch(Polygon([[0,0],[4,1.1],[6,2.5],[2,1.4]], closed=True,

                      fill=False, hatch='/'))

ax3.set_xlim((0,6))
ax3.set_ylim((0,2.5))

plt.show()

I was able to run this script and save the eps file just fine. However, the
resulting image is completely wrong. I have attached a screenshot of the
eps file as viewed in evince. Essentially, all of the hatching elements are
not at all what they are supposed to be.

Ben Root

------------------------------------------------------------------------------
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

JJ,

Attached is my eps file produced from the latest svn. I am using evince 2.30.3 to view it.

Ben Root

hatchpatchkids.eps (115 KB)

···

On Tue, Dec 28, 2010 at 8:25 PM, Jae-Joon Lee <lee.j.joon@…2015…87…> wrote:

Benjamin,

Can you post the eps file?

With matplotlib from the svn, everything is fine in my system.

Regards,

-JJ

I think this is a bug in the ghostscript (which I believe that has
been fixed recently). If you turn off antialiasing, the hatches come
out fine. Did you use "round" join-style to create this output? My
recollection is that this bug (of ghostscript) only happen when ghost
script does antialiasing for paths with "round" join style.

Regards,

-JJ

···

On Tue, Jan 4, 2011 at 6:23 AM, Benjamin Root <ben.root@...1304...> wrote:

On Tue, Dec 28, 2010 at 8:25 PM, Jae-Joon Lee <lee.j.joon@...287...> wrote:

Benjamin,
Can you post the eps file?

With matplotlib from the svn, everything is fine in my system.

Regards,

-JJ

JJ,

Attached is my eps file produced from the latest svn. I am using evince
2.30.3 to view it.

Ben Root