在RStudio中的对数对数图中使用geom_abline吗?

我的目标是在对数-对数图上绘制几条对角线参考线。这些线将代表C,其中C = X xY。基本上,在图上,其中x轴表示总量,y轴表示材料浓度为材料量提供参考。随附的示例说明了我的意思-我是在Matlab中绘制此图的。我试图在RStudio中重现类似的图。但是,当我使用scale_x_log10和scale_y_log10应用日志比例时,geom_abline似乎不起作用。当我不应用对数缩放时,可以得到要绘制的线。为什么geom_abline似乎不适用于对数比例,并且使用ggplot2库在对数对数比例上绘制这些对角线的最佳方法是什么?提前致谢。 参考代码:

library(tidyverse)
breaks <- 10^(-10:10)
minor_breaks <- rep(1:9,21)*(10^rep(-10:10,each=9))

ggplot(Re1,aes(x = Tonnage,y = Percent.grade,group = Type)) + 
  geom_point(aes(shape=Type,color=Type)) +
  theme(panel.grid.major = element_blank(),panel.grid.minor = element_blank()) +
  geom_text_repel(aes(label=Name),size = 3) +

  geom_abline(intercept=0.000011,slope=-1*10^-14) +
  geom_abline(intercept=3*0.000011,slope=-1*10^-14) +

  scale_x_log10(breaks = breaks,minor_breaks = minor_breaks) +
  scale_y_log10(breaks = breaks,minor_breaks = minor_breaks) +
  annotation_logticks() +
  coord_equal() +
  theme_bw() + 

  labs(
    x = "Metric Tons",y = "Weight % Re",shape = "Deposit Type",color = "Deposit Type",title = "Rhenium Grade-Tonnage Model"
  ) 

dput(Re1) 
structure(list(Name = structure(c(13L,2L,3L,11L,12L,18L,14L,19L,4L,17L,23L,7L,8L,22L,10L,1L,9L,15L,5L,24L,20L,21L,16L,6L),.Label = c("Bagdad","Bingham","Butte","Castle Dome","Climax","Copper Creek","Ely","Miami-Inspiration","Mineral Park","Mission-Pima","Morenci","Mount Tolman","Pebble","Quartz Hill","Questa","Ray","San Manuel-Kalamazoo","Santa Rita","Sierrita- Esperanza","Silver Bell","Thompson Creek","Tomichi","Twin Buttes","Urad-Henderson"),class = "factor"),Tonnage = c(5.94e+09,3.23e+09,5.22e+09,2.177e+09,3.03e+09,1.6e+09,2.262e+09,1.438e+09,1.39e+09,9.4e+08,7.54e+08,1.591e+10,7.11e+08,9e+08,8.76e+08,4.24e+08,8e+08,4.37e+08,2.68e+08,2.12e+08,1.583e+09,7.5e+07),Grade = c(4.461e-07,2.211e-07,1.121e-07,8.93e-08,1.631e-07,1.069e-07,1.888e-07,1.158e-07,1.599e-07,1.647e-07,2.298e-07,2.653e-07,1.01e-08,2.166e-07,1.5e-07,8.13e-08,5.02e-08,8.96e-08,4.38e-08,7.55e-08,1.157e-07,1.415e-07,1.39e-08,9.33e-08),Percent.grade = c(4.46128e-05,2.21053e-05,1.12069e-05,8.9272e-06,1.63068e-05,1.06931e-05,1.8875e-05,1.15827e-05,1.59944e-05,1.64748e-05,2.29787e-05,2.65252e-05,1.0057e-06,2.16596e-05,1.5e-05,8.125e-06,5.0228e-06,8.9623e-06,4.375e-06,7.5515e-06,1.15672e-05,1.41509e-05,1.3898e-06,9.3333e-06),Contained = c(2650L,714L,585L,466L,355L,324L,302L,262L,230L,229L,216L,200L,160L,154L,135L,130L,44L,38L,35L,33L,31L,30L,7L),Type = structure(c(4L,2L),.Label = c("Climax Mo","Porphyry Cu","Porphyry Cu-Au","Porphyry Cu-Mo","Porphyry Mo"),class = "factor")),class = "data.frame",row.names = c(NA,-24L))

Example of diagonal lines I am trying to recreate in RStudio

Diagonal lines plot when I remove #scale_*_log10

When I use scale_*_log10 the lines do not plot

moumeiyuan 回答:在RStudio中的对数对数图中使用geom_abline吗?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3141639.html

大家都在问