Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Digits Cut off In Axis Text #268

Open
pemb4571 opened this issue Feb 7, 2019 · 4 comments
Open

Digits Cut off In Axis Text #268

pemb4571 opened this issue Feb 7, 2019 · 4 comments

Comments

@pemb4571
Copy link

pemb4571 commented Feb 7, 2019

I'm trying to export PDF with OpenGL and transparency on and using Matlab R2018b. The text on left and right axes is being cut off, in particular zeros:
image
image

export_fig(fig, 'myfile','-OpenGL','-pdf','-nocrop');

I've tried switching fonts, adding padding, turning off cropping, turning off font switching, but nothing helps. Painters and Zbuffer fixes the issue but I really need to use the transparency option.

I am using multiple subplots in this which might be the cause.

@pemb4571 pemb4571 changed the title Zeros Cut off In Axis Text Digits Cut off In Axis Text Feb 7, 2019
@altmany
Copy link
Owner

altmany commented Feb 7, 2019

  1. when you export to EPS, do you still see cropped zeros?
  2. if not (EPS is ok, PDF not), then the problem is in the ghostscript program, which converts EPS to PDF - this is called in eps2pdf.m, so try debugging it there (maybe a change in the ghostscript options (line 62) will fix the problem.
  3. if yes (EPS is also not ok), then try running the following and let me know what happens:
print(fig, '-loose', '-opengl', '-r864', '-depsc2', 'myfile.eps')
  1. if the resulting EPS file is good, then the problem is either in export_fig's figure preparation (export_fig.m lines 325-713 and print2eps.m lines 102-300), or its EPS post-processing (print2eps.m lines 303 onward).
  2. if the resulting EPS file is not good, then it means there is an inherent bug in Matlab's built-in print function. In this case try using other parameters (e.g., '-r300' or '-depsc'), maybe these will solve it.

In any case, let me know what you find.

@pemb4571
Copy link
Author

pemb4571 commented Feb 8, 2019

Thanks for getting back to me. It doesn't crop when i use eps so I can look into the eps2pdf.m file. Do you have any clue which options I can try changing?

@pemb4571
Copy link
Author

pemb4571 commented Feb 23, 2019

Hello,

I haven't had any luck with changing the options. When I open the pdf file with Inkscape it's clear this cropping is caused by these tiles:

image

I've tried turning off all the elements of the figure that could be causing it (e.g. no grid, changing the background colour etc). Do you have any idea what it might be? It seems pretty integral though.

@altmany
Copy link
Owner

altmany commented Mar 21, 2019

The Inkscape image that you uploaded does not show any digit cropping (the "0" looks perfectly round in your image). I could also not see any significant cropping in my tests. So I'm thinking that perhaps the cropping is an artifact of your specific PDF viewer - try loading the PDF file in a different viewer and see if you still see a problem.

If the problem is still there, then perhaps it is due to one of the Ghostscript options (Ghostscript is used to convert the intermediary EPS to PDF). This is done in line 143 of eps2pdf.m. I suggest that you take your EPS file (the one that you said looks good, and play with the Ghostscript options by removing them one by one and inspecting the output. For example, let's assume your EPS file is called "C:\test.eps". You could try the following in the Matlab Command Window:

% Default options
options = '-q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -sOutputFile="C:\test1.pdf" -dEPSCrop -sFONTPATH="C:\Windows\Fonts" -f "C:\test.eps"';
ghostscript(options); winopen('C:\test1.pdf')

% remove the FONTPATH option and recheck:
options = '-q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -sOutputFile="C:\test2.pdf" -dEPSCrop -f "C:\test.eps"';
ghostscript(options); winopen('C:\test2.pdf')

% remove the EPSCrop option and recheck:
options = '-q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -sOutputFile="C:\test3.pdf" -sFONTPATH="C:\Windows\Fonts" -f "C:\test.eps"';
ghostscript(options); winopen('C:\test3.pdf')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants