Figure cropped without warning #1365

Closed
qifei9 opened this Issue Feb 23, 2017 · 3 comments

Comments

Projects
None yet
2 participants
@qifei9

qifei9 commented Feb 23, 2017

When render Rmd to pdf, the figures are cropped by default. The EPS figures are in bad quality (no longer vector graphics?) after cropped by ImageMagick and there is no warning about this.

@yihui

This comment has been minimized.

Show comment
Hide comment
@yihui

yihui Feb 23, 2017

Owner

That is a decision made in rmarkdown. If you do not want this feature, you can turn it off by fig_crop = FALSE, e.g.

output:
  pdf_document:
    fig_crop: false

That said... Seriously? Are there still journals that require EPS figures?... 😂

Owner

yihui commented Feb 23, 2017

That is a decision made in rmarkdown. If you do not want this feature, you can turn it off by fig_crop = FALSE, e.g.

output:
  pdf_document:
    fig_crop: false

That said... Seriously? Are there still journals that require EPS figures?... 😂

@qifei9

This comment has been minimized.

Show comment
Hide comment
@qifei9

qifei9 Feb 24, 2017

Problem

I found this option of rmd. This option is mentioned in the rmarkdown reference guide and in http://rmarkdown.rstudio.com/pdf_document_format.html#figure_options. However, neither of these two documents warn about the impairment to EPS figures.

The problem is that, when user use dev option like postscript or cario_ps, he will get low quality figures and no clue about why the figure quality is impaired. It may be very hard to connect the impairment to fig_crop option.

For myself, I spent rather long time to find out why EPS figure is in low quality. Finally I found with dev='CairoPS', the figure is OK. This is due to a bug #1364 about the filename of the figure. I notice a warning like convert cannot open file xxx. Then I wondered what is convert. I read the code of knitr/R/plot.R, found the code about crop and finally point the impairment to fig_crop.

The fig_crop is true by default, so I think at least a warning should be given in the document or printed when render. Then users can finger out how to get high quality EPS figures.

EPS vs PDF

When manager the figures under git. If you store figures in PDF, every time you render the rmd file, git will mark the figures as modified even there is no change in the figures. If the figures are stored in EPS format, there is no problem. git can read the figures and know the figures are not changed.

Perhaps this issue should be reported in rmarkdown repo?

qifei9 commented Feb 24, 2017

Problem

I found this option of rmd. This option is mentioned in the rmarkdown reference guide and in http://rmarkdown.rstudio.com/pdf_document_format.html#figure_options. However, neither of these two documents warn about the impairment to EPS figures.

The problem is that, when user use dev option like postscript or cario_ps, he will get low quality figures and no clue about why the figure quality is impaired. It may be very hard to connect the impairment to fig_crop option.

For myself, I spent rather long time to find out why EPS figure is in low quality. Finally I found with dev='CairoPS', the figure is OK. This is due to a bug #1364 about the filename of the figure. I notice a warning like convert cannot open file xxx. Then I wondered what is convert. I read the code of knitr/R/plot.R, found the code about crop and finally point the impairment to fig_crop.

The fig_crop is true by default, so I think at least a warning should be given in the document or printed when render. Then users can finger out how to get high quality EPS figures.

EPS vs PDF

When manager the figures under git. If you store figures in PDF, every time you render the rmd file, git will mark the figures as modified even there is no change in the figures. If the figures are stored in EPS format, there is no problem. git can read the figures and know the figures are not changed.

Perhaps this issue should be reported in rmarkdown repo?

@yihui

This comment has been minimized.

Show comment
Hide comment
@yihui

yihui Feb 25, 2017

Owner

I'm very sorry for wasting your time. I think we should definitely mention the problem with cropping eps figures in the rmarkdown documentation.

It is indeed tricky to deal with binary files in git. Usually I try to avoid committing binary files into git, such as images generated from R (I ignore them in .gitignore). I understand that this may not be an option for you if you are collaborating with other people, though.

Owner

yihui commented Feb 25, 2017

I'm very sorry for wasting your time. I think we should definitely mention the problem with cropping eps figures in the rmarkdown documentation.

It is indeed tricky to deal with binary files in git. Usually I try to avoid committing binary files into git, such as images generated from R (I ignore them in .gitignore). I understand that this may not be an option for you if you are collaborating with other people, though.

yihui added a commit to rstudio/rmarkdown that referenced this issue Feb 25, 2017

@yihui yihui closed this Mar 6, 2017

@yihui yihui added this to the v1.16 milestone Mar 6, 2017

@yihui yihui added the Doc label Mar 6, 2017

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