R绘制一些Unicode字符,但不绘制其他字符 [英] R plots some unicode characters but not others

查看:89
本文介绍了R绘制一些Unicode字符,但不绘制其他字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的系统管理员刚刚将我们的操作系统升级到SLES12SP1。我重新安装了Rv3.2.3,并试图进行绘制。我使用 cairo_pdf 并尝试绘制x标签为 \u0298 的图,即太阳符号,但是它不起作用:标签只是空白。例如:

our sysadmin just upgraded our operating system to SLES12SP1. I reinstalled Rv3.2.3 and tried to make plots. I use cairo_pdf and try to make a plot with the x-label being \u0298 i.e. the solar symbol, but it doesn't work: the label just comes out blank. For example:

cairo_pdf('Rplots.pdf')
plot(1, xlab='\u0298') # the x-label comes up blank
dev.off()

工作,但由于某种原因,它不再。它可以与其他字符一起使用,例如

This used to work, but for some reason it does not anymore. It works with other characters, e.g.

cairo_pdf('Rplots.pdf')
plot(1, xlab='\u2113') # the x-label comes up with the \ell symbol
dev.off()

何时我只是粘贴太阳符号,即

When I just paste in the solar symbol, i.e.

plot(1, xlab='ʘ')

然后我得到警告

Warning messages:
1: In title(...) :
  conversion failure on 'ʘ' in 'mbcsToSbcs': dot substituted for <ca>

机器是德语,但是我使用的是美国英语UTF-8语言环境:

The machine is German, but I am using the US English UTF-8 locale:

> sessionInfo()
R version 3.2.3 (2015-12-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: SUSE Linux Enterprise Server 12 SP1

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
 [9] LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

关于我能使太阳符号出现吗?

Any tips on how I can get the solar symbol to appear?

推荐答案

也许您的文本编辑器使用的是latin1,因此才可以将latin1字符发送到控制台。

Maybe your text editor is using latin1, therfore you would send latin1 characters to your console.

查看编码

Encoding('ʘ')

和/或尝试

plot(1, xlab=iconv('ʘ', from='latin1', to="UTF-8"))

,但是请注意,编码可能会在应对时发生变化。
如果您使用Notepad ++,则可以在文本编辑器中在不同的编码之间进行转换。

but be carefull the encoding could change while coping. If you use Notepad++ you can convert in the text editor between the different encodings.

这篇关于R绘制一些Unicode字符,但不绘制其他字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆