How to achieve the expected graph?

I try to reproduce the example of the following link: Example: The Polynomials.jl logo,
but I don’t get the image shown in the link:
chebs

I only get the following image
chebs _1

#https://juliamath.github.io/Polynomials.jl/stable/reference/#Polynomials.fit
using Plots, Polynomials
# T1, T2, T3, and T4:
chebs = [
  ChebyshevT([0, 1]),
  ChebyshevT([0, 0, 1]),
  ChebyshevT([0, 0, 0, 1]),
  ChebyshevT([0, 0, 0, 0, 1]),
]
colors = ["#4063D8", "#389826", "#CB3C33", "#9558B2"]
itr = zip(chebs, colors)
(cheb,col), state = iterate(itr)
p = plot(cheb, c=col,  lw=5, legend=false, label="")
for (cheb, col) in Base.Iterators.rest(itr, state)
  plot!(cheb, c=col, lw=5)
end

How to achieve the expected graph?

You’re just not displaying the final plot (the loop returns nothing), so you need to add either p, display(p), or current() at the end to show the plot.

1 Like