m = 2;
g = 9.81;
k = 3.5;
L = 1.5; (**rest length of spring**)

x0 =0.5; (**initial x**)
vx0 = 0.5; (**initial vx**)
θ0=((2π)/3);(**initial θ**)
vθ0 =0.5;(**initial ω**)

tmax = 30; (**end time for animation**)

s = NDSolve[{m x''[t] == m (L + x[t]) (((θ'[t]))^2) + m g Cos[θ[t]] - k x[t], 2(L + x[t]) x'[t] θ'[t] + (((L + x[t]))^2)θ''[t] == -g (L + x[t]) Sin[θ[t]], x[0]== x0, x'[0]==vx0, θ[0]==θ0, θ'[0]==vθ0 },{x,θ},{t,0,tmax}]

spring[r_: {1,0},n_: 10,w_: 0.25]:=Line@Transpose[{r,-Cross[r]}.{(#-1)/(2 n),Re[I^#] w/Norm[r]}]&@Range[2 n+1];
(** This is someone's custom written spring graphics primitive taken from Mathematica StackExchange - a website online **)

X[t_]:=(L + x[t]) Sin[θ[t]]/.s; (** Calculate trajectories in Cartesian Coordinates **)
Y[t_] :=-(L+ x[t]) Cos[θ[t]]/.s;

Plotrange={{-L-3,L+3},{-23,2}};

Animate[GraphicsRow[{Show[Graphics[{Black,Disk[Flatten[{X[t],Y[t]}],0.75], Black,spring[Flatten[{X[t],Y[t]}], 15, 0.25]},PlotRange->Plotrange
],Graphics[ListPlot[Table[Flatten[{X[q],Y[q]}],{q,0,t,0.1}],PlotStyle->Dashed,PlotRange->Plotrange]]], GraphicsColumn[{Plot[x[q]/.s,{q,0,t},PlotStyle->Orange,AxesLabel->{"t (s.)","x (m.)"},PlotLabel->Style["Spring Extension",Small]],Plot[θ[q]/.s,{q,0,t},PlotLabel->Style["Angle Variation",Small],PlotStyle->Blue,AxesLabel->{"t (s.)","θ (rad.)"}]}]}], {t,1,tmax,0.005},AnimationRate->1,RefreshRate->75]

Uncomment the following to export the above animation as a gif in your current working directory:
(**graphics =Table[GraphicsRow[{Show[Graphics[{Black,Disk[Flatten[{X[t],Y[t]}],0.75], Black,spring[Flatten[{X[t],Y[t]}], 15, 0.25]},PlotRange->Plotrange
],Graphics[ListPlot[Table[Flatten[{X[q],Y[q]}],{q,0,t,0.1}],PlotStyle->Dashed,PlotRange->Plotrange]]], GraphicsColumn[{Plot[x[q]/.s,{q,0,t},PlotStyle->Orange,AxesLabel->{"t (s.)","x (m.)"},PlotLabel->Style["Spring Extension",Small]],Plot[θ[q]/.s,{q,0,t},PlotLabel->Style["Angle Variation",Small],PlotStyle->Blue,AxesLabel->{"t (s.)","θ (rad.)"}]}]}],{t,0.01,tmax,0.1}];
SetDirectory[NotebookDirectory[]];
Export["SpringPendulum.gif",graphics]
**)