Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R qplot没有在我的情节上显示任何东西_R_Ggplot2 - Fatal编程技术网

R qplot没有在我的情节上显示任何东西

R qplot没有在我的情节上显示任何东西,r,ggplot2,R,Ggplot2,您好,我一直在尝试使用qplot绘制此data.frame print(Data) partition axis1 axis2 V1 Alpha 0.064989 -0.093558 V2 Beta -0.065058 0.009540 V3 Delta 0.100572 -0.081021 V4 Zed -0.152011 0.057507 V5 Alpha -0.039480 -0.020070 V6

您好,我一直在尝试使用qplot绘制此data.frame

print(Data)
    partition     axis1     axis2
V1      Alpha  0.064989 -0.093558
V2       Beta -0.065058  0.009540
V3      Delta  0.100572 -0.081021
V4        Zed -0.152011  0.057507
V5      Alpha -0.039480 -0.020070
V6       Beta  0.044027 -0.055642
V7     Catsup -0.149427  0.038032
V8        Zed  0.133783 -0.021328
V9        Zed -0.014662 -0.029677
V10     Alpha -0.094468  0.002095
V11      Beta  0.090668 -0.033317
我正在尝试使用此代码按轴绘制,按组绘制颜色

qplot(x="axis1", y= "axis2", data = taxi, color= "partition)

但是什么也没有出现。我做错了什么?

您不想在ggplot或qplot中引用列名。有一种类似于隐式
with
attach
的方法,允许您引用列,就像它们已经被定义为命名空间中的变量一样

qplot(data=taxi, x=axis1, y=axis2, color=partition)

您不希望在ggplot或qplot中引用列名。有一种类似于隐式
with
attach
的方法,允许您引用列,就像它们已经被定义为命名空间中的变量一样

qplot(data=taxi, x=axis1, y=axis2, color=partition)

Justin解决方案就是这样:不需要在ggplot2中引用aes。但是使用
aes\u string
,您可以获得与引用变量相同的结果:

ggplot(data = taxi) +
 geom_point(aes_string(x="axis1", y= "axis2", color= "partition"))

例如,如果将ggplot调用封装在函数中,这可能很有用…

Justin解决方案就是这样:不需要在ggplot2中引用aes。但是使用
aes\u string
,您可以获得与引用变量相同的结果:

ggplot(data = taxi) +
 geom_point(aes_string(x="axis1", y= "axis2", color= "partition"))

例如,如果您将ggplot调用封装在函数中,这可能会很有用。例如…

谢谢,这看起来可以工作,但qplot仍然没有显示任何内容。它甚至不能取代先前的绘图。我不得不说非常感谢。除非你没有告诉我们整个故事!如果在函数中有一个ggplot调用,那么肯定需要对其调用
print
。就是这样。上一个ggplot来自我忘记删除的前一部分。再次感谢。谢谢。看起来它会起作用,但qplot仍然没有显示任何内容。它甚至不能取代先前的绘图。我不得不说非常感谢。除非你没有告诉我们整个故事!如果在函数中有一个ggplot调用,那么肯定需要对其调用
print
。就是这样。上一个ggplot来自我忘记删除的前一部分。再次感谢。