图例文本在r图中使用latex2exp切断
我的传说中的文字使用库(latex2exp)
在传说中切断。
library(stats)
library(evd)
library(dgumbel)
library(latex2exp)
x=seq(-5,10,length.out=1001)
fgumb=dgumbel(x,location=0,scale=1)
ffrech=dfrechet(x,loc=0,scale=1,shape=1)
fweib=dweibull(x,shape=2,scale=1)
maxes=max(fgumb,ffrech,fweib)
plot(x,fgumb,type='l',lwd=2,col='blue',ylim=c(0,maxes),
ylab="f(x)")
lines(x,ffrech,type='l',lwd=2,col='red')
lines(x,fweib,type='l',lwd=2,col='green')
legend("topright",
legend=c(TeX(r'(Gumbel(\mu=0,\sigma=1)'),
TeX(r'(Frechet(\mu=0,\sigma=1,\xi=1)'),
TeX(r'(Weibull(\sigma=1,\xi=2)')),
col=c("blue","red","green"),
lwd=c(2,2,2),cex=1)
有没有办法对此进行纠正?
The text in my legend cuts off using library(latex2exp)
in a legend.
library(stats)
library(evd)
library(dgumbel)
library(latex2exp)
x=seq(-5,10,length.out=1001)
fgumb=dgumbel(x,location=0,scale=1)
ffrech=dfrechet(x,loc=0,scale=1,shape=1)
fweib=dweibull(x,shape=2,scale=1)
maxes=max(fgumb,ffrech,fweib)
plot(x,fgumb,type='l',lwd=2,col='blue',ylim=c(0,maxes),
ylab="f(x)")
lines(x,ffrech,type='l',lwd=2,col='red')
lines(x,fweib,type='l',lwd=2,col='green')
legend("topright",
legend=c(TeX(r'(Gumbel(\mu=0,\sigma=1)'),
TeX(r'(Frechet(\mu=0,\sigma=1,\xi=1)'),
TeX(r'(Weibull(\sigma=1,\xi=2)')),
col=c("blue","red","green"),
lwd=c(2,2,2),cex=1)
Is there a way to correct this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定问题是什么,但我根本无法解析你的乳胶字符串。无论如何,如果您直接将它们编写为 R 表达式,您的问题就可以解决:
I'm not sure what the problem is, but I couldn't get your latex strings to parse at all. In any case, if you write them directly as R expressions, your problem resolves: