使用geom_scatterpie R缩放x和y

问题描述 投票:2回答:1

我的ggplot中的一些馅饼非常小,无法看到里面的“porteur”的重新分配。我的第二个问题是第一个馅饼彼此非常接近所以我们不知道它们有多少,我想让这个情节清楚。但是当我使用log10 scale时,我得到错误:“seq.default中的错误(min,max,by = by):'from'必须是有限数”。

这是我的情节:

enter image description here

这是我的数据:

       industry            comt        cattt    volll   Filiale MCI   Visa  National UPI Amex
 1     Appl, Furni, Mate   23606.424   1181598   6219    1708   359   1516     2636   9    1
 2     Business expenses    4726.499    183885   3592    1163   131    686     1612   9  654
 3              Clothing   47893.360   1918793  15939    3187  1218   4993     6532  86   86
 4  Education and health   62877.728   2754194  37736   10743  2132   8301    16551  19 5428
 5                Luxury  358699.815  20129817 192014   63765 16257  44096    67810   8    0
 6                others  103460.838   6927711  65699   10968  4924  26728    23060   7    0
 7     Personal services   78880.119   3112051  28755    6207  2718   7656    12165 124    0
 8           Restaurants  218580.788   8892880  88280   15171 10357  34500    27591   2    0
 9                Retail  702095.418  40652702 524690  157434 39082 125088   202876   5    0
 10          Technology    65161.087   3573220  28920    8154  1784   5656    13324  39    0
 11       Transportation   61907.204  20052011  38831    9570  6363   7063    15830   0    0
 12               Travel 2338812.925 103582243 293428   12839 68019 173803    33300   0    0

这是我的代码:

p <- ggplot(dt, aes(cattt, comt))
kk = p + geom_scatterpie(aes(x=cattt/23, y=comt, r= volll),
                data = dt, cols = c("Filiale", "MCI", "Visa","National", 'UPI','Amex'),color=NA, alpha=.6)+
guides(fill=guide_legend(title="Type \n Porteur"))+
geom_scatterpie_legend(dt$volll, x=500000, y=2500000)
r ggplot2 scatter-plot scaletransform
1个回答
0
投票

一种方法是通过乘以或除以因子来缩放值,例如3.您可以在绘图中添加“coord_fixed”参数以拉伸x轴。我不确定这是否会影响饼图。

p + geom_scatterpie(aes(x=cattt/23, y=comt,r= volll*3) + 
coord_fixed(ratio = 3/1) +  data = dt, cols = c("Filiale", "MCI", "Visa","National", 'UPI','Amex'),color=NA, alpha=.6) +
guides(fill=guide_legend(title="Type \n Porteur"))+
geom_scatterpie_legend(dt$volll, x=500000, y=2500000)

要么

p + geom_scatterpie(aes(x=cattt/23, y=comt, r = volll/3) + 
coord_fixed(ratio = 3/1) +  data = dt, cols = c("Filiale", "MCI", "Visa","National", 'UPI','Amex'),color=NA, alpha=.6) +
guides(fill=guide_legend(title="Type \n Porteur"))+
geom_scatterpie_legend(dt$volll, x=500000, y=2500000)
© www.soinside.com 2019 - 2024. All rights reserved.