r 中的罗马斜体标签

发布于 2024-11-07 04:02:13 字数 342 浏览 0 评论 0原文

我有一个非常简单的脚本:

sens = read.table("Myfile.txt")
library(lattice)
contourplot(sens$V1 ~ sens$V2+sens$V3,data=d3,xlab="U",ylab=expression(kappa))

我一直在尝试以罗马斜体字体获取标签。我认为

font.lab=3, family="serif"

应该给我这个,但无论我尝试什么(font = 3,font =“italic”...)都不会改变字体。

有人能发现我做错了什么吗? 谢谢。

I have a very simple script:

sens = read.table("Myfile.txt")
library(lattice)
contourplot(sens$V1 ~ sens$V2+sens$V3,data=d3,xlab="U",ylab=expression(kappa))

I have been trying to get my labels in roman italic font. I thought

font.lab=3, family="serif"

should give me exactly this but whatever I try (font=3,font="italic"...) just doesn't change the font at all.

Can anybody spot what I'm doing wrong?
Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

—━☆沉默づ 2024-11-14 04:02:13

您可以尝试使用 italic 函数和 unicode 符号。

require(lattice)
require(grid)
x <- seq(pi/4, 5 * pi, length.out = 100)
y <- seq(pi/4, 5 * pi, length.out = 100)
r <- as.vector(sqrt(outer(x^2, y^2, "+")))
grid <- expand.grid(x=x, y=y)
grid$z <- cos(r^2) * exp(-r/(pi^3))

contourplot(z~x*y, grid, cuts = 1,
  colorkey = FALSE, region = TRUE,
  xlab=expression(italic(U)),
  ylab=expression(italic('\u03ba')))
grid.gedit("text", gp=gpar(fontfamily="serif"))
grid.gedit("xlab", gp=gpar(fontfamily="serif"))
grid.gedit("ylab", gp=gpar(fontfamily="serif"))

You could try the italic function and unicode symbols.

require(lattice)
require(grid)
x <- seq(pi/4, 5 * pi, length.out = 100)
y <- seq(pi/4, 5 * pi, length.out = 100)
r <- as.vector(sqrt(outer(x^2, y^2, "+")))
grid <- expand.grid(x=x, y=y)
grid$z <- cos(r^2) * exp(-r/(pi^3))

contourplot(z~x*y, grid, cuts = 1,
  colorkey = FALSE, region = TRUE,
  xlab=expression(italic(U)),
  ylab=expression(italic('\u03ba')))
grid.gedit("text", gp=gpar(fontfamily="serif"))
grid.gedit("xlab", gp=gpar(fontfamily="serif"))
grid.gedit("ylab", gp=gpar(fontfamily="serif"))
十年九夏 2024-11-14 04:02:13

设置主题将允许您全局更改这些主题。

font.settings <- list(font = 3, fontfamily = "serif")

my.theme <- list(par.xlab.text = font.settings,
                 par.ylab.text = font.settings,
                 axis.text = list(fontfamily = "serif"))

然后将 par.settings = my.theme 添加到轮廓图语句中

contourplot(sens$V1 ~ sens$V2+sens$V3,data=d3,xlab="U",ylab=expression(kappa), 
            par.settings = my.theme)

Setting up a theme will allow you to change these globally.

font.settings <- list(font = 3, fontfamily = "serif")

my.theme <- list(par.xlab.text = font.settings,
                 par.ylab.text = font.settings,
                 axis.text = list(fontfamily = "serif"))

Then add par.settings = my.theme to the contourplot statement

contourplot(sens$V1 ~ sens$V2+sens$V3,data=d3,xlab="U",ylab=expression(kappa), 
            par.settings = my.theme)
陈甜 2024-11-14 04:02:13

尽管 Triad Sou 的答案在 R Graphics 窗口上有效,但当我尝试使用以下命令以 eps 格式打印绘图时,标签仍然采用非衬线字体:

dev.print(device=postscript,file="Myfile.eps")

因此,对于我的 eps 文件,我必须执行以下操作:

contourplot(sens$Tot ~ sens$U+sens$kappa,data=d3,
        xlab=expression(italic(U)),ylab=expression(italic(kappa)))
dev.print(device=postscript,file="Myfile.eps",family="serif")

Although Triad Sou's answer worked on the R Graphics window, the labels were still in a non-serif font when I tried to print the plot in an eps format with the command:

dev.print(device=postscript,file="Myfile.eps")

So for my eps file I had to do:

contourplot(sens$Tot ~ sens$U+sens$kappa,data=d3,
        xlab=expression(italic(U)),ylab=expression(italic(kappa)))
dev.print(device=postscript,file="Myfile.eps",family="serif")
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文