corrupt pdf of histogram

Benjamin Root <ben.root@...1304...> writes:

sanders <sanders@...3329...> writes:

> If keywords fill=False and log=True,
> then after saving, the png looks fine but the histogram in the pdf is
> mixed up.

Confirmed, thanks for the report. I filed this at
pdf backend bug with logarithmic plots · Issue #804 · matplotlib/matplotlib · GitHub

I ran into something like this with filled plots originally saved as eps
files and then converted into a pdf. Didn't need log=True, though.

I think that's likely a different issue. The eps output machinery in
matplotlib is somewhat complicated, which it likely has to be to
function well with various eps-handling software, and incorporate
LaTeX-rendered equations. With all the various steps (including
distilling through an external program) it's difficult to debug what
goes wrong.

In the original problem, it seems that the path-cropping functionality
used in logarithmic plots is outputting paths that work in Agg but not
in pdf or svg. It basically rewrites

  moveto X0,Y0 (outside plottable area)
  lineto X1,Y0 (outside plottable area)
  lineto X1,Y1 (inside)
  lineto X0,Y1 (inside)


  moveto X0,Y0' (Y0' is Y0 rewritten to be close to the area)
  moveto X1,Y0'
  lineto X1,Y1
  lineto X0,Y1

and the closepath operation apparently goes to the first moveto in Agg,
but to the latest moveto in pdf and svg.

I have a suggested fix for this at


Jouni K. Sepp�nen