using PGFPlotsX
using CSV
using FinEtools

objects = []

f = CSV.File("$(@__DIR__)/spherical_cap_expl_22-KE-1.0.res") 
xdata, ydata = f["t"][1:2:end],  f["v"][1:2:end];
@pgf p = PGFPlotsX.Plot(
{
color = "black",
line_width  = 1.0,
},
Coordinates([v for v in  zip(xdata, ydata)])
)
push!(objects, p)
push!(objects, LegendEntry("1.0"))

f = CSV.File("$(@__DIR__)/spherical_cap_expl_22-KE-0.1.res") 
xdata, ydata = f["t"][1:71:end],  f["v"][1:71:end];
@pgf p = PGFPlotsX.Plot(
{
only_marks,
        color = "black",
        line_width  = 1.0,
        mark = "square",
},
Coordinates([v for v in  zip(xdata, ydata)])
)
push!(objects, p)
push!(objects, LegendEntry("0.1"))

f = CSV.File("$(@__DIR__)/spherical_cap_expl_22-KE-10.0.res") 
xdata, ydata = f["t"][17:71:end],  f["v"][17:71:end];
@pgf p = PGFPlotsX.Plot(
{
only_marks,
        color = "black",
        line_width  = 1.0,
        mark = "diamond",
},
Coordinates([v for v in  zip(xdata, ydata)])
)
push!(objects, p)
push!(objects, LegendEntry("10.0"))

@pgf ax = Axis(
{
xlabel = "Time [ms]",
ylabel = "Kinetic energy [lbf*in]",
# ymin = -1.1e-5,
# ymax = 1.1e-5,
xmin = 0.0,
xmax = 1.0,
xmode = "linear", 
ymode = "linear",
yminorgrids = "true",
grid = "both",
legend_style = {
at = Coordinate(0.5, 1.05),
anchor = "south",
legend_columns = -1
},
},
objects...
)

display(ax)
pgfsave("spherical_cap_expl_22-KE.pdf", ax)

