3131 fig = Figure()
3232 ax = CairoMakie. Axis(fig[1 , 1 ]; xlabel= " x" , ylabel= " y" )
3333
34- l = lines!(ax, x[1 , :], x -> evalpoly(x, (0 , - 2 , 1 )); linewidth= 3 , color= :blue)
34+ l = lines!(
35+ ax,
36+ x[1 , :],
37+ x -> evalpoly(x, (0 , - 2 , 1 ));
38+ linewidth= 3 ,
39+ color= :blue,
40+ label= " Data Points" ,
41+ )
3542 s = scatter!(
3643 ax,
3744 x[1 , :],
4148 color= :orange,
4249 strokecolor= :black,
4350 strokewidth= 2 ,
51+ label= " True Quadratic Function" ,
4452 )
4553
46- axislegend(ax, [l, s], [ " True Quadratic Function " , " Data Points " ] )
54+ axislegend(ax)
4755
4856 fig
4957end
@@ -116,7 +124,13 @@ begin
116124 fig = Figure()
117125 ax = CairoMakie. Axis(fig[1 , 1 ]; xlabel= " x" , ylabel= " y" )
118126
119- l = lines!(ax, x[1 , :], x -> evalpoly(x, (0 , - 2 , 1 )); linewidth= 3 )
127+ l = lines!(
128+ ax,
129+ x[1 , :],
130+ x -> evalpoly(x, (0 , - 2 , 1 ));
131+ linewidth= 3 ,
132+ label= " True Quadratic Function" ,
133+ )
120134 s1 = scatter!(
121135 ax,
122136 x[1 , :],
@@ -126,6 +140,7 @@ begin
126140 color= :orange,
127141 strokecolor= :black,
128142 strokewidth= 2 ,
143+ label= " Actual Data" ,
129144 )
130145 s2 = scatter!(
131146 ax,
@@ -136,9 +151,10 @@ begin
136151 color= :green,
137152 strokecolor= :black,
138153 strokewidth= 2 ,
154+ label= " Predictions" ,
139155 )
140156
141- axislegend(ax, [l, s1, s2], [ " True Quadratic Function " , " Actual Data " , " Predictions " ] )
157+ axislegend(ax)
142158
143159 fig
144160end
0 commit comments