我如何绘制有限点的线条和点? [英] How do I plot lines and points with limited points?

查看:90
本文介绍了我如何绘制有限点的线条和点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图以更清晰的方式重新绘制下图。观察我正在尝试绘制线条和点。但是,正在打印的点数太多了,线条被掩盖了。有什么方法可以绘制:


  • 不同数据集的不同行

  • 不同的数据集,但限制点的数量为30-50

  • 添加线条和点信息到图例




我的绘图代码是这里(对SO来说太大了)

解决方案

你需要这样的东西吗?

  transData $ Type2<  -  factor(transData $ Type,labels = c(Some Info for P,Some Info for Q))
ggplot(transData,aes(x = Value,y = ecd)) +
geom_line(aes(group = Type2,color = Type2,linetype = Type2),size = 1.5)+
geom_point(aes(shape = Type2),data = transData [round(seq(1, nrow(transData),length = 30)),],size = 5)+
opts(legend.positi on =top,legend.key.width = unit(3,line))


I am trying to replot the following figure in a more legible way. Observe that I am trying to plot both lines and points. However, the number of points being printed is way too many and the line is getting covered up. Is there a way I can plot:

  • Different lines for different datasets
  • Different points shapes for different datasets but limit the number of points to say 30-50
  • Add the line and point information to the legend

My plotting code is here (It was too big for SO)

解决方案

Do you need something like this?

transData$Type2 <- factor(transData$Type, labels = c("Some Info for P", "Some Info for Q"))    
ggplot(transData, aes(x=Value, y=ecd)) + 
  geom_line(aes(group=Type2,colour=Type2, linetype=Type2), size=1.5) + 
  geom_point(aes(shape = Type2), data = transData[round(seq(1, nrow(transData), length = 30)), ], size = 5) +
  opts(legend.position = "top", legend.key.width = unit(3, "line"))

这篇关于我如何绘制有限点的线条和点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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