我在power bi中具有R视觉。我使用此视觉效果显示具有点(geom_point)和线(geom_line)的散点图。
行中使用的数据(Matlab_min_head - Matlab_max_head - Matlab
)中有许多未使用的零,我想忽略掉,因为该行将显示下降。
如何排除零?
我不是R方面的专家,但是我了解功率Bi的数据调整应在构建图形时进行。我无法先过滤数据,然后再绘制结果。
稍微简化的代码(不包含所有格式)如下:
Plot1<-ggplot(dataset, aes(x=Capacity_recalculated, y=Head_recalculated))
Plot1<-Plot1+geom_point(aes(colour=Head_recalculated))
#these are the 3 black lines:
Plot1<-Plot1+geom_line(aes(y=Matlab_min_head, x=Matlab_min_Q))
Plot1<-Plot1+geom_line(aes(y=Matlab_max_head,x=Matlab_max_Q))
Plot1<-Plot1+geom_line(aes(y=Matlab_head, x=Matlab_Q))
Plot1
更新:
因此,我对Ismail's answer之后的子集进行了自我教育。 我想我知道问题出在哪里: 我的数据如下:
Project: Head_recalculated: Matlab_min_head: Matlab_head:
1 10 0 0
1 20 0 0
...
Matlab 60 0 60
Matlab 70 0 70
......
Matlab_min_head 50 50 0
Matlab_min_head 60 60 0
......
因此,如果我使用以下方法进行过滤:
Plot1<-ggplot(subset(dataset, Matlab_head>0)
或
Plot1<-ggplot(subset(dataset, Matlab_head !=0)
我实质上从数据集中删除了其他Matlab_min_head
列和其他Project
数据,因为它是0。
是否可以选择仅让子集删除Matlab_head
列中的值(而不是整个数据集)?
答案 0 :(得分:0)
您可以在第一次subset(dataset, Head_recalculated != 0)
调用中使用ggplot
删除零:
Plot1 <- ggplot(subset(dataset,Head_recalculated != 0), aes(x=Capacity_recalculated, y=Head_recalculated))