# How to generate plots in documentation?

**URL:** <https://discourse.julialang.org/t/how-to-generate-plots-in-documentation/77009>\
**Category:** Performance\
**Tags:** question, documentation, plotting, documenter\
**Created:** [February 24, 2022, 8:21am UTC](https://discourse.julialang.org/t/how-to-generate-plots-in-documentation/77009 "2022-02-24T08:21:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Giulio\_Benedetti](https://avatars.discourse-cdn.com/v4/letter/g/f0a364/32.png) [@Giulio\_Benedetti](https://discourse.julialang.org/u/Giulio_Benedetti)\
**Post date:** [February 24, 2022, 8:21am UTC](https://discourse.julialang.org/t/how-to-generate-plots-in-documentation/77009/1 "2022-02-24T08:21:41Z")

</div>

Hi! My question is somewhat related to [this topic](https://discourse.julialang.org/t/generating-plots-in-documenter-jl/11166), 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:

````julia
```@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:

 ![Screenshot 2022-02-24 at 11.09.30](https://global.discourse-cdn.com/julialang/original/3X/d/c/dc67f7dec6d39b5fcbbf4e564be5fa95c0023b0d.png)

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

---

<div class="post-metadata">

**Author:** ![Giulio\_Benedetti](https://avatars.discourse-cdn.com/v4/letter/g/f0a364/32.png) [@Giulio\_Benedetti](https://discourse.julialang.org/u/Giulio_Benedetti)\
**Post date:** [February 25, 2022, 12:42pm UTC](https://discourse.julialang.org/t/how-to-generate-plots-in-documentation/77009/2 "2022-02-25T12:42:38Z")

</div>

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

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

```

from the `make.jl` file.
