我正在尝试使用两类数据制作一个数字,如下所示: A comparison between two groups (indicated by pink and black) concerning various different species
这个图的作者似乎把两张箱线图放在一张图中。我用R构建了类似的boxplot,代码如下:
{library(reshape2)
species_melt <- melt(species, "Species")
library(ggplot2)
p<-ggplot(species_melt, aes(Species, value),color="Red") + geom_boxplot()
windowsFonts(myFont1=windowsFont("Arial"),myFont2=windowsFont("Times New Roman"))
p+scale_y_log10()}
生成如下(部分)的箱线图: enter image description here
因此我想知道如何在其上添加另一层箱图,但R似乎很难。
答案 0 :(得分:1)
如果没有您的数据,很难测试,但这样的事情应该有效:
Range.Address(True, True, xlR1C1, xlExternal)
我使用了两个Dim Rng1 As Range ' new Range Object
Window2 = Application.GetOpenFilename(FileFilter:="Excel Files (*.xls*),*.xls*", _
Title:="Choose the Newest Kronos Full File", MultiSelect:=False)
Set wb2 = Workbooks.Open(Filename:=Window2, ReadOnly:=True)
'shtName = wb2.Worksheets(1).Name '<-- not necessary
Set Rng1 = wb2.Worksheets(1).Range("B2:E99999")
wb2.Close
With ws
.Range("M2").Formula = "=VLOOKUP($K2," & Rng1.Address(True, True, xlR1C1, xlExternal) & ",4,0)"
' define more ranges for the other formulas
End With
个不同的数据集(library(ggplot2)
ggplot() +
geom_boxplot(data = species_melt_1,
aes(Species, value),
fill = "#ff84b3", color = "#994f6b") +
geom_boxplot(data = species_melt_2,
aes(Species, value),
alpha = 0, color = "black")
和geom_boxplot
)。第一个是红色,第二个是透明的。