library(data.table)
library(ggpolot2)
numPoints <- 10000
dt <- data.table(a=rnorm(numPoints),b=rnorm(numPoints))
qplot(a,b,data=dt, geom="point", alpha=1)
qplot(a,b,data=dt, geom="point", alpha=0.1)
qplot(a,b,data=dt, geom="point", alpha=0.01)
Regardless of the alpha value I choose, the resulting chart seems to have the same amount of transparency.
无论我选择的alpha值如何,结果图表似乎都具有相同的透明度。
How can I get the points to be more transparent (so that the density of the points in an area is more clearly visible)?
如何让点更透明(以便区域中的点密度更清晰可见)?
1 个解决方案
#1
32
Because the ...
is other aesthetics passed for each layer, i.e. you are not setting alpha
you are mapping it to some value which is then the same for all values. You can tell by how you also get a legend entry for alpha
on the plot. There are two solutions:
因为...是为每一层传递的其他美学,即你没有设置alpha,你将它映射到某个值,然后对所有值都是相同的。您可以通过如何在绘图上获得alpha的图例条目来判断。有两种解决方案:
1) Use the I
to indicate this is a set aesthetic;
1)用I来表示这是一套审美;
qplot(a,b,data=dt, geom="point", alpha=I(0.1) )
2) Instead use a ggplot
and set the aesthetic in the geom
...
2)而是使用ggplot并在geom中设置美学...
ggplot( dt , aes( a , b ) )+
geom_point( alpha = 0.1 )
Both calls produce the same result.
两个调用产生相同的结果。
#1
32
Because the ...
is other aesthetics passed for each layer, i.e. you are not setting alpha
you are mapping it to some value which is then the same for all values. You can tell by how you also get a legend entry for alpha
on the plot. There are two solutions:
因为...是为每一层传递的其他美学,即你没有设置alpha,你将它映射到某个值,然后对所有值都是相同的。您可以通过如何在绘图上获得alpha的图例条目来判断。有两种解决方案:
1) Use the I
to indicate this is a set aesthetic;
1)用I来表示这是一套审美;
qplot(a,b,data=dt, geom="point", alpha=I(0.1) )
2) Instead use a ggplot
and set the aesthetic in the geom
...
2)而是使用ggplot并在geom中设置美学...
ggplot( dt , aes( a , b ) )+
geom_point( alpha = 0.1 )
Both calls produce the same result.
两个调用产生相同的结果。