# Way to make radial gradient in 2-d PGFPlot?

**URL:** <https://discourse.julialang.org/t/way-to-make-radial-gradient-in-2-d-pgfplot/13271>\
**Category:** Visualization\
**Tags:** question\
**Created:** [August 11, 2018, 9:45pm UTC](https://discourse.julialang.org/t/way-to-make-radial-gradient-in-2-d-pgfplot/13271 "2018-08-11T21:45:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![djsegal](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/djsegal/32/13752_2.png) [@djsegal](https://discourse.julialang.org/u/djsegal)\
**Post date:** [August 11, 2018, 9:45pm UTC](https://discourse.julialang.org/t/way-to-make-radial-gradient-in-2-d-pgfplot/13271/1 "2018-08-11T21:45:52Z")

</div>

Let’s say you wanted to make a plot like:

 ![](https://global.discourse-cdn.com/julialang/original/3X/f/7/f7711e8c602ab8c5f6c37fb41508c99bc8e97aed.jpeg)

How would you make a radial gradient using Plots.jl with the PGFPlots backend?

---

<div class="post-metadata">

**Author:** ![djsegal](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/djsegal/32/13752_2.png) [@djsegal](https://discourse.julialang.org/u/djsegal)\
**Post date:** [August 11, 2018, 10:31pm UTC](https://discourse.julialang.org/t/way-to-make-radial-gradient-in-2-d-pgfplot/13271/2 "2018-08-11T22:31:09Z")

</div>

Current attempt:

 ![49%20PM](https://global.discourse-cdn.com/julialang/original/3X/a/e/ae4ed328a851bb3260f0dd119797505073d5e8b6.png)

```julia
cur_theta = linspace(0,2*pi)

sphere_x = cos.(cur_theta)
sphere_y = sin.(cur_theta)

plot()

plot!(sphere_x-7.75, sphere_y+5.5, color=1, fill=true, fillopacity=0.95, label="")
plot!(sphere_x-8.75, sphere_y+4.5, color=2, fill=true, fillopacity=0.95, label="")
plot!(sphere_x-7.5, sphere_y+4, color=1, fill=true, fillopacity=0.95, label="")

plot!(ann=[(-4.5,6,"Tritium")])

plot!(sphere_x-6.5, sphere_y-4.25, color=1, fill=true, fillopacity=0.95, label="")
plot!(sphere_x-8, sphere_y-5, color=2, fill=true, fillopacity=0.95, label="")

plot!(aspectratio=:equal)

plot!(ann=[(-9.75,-2.25,"Deuterium")])

plot!([-4.75, -3], [2.75, 1], color=3, label="")
plot!([-4.75, -3], [-2.75, -1], color=3, label="")

plot!([-3, -3.5, -3, -3], [1, 1, 1.5, 1], fill=true, color=3, label="")
plot!([-3, -3.5, -3, -3], [-1, -1, -1.5, -1], fill=true, color=3, label="")

plot!([3, 4.75], [1, 2.75], color=3, label="")
plot!([3, 4.75], [-1, -2.75], color=3, label="")

plot!([4.75, 4.25, 4.75, 4.75], [2.75, 2.75, 2.25, 2.75], fill=true, color=3, label="")
plot!([4.75, 4.25, 4.75, 4.75], [-2.75, -2.75, -2.25, -2.75], fill=true, color=3, label="")

plot!(ann=[(0,0,"+17.6 MeV")])

plot!([-3, +3, +3, -3, -3], [1,1,-1,-1,1], fill=true, color=3, fillopacity=0.2, label="")

plot!(sphere_x+6.75, sphere_y+4, color=1, fill=true, fillopacity=0.95, label="")

plot!(sphere_x+6.75, sphere_y-5, color=1, fill=true, fillopacity=0.95, label="")
plot!(sphere_x+8, sphere_y-6, color=2, fill=true, fillopacity=0.95, label="")
plot!(sphere_x+7.25, sphere_y-3.75, color=2, fill=true, fillopacity=0.95, label="")
plot!(sphere_x+8.5, sphere_y-4.5, color=1, fill=true, fillopacity=0.95, label="")

plot!(ann=[(10,-2.25,"Helium")])

xlims!(-12,12)
ylims!(-8,8)

scatter!([100],[100],color=1,label="Neutron")
scatter!([100],[100],color=2,label="Proton")

plot!(grid=false, ticks=false)
title!("The Nuclear Fusion Reaction")
xlabel!(L"x")
ylabel!(L"y")

```

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [August 13, 2018, 1:46pm UTC](https://discourse.julialang.org/t/way-to-make-radial-gradient-in-2-d-pgfplot/13271/3 "2018-08-13T13:46:53Z")

</div>

Not sure this helps, but if you know how to do it in LaTeX you can probably make it work in

> **[GitHub - KristofferC/PGFPlotsX.jl: Plots in Julia using the PGFPlots LaTeX...](https://github.com/KristofferC/PGFPlotsX.jl)**
>
> Plots in Julia using the PGFPlots LaTeX package. Contribute to KristofferC/PGFPlotsX.jl development by creating an account on GitHub.

In case there is a feature missing (for passing on the relevant LaTeX code), please open an issue.
