# How to generate plots in documentation?

Hi! My question is somewhat related to this topic, but its solution doesn’t work in my case.

I’d like the code chunks within my `docs/src/` directory to automatically generate images inside the docs upon deployment. In fact, the images are produced in `docs/`, but they are not rendered as they should.

For instance, the code:

`````````@repl 1
using FdeSolver
using Plots, SpecialFunctions

# Inputs
tSpan = [0, 1]     # [intial time, final time]
y0 = 0             # initial value
β = 0.9            # order of the derivative

# ODE Model
par = β
F(t, y, par) = (40320 ./ gamma(9 - par) .* t .^ (8 - par) .- 3 .* gamma(5 + par / 2)
./ gamma(5 - par / 2) .* t .^ (4 - par / 2) .+ 9/4 * gamma(par + 1) .+
(3 / 2 .* t .^ (par / 2) .- t .^ 4) .^ 3 .- y .^ (3 / 2))

## Numerical solution
t, Yapp = FDEsolver(F, tSpan, y0, β, par)

# Plot
plot(t, Yapp, linewidth = 5, title = "Solution of a 1D fractional IVP",
xaxis = "Time (t)", yaxis = "y(t)", label = "Approximation")
plot!(t, t -> (t.^8 - 3 * t .^ (4 + β / 2) + 9/4 * t.^β),
lw = 3, ls = :dash, label = "Exact solution")
savefig("example1.png"); nothing # hide
``````

followed by:

`![example1](example1.png)`

returns:

What am I doing wrong? Should I specify the path to the image differently?

As a solution, I had to add `Plots` to the `Project.toml` of the `docs` directory and remove

``````push!(LOAD_PATH, "../src/")
ENV["GKS_WSTYPE"]=100
``````

from the `make.jl` file.

1 Like