plot图例中添加pch符号

plot图例中添加pch符号

本文介绍了在R plot图例中添加pch符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个时间序列,用黑线表示,一个用红色曲线表示。然后我在R中有单个符号为8的点。这些是星星。见下图:



目前我有以下的图例:
$ b $ pre $ code> legend(bottomleft,
legend = c(log loss ,每日VaR,超额),
bty =n,lwd = 2,cex = 1.2,y.intersp = 1.4,col = c(black ),lty = c(1,1,1))

但我不想超越传说中的蓝线,而只是情节中的星星。我必须使用pch = 8。我只想拥有传说中的明星,而不是一线明星。所以不是这些解决方案:R的传奇问题,点的符号被行掩盖了

解决方案

试试这个。你设置lty只显示前两行,而pch只显示最后一个点。

  plot(1:10,rnorm (10)* 1:10)
legend(bottomleft,legend = c(entry1,entry2,something cpl different),bty =n,
lwd = 2 ,cex = 1.2,col = c(黑色,蓝色,红色),lty = c(1,1,NA),pch = c(NA,NA,8))
code>

I have one time series which is represented by a black line and one which is represented by a red curve. Then I have single points which have the pch symbol of 8 in R. These are stars. See the following plot:

Currently I have the following legend:

legend("bottomleft",
 legend=c("log loss","daily VaR","exceedance"),
 bty = "n",lwd=2, cex=1.2,y.intersp=1.4, col=c("black","red","blue"), lty=c(1,1,1))

But I don't want to have a blue line in the legend for exceedance, but just the stars in the plot. I have to use the pch=8. I just want to have the stars in the legend, not the stars with a line. So not these solutions: R legend issue, symbols of points are masked by lines

解决方案

Try this. You set lty to display only first two lines, and pch to display only the last point.

plot(1:10, rnorm(10) * 1:10)
legend("bottomleft", legend = c("entry1", "entry2", "something cpl different"), bty = "n",
       lwd = 2, cex = 1.2, col = c("black", "blue", "red"), lty = c(1, 1, NA), pch = c(NA, NA, 8))

这篇关于在R plot图例中添加pch符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 19:29