command line fitCanvasToDrawing
Matplotlib produces pdf figures whose bounding boxes do not enclose all of the contents of the figure (or, usually, are too big).
I thought inkscape could easily solve this problem with:
inkscape -f matplotlibOutput.pdf --verb=FitCanvasToDrawing -A prettyfigure.pdf
But that leaves the pdf unchanged. Have I made a basic error?
Thanks, Chris
On 16/12/2011 02:41, cpblpublic+usenet@...155... wrote:
inkscape -f matplotlibOutput.pdf --verb=FitCanvasToDrawing -A prettyfigure.pdf But that leaves the pdf unchanged. Have I made a basic error?
Yes, using the inkscape command line.
Seriously. It's broken. This is sad, but so. :(
I have often tried it. It always fails, and then I'm off down xml, python or other roads to try do the same thing.
\d
On 16/12/11 01:41, cpblpublic+usenet@...155... wrote:
Matplotlib produces pdf figures whose bounding boxes do not enclose all of the contents of the figure (or, usually, are too big).
I thought inkscape could easily solve this problem with:
inkscape -f matplotlibOutput.pdf --verb=FitCanvasToDrawing -A prettyfigure.pdf
But that leaves the pdf unchanged. Have I made a basic error?
Try this:
$ cp matplotlibOutput.pdf prettyfigure.pdf $ inkscape -f prettyfigure.pdf.pdf \ --verb=FitCanvasToDrawing \ --verb=FileSave \ --verb=FileQuit
Note: when using verbs on the command line, the GUI cannot be suppressed [1] (limits the usefulness of verbs for scripting or when trying to run Inkscape on a web server as conversion tool): you will need to press some buttons for commands that have options: 1 - Importing (aka opening) a PDF needs a confirmation in the import options dialog 2 - Exporting (saving as PDF) also requires a confirmation in the export options dialog 3 - The warning that you saved in a lossy format makes more sense when working with the GUI right from the beginning. I'm not aware of a setting to turn that warning off.
hth, ~suv
[1] http://tavmjong.free.fr/INKSCAPE/MANUAL/html/CommandLine.html
On 16/12/11 09:55, ~suv wrote:
On 16/12/11 01:41, cpblpublic+usenet@...155... wrote:
Matplotlib produces pdf figures whose bounding boxes do not enclose all of the contents of the figure (or, usually, are too big).
I thought inkscape could easily solve this problem with:
inkscape -f matplotlibOutput.pdf --verb=FitCanvasToDrawing -A prettyfigure.pdf
But that leaves the pdf unchanged. Have I made a basic error?
Try this:
$ cp matplotlibOutput.pdf prettyfigure.pdf $ inkscape -f prettyfigure.pdf.pdf \ --verb=FitCanvasToDrawing \ --verb=FileSave \ --verb=FileQuit
Sorry for the typo:
$ cp matplotlibOutput.pdf prettyfigure.pdf $ inkscape -f prettyfigure.pdf \ --verb=FitCanvasToDrawing \ --verb=FileSave \ --verb=FileQuit
~suv
On 16/12/11 09:55, ~suv wrote:
On 16/12/11 01:41, cpblpublic+usenet@...155... wrote:
Matplotlib produces pdf figures whose bounding boxes do not enclose all of the contents of the figure (or, usually, are too big).
I thought inkscape could easily solve this problem with:
inkscape -f matplotlibOutput.pdf --verb=FitCanvasToDrawing -A prettyfigure.pdf
But that leaves the pdf unchanged. Have I made a basic error?
Try this:
$ cp matplotlibOutput.pdf prettyfigure.pdf $ inkscape -f prettyfigure.pdf.pdf \ --verb=FitCanvasToDrawing \ --verb=FileSave \ --verb=FileQuit
Note: when using verbs on the command line, the GUI cannot be suppressed [1] (limits the usefulness of verbs for scripting or when trying to run Inkscape on a web server as conversion tool): you will need to press some buttons for commands that have options: 1 - Importing (aka opening) a PDF needs a confirmation in the import options dialog 2 - Exporting (saving as PDF) also requires a confirmation in the export options dialog 3 - The warning that you saved in a lossy format makes more sense when working with the GUI right from the beginning. I'm not aware of a setting to turn that warning off.
Alternative without needing to press any buttons:
$ inkscape -f matplotlibOutput.pdf -l matplotlibOutput.svg $ inkscape -f matplotlibOutput.svg --verb=FitCanvasToDrawing \ --verb=FileSave \ --verb=FileQuit $ inkscape -f matplotlibOutput.svg -A prettyfigure.pdf $ rm matplotlibOutput.svg
hth, ~suv
participants (3)
-
unknown@example.com
-
donn
-
~suv