我正在尝试使用Gadfly绘制不同的数据文件。我尝试使用DataFrame,但没有结果。
我尝试使用下面的代码,但它只绘制了最后一个数据文件。我不知道如何使用Gadfly在一次绘图中绘制所有数据文件。
data1 = CSV.read("DOC.CSV")
data2 = CSV.read("DODC.CSV")
data3 = CSV.read("DOTC.CSV")
data4 = CSV.read("DTC.CSV")
data5 = CSV.read("DTDC.CSV")
data6 = CSV.read("DTTC.CSV")
data = [data1,data2,data3,data4,data5,data6]
ddframe = DataFrame()
for i in 1:6
ddframe[Symbol("Data"*string(i))]=DataFrame(x=data[i][!,1],y=data[i][!,2],label="Data "*string(i))
end
p = plot(ddframe,x="x",y="y",color="label",Geom.point,Geom.line,Guide.xlabel("Wavelength(nm)"),Guide.ylabel("Absorbance(UA)"),Guide.title("Absorbance Spectrum for
Cianine dyes"))发布于 2019-09-07 23:11:12
我假设您的数据是这样的。
│ x │ y │
│───────┼───────┤
│ 1 │ 1 │
│ 2 │ 3 │
│ 3 │ 5 │
│ 4 │ 7 │
│ 5 │ 9 │因此,data是一个数据帧数组。
此外,我假设数据帧可以表示为一条线(波长与吸光度)。
根据您的代码,您可以将每个数据帧组合成一个图,因此您需要的是layer()函数。
plot(
layer(data[1],
x=:x,
y=:y,
Geom.point,
Geom.line,
Theme(default_color="red")),
layer(data[2],
x=:x,
y=:y,
Geom.point,
Geom.line,
Theme(default_color="blue"))
)https://stackoverflow.com/questions/57822085
复制相似问题