2017-06-28 37 views
1

enter image description here- [R情节标签表示换算值

我R代码里面绘制上述图表

p <- ggplot() + 
    geom_point(data=data2, aes(x=df, y=dn, size=avgdice^3, fill = log2(tsSTDCommoncrawl)), shape=21) 

p <- p + xlab("document fraction between commoncrawl and directcrawl") + 
    ylab("document number in commoncrawl") + 
    labs(fill="timestamp \nvariance",size ="average \ndice value") 

所以sizefill在代码被缩放。但我希望图表右侧的图例显示avgdicetsSTDCommoncrawl的原始值,而不是avgdice^3log2(tsSTDCommoncrawl)值。

回答

0

这将采取两个步骤。你必须找出ggplot在哪里放置休息,然后手动输入scale。我们来使用虹膜数据集。我想补充与Sepal.Length另一列立方强调在尺寸上的差异:

example=iris 
example$sizes=example$Sepal.Length^3 

现在,我可以绘制它:在100

gplot(example, aes(x=Petal.Length, y=Petal.Width))+ 
+ geom_point(aes(size=sizes))+ 
+ scale_size_continuous(range=c(1,10)) 

enter image description here

传说是把休息, 200,300和400.所以我只需要拿scale电话中的那些立方根,使用breakslabels

> ggplot(example, aes(x=Petal.Length, y=Petal.Width))+ 
+ geom_point(aes(size=sizes))+ 
+ scale_size_continuous(range=c(1,10), breaks=c(100, 200, 300, 400), labels=c(100, 200, 300, 400)^(1/3)) 

enter image description here

您可以用文字的矢量标记过,只要元素的个数等于断线次数。