Corrupt/invalid PDF and EPS files when saving a logscaled plot made with negative values #1799

Merged
merged 1 commit into from Mar 7, 2013

Conversation

Projects
None yet
3 participants
@mdboom
Owner

mdboom commented Mar 7, 2013

This is with matplotlib 1.1.0, via the Pylab interface (I'm using a version supplied with PythonXY):

import pylab as p
import numpy as np

x = np.arange(10)
y = np.arange(10)-1

p.scatter(x,y)
p.xscale('log')
p.yscale('log')

Saving the plot as an EPS or PDF produces an invalid file; when opening the PDF, Adobe Reader says "Path lacks initial MOVETO". PNG output looks fine.

Granted, negative values can't be plotted on a log scale, but creating a bad output file seems like a bug. As a workaround, I now filter my data for negative values before plotting.

@WeatherGod

This comment has been minimized.

Show comment Hide comment
@WeatherGod

WeatherGod Mar 1, 2013

Member

Fixed, I think, by #684. Although, admittedly, that bug threw an exception
during runtime.

Member

WeatherGod commented Mar 1, 2013

Fixed, I think, by #684. Although, admittedly, that bug threw an exception
during runtime.

@andrewcollette

This comment has been minimized.

Show comment Hide comment
@andrewcollette

andrewcollette Mar 1, 2013

Just tried it with matplotlib 1.2.0 (new install via pip on Linux). When saving a PDF, I get a popup saying "Can only output finite numbers in PDF". When saving EPS, the save completes but the file can't be opened in any EPS viewer I tried.

Just tried it with matplotlib 1.2.0 (new install via pip on Linux). When saving a PDF, I get a popup saying "Can only output finite numbers in PDF". When saving EPS, the save completes but the file can't be opened in any EPS viewer I tried.

@mdboom

This comment has been minimized.

Show comment Hide comment
@mdboom

mdboom Mar 7, 2013

Owner

Good catch. This seems to be specific to path collections, which is rare on a log plot, so we haven't caught it. Expect a fix shortly.

Owner

mdboom commented Mar 7, 2013

Good catch. This seems to be specific to path collections, which is rare on a log plot, so we haven't caught it. Expect a fix shortly.

@mdboom

This comment has been minimized.

Show comment Hide comment
@mdboom

mdboom Mar 7, 2013

Owner

@andrewcollette: Would you mind testing the attached patch to confirm that it addresses your issue?

Owner

mdboom commented Mar 7, 2013

@andrewcollette: Would you mind testing the attached patch to confirm that it addresses your issue?

mdboom added a commit that referenced this pull request Mar 7, 2013

Merge pull request #1799 from mdboom/issue1799
Corrupt/invalid PDF and EPS files when saving a logscaled plot made with negative values

@mdboom mdboom merged commit ff749cb into matplotlib:v1.2.x Mar 7, 2013

1 check passed

default The Travis build passed
Details

HubertHolin added a commit to HubertHolin/matplotlib that referenced this pull request Apr 7, 2013

@mdboom mdboom deleted the mdboom:issue1799 branch Aug 7, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment