2017-07-18 108 views
0

我试图简单地将一个图例添加到我的奈奎斯特图中,绘制2组数据:1是实验组(约600分),2是数据框使用传递函数计算(〜1000分)将自定义图例添加到ggplot2中的2个数据集

我需要绘制两者并标记它们。目前我有他们都绘制好,但当我尝试使用scale_colour_manual添加标签没有标签出现。另外一种方式来移动这个标签周围将不胜感激!代码如下。

pdf("nyq_2elc.pdf") 

    nq2 <- ggplot() + geom_point(data = treat, aes(treat$V1,treat$V2), color = "red") + 
    geom_point(data = circuit, aes(circuit$realTF,circuit$V2), color = "blue") + 
    xlab("Real Z") + ylab("-Imaginary Z") + 
    scale_colour_manual(name = 'hell0', 
         values =c('red'='red','blue'='blue'), labels = c('Treatment','EQ')) + 
    ggtitle("Nyquist Plot and Equivilent Circuit for 2 Electrode Treatment Setup at 0 Minutes") + 
    xlim(0,700) + ylim(0,700) 


print(nq2) 
dev.off() 

回答

0

Ggplot在最佳状态下长dataframes,所以我会结合数据集是这样的:

treat$Cat <- "treat" 
circuit$Cat <- "circuit" 
CombData <- data.frame(rbind(treat, circuit)) 

ggplot(CombData, aes(x=V1, y=V2, col=Cat))+geom_point() 

这应该给你你想要的传说。

你可能必须改变dataframes treatcircuit,使他们可以合并的列的名称/订单,但很难说,因为你不给我们一个重复的例子。

+0

作品完美!谢谢:D – CHopp

相关问题