about lable changes in file format

73 views
Skip to first unread message

lily li

unread,
Sep 28, 2016, 8:55:24 AM9/28/16
to ggp...@googlegroups.com
Hi ggplot2 users,

I'm drawing figures, using the ggplot2 function. When there are per mil sign (‰) in the x or y-axis, and when I save the figure as a PDF file, the per mil sign becomes (...). How to solve this problem? The figures are definitely clearer when saved as PDF rather than tiff/jpg/etc format. Thanks for your help.

Roman Luštrik

unread,
Sep 28, 2016, 9:00:37 AM9/28/16
to lily li, ggp...@googlegroups.com
Can you pass another encoding to `pdf.options()`? My guess would be pdf is using some sort of encoding (from your system?) which doesn't support all relevant characters. I recommend using "UTF-8", e.g. `pdf.options(encoding = "UTF-8")`.

Cheers,
Roman

On Wed, Sep 28, 2016 at 2:53 PM, lily li <choc...@gmail.com> wrote:
Hi ggplot2 users,

I'm drawing figures, using the ggplot2 function. When there are per mil sign (‰) in the x or y-axis, and when I save the figure as a PDF file, the per mil sign becomes (...). How to solve this problem? The figures are definitely clearer when saved as PDF rather than tiff/jpg/etc format. Thanks for your help.

--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility
 
To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+unsubscribe@googlegroups.com
More options: http://groups.google.com/group/ggplot2

---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
In God we trust, all others bring data.

lily li

unread,
Sep 28, 2016, 9:24:21 AM9/28/16
to Roman Luštrik, ggp...@googlegroups.com
Thanks for your reply. I just clicked on the Export button in the lower right panel of the R-studio. It has two options only, Save as image, or Save Plot as PDF. So I couldn't set other details. Do you mean to save the file in the console?

Roman Luštrik

unread,
Sep 28, 2016, 9:35:44 AM9/28/16
to lily li, ggp...@googlegroups.com
For my needs (also printing "weird characters" like ščž) using `ggsave` in the console works flawlessly. I'm on Windows.

Cheers,
Roman

Seth Younger

unread,
Sep 28, 2016, 9:53:15 AM9/28/16
to Roman Luštrik, lily li, ggp...@googlegroups.com

My experiences have been that ‘ggsave’ does work for per mill notation on Windows but not on OS X. On OS X the only workaround I’ve been successful with is using Cairo. I tried changing the encoding on OS X but got:

 

‘Error in grDevices::pdf(..., version = version) :

  failed to load default encoding

In addition: Warning message:

  In grDevices::pdf(..., version = version) :

  failed to load encoding file 'UTF-8'’

 

Example attached.

 

Seth

 

From: rom...@gmail.com [mailto:rom...@gmail.com] On Behalf Of Roman Luštrik
Sent: Wednesday, September 28, 2016 9:35 AM
To: lily li <choc...@gmail.com>
Cc: ggp...@googlegroups.com
Subject: Re: about lable changes in file format

 

For my needs (also printing "weird characters" like ščž) using `ggsave` in the console works flawlessly. I'm on Windows.

 

Cheers,

Roman

On Wed, Sep 28, 2016 at 3:23 PM, lily li <choc...@gmail.com> wrote:

Thanks for your reply. I just clicked on the Export button in the lower right panel of the R-studio. It has two options only, Save as image, or Save Plot as PDF. So I couldn't set other details. Do you mean to save the file in the console?

On Wed, Sep 28, 2016 at 6:59 AM, Roman Luštrik <roman....@gmail.com> wrote:

Can you pass another encoding to `pdf.options()`? My guess would be pdf is using some sort of encoding (from your system?) which doesn't support all relevant characters. I recommend using "UTF-8", e.g. `pdf.options(encoding = "UTF-8")`.

 

Cheers,

Roman

On Wed, Sep 28, 2016 at 2:53 PM, lily li <choc...@gmail.com> wrote:

Hi ggplot2 users,

 

I'm drawing figures, using the ggplot2 function. When there are per mil sign (‰) in the x or y-axis, and when I save the figure as a PDF file, the per mil sign becomes (...). How to solve this problem? The figures are definitely clearer when saved as PDF rather than tiff/jpg/etc format. Thanks for your help.

--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility
 
To post: email ggp...@googlegroups.com

To unsubscribe: email ggplot2+u...@googlegroups.com


More options: http://groups.google.com/group/ggplot2

---
You received this message because you are subscribed to the Google Groups "ggplot2" group.

To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+u...@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.



 

--

In God we trust, all others bring data.



 

--

In God we trust, all others bring data.

--

--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility
 
To post: email ggp...@googlegroups.com

To unsubscribe: email ggplot2+u...@googlegroups.com


More options: http://groups.google.com/group/ggplot2

---
You received this message because you are subscribed to the Google Groups "ggplot2" group.

To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+u...@googlegroups.com.

per_mill_example.R

lily li

unread,
Sep 28, 2016, 11:04:43 AM9/28/16
to Seth Younger, Roman Luštrik, ggp...@googlegroups.com
This works. Thanks a lot, Seth.


More options: http://groups.google.com/group/ggplot2

---
You received this message because you are subscribed to the Google Groups "ggplot2" group.

To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+unsubscribe@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.



 

--

In God we trust, all others bring data.



 

--

In God we trust, all others bring data.

--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility
 
To post: email ggp...@googlegroups.com


More options: http://groups.google.com/group/ggplot2

---
You received this message because you are subscribed to the Google Groups "ggplot2" group.

To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+unsubscribe@googlegroups.com.

lily li

unread,
Sep 28, 2016, 11:09:41 AM9/28/16
to Seth Younger, Roman Luštrik, ggp...@googlegroups.com
Actually, I still have another problem. For example, I want to inset one plot to another, and save the whole as pdf file.

require(grid)
print(ggplot1.1)
print(ggplot1.2, vp=viewport(.6, .3, .5, .5) #viewport(x-location, y-location, width, height)
cairo_pdf('~/figuredoc/figure1.pdf')

But the saved file is only ggplot1.2. That is why I use the Export button to save the figure initially, so it will save the whole thing. Thanks again.
Reply all
Reply to author
Forward
0 new messages