# Easiest way to do Contour & 3D Plots of Semi-Discrete solution data?

**URL:** <https://discourse.julialang.org/t/easiest-way-to-do-contour-3d-plots-of-semi-discrete-solution-data/47115>\
**Category:** General Usage\
**Tags:** plotting\
**Created:** [September 23, 2020, 6:33am UTC](https://discourse.julialang.org/t/easiest-way-to-do-contour-3d-plots-of-semi-discrete-solution-data/47115 "2020-09-23T06:33:00Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![CosmoProf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cosmoprof/32/15516_2.png) [@CosmoProf](https://discourse.julialang.org/u/CosmoProf)\
**Post date:** [September 23, 2020, 6:33am UTC](https://discourse.julialang.org/t/easiest-way-to-do-contour-3d-plots-of-semi-discrete-solution-data/47115/1 "2020-09-23T06:33:00Z")

</div>

Hi, I have a method-of-lines solution to a 2nd-order PDE, where the solution “sol” is discrete in x, has columns for discrete data points df/dt and f, and has an ODE-type solution which can be either discrete or continuous in time.  
(For example, `sol.u[17][5,2]` is the function value at the 5th x-position at the 17th timestep, and `sol(17)[5,1]` is (I think) df/dt at t=17 for the 5th x-position.)

So, question: what are some simple commands to plot values in the (t,x) plane? Like contour plots, 3D plots (similar to plot3D in Mathematica, and so on)? Thanks for any info!

---

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [September 26, 2020, 12:37am UTC](https://discourse.julialang.org/t/easiest-way-to-do-contour-3d-plots-of-semi-discrete-solution-data/47115/2 "2020-09-26T00:37:45Z")

</div>

You probably want `contour` plots from the Plots package. There are some examples here: [Filled contour plots in Plots.jl without contour lines and smooth interpolation (GR backend) - #2 by jheinen](https://discourse.julialang.org/t/filled-contour-plots-in-plots-jl-without-contour-lines-and-smooth-interpolation-gr-backend/34796/2)

---

<div class="post-metadata">

**Author:** ![CosmoProf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cosmoprof/32/15516_2.png) [@CosmoProf](https://discourse.julialang.org/u/CosmoProf)\
**Post date:** [October 9, 2020, 8:04pm UTC](https://discourse.julialang.org/t/easiest-way-to-do-contour-3d-plots-of-semi-discrete-solution-data/47115/3 "2020-10-09T20:04:23Z")

</div>

Hi Leandro, thanks for the response!

`contour` does seem to produce better looking plots for my stuff than `heatmap`, `histogram2d`, or `surface`.

But… does anyone know the difference between `contour` and `contourf` ??  
I’ve looked all around and can’t find an explanation of the distinction.

Thanks!

---

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [October 9, 2020, 9:09pm UTC](https://discourse.julialang.org/t/easiest-way-to-do-contour-3d-plots-of-semi-discrete-solution-data/47115/4 "2020-10-09T21:09:18Z")

</div>

> [@CosmoProf](#):
>
> does anyone know the difference between `contour` and `contourf`

In one the level courves are filled, in the other they are not:

with countour:

![contour](https://global.discourse-cdn.com/julialang/original/3X/5/0/504460e468362544633f0bd87eecbd87743ca17d.png)

with coutourf:

![contourf](https://global.discourse-cdn.com/julialang/original/3X/3/d/3d630fa5d476e0c78f1c99a1294310f1cf311591.png)

---

<div class="post-metadata">

**Author:** ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)\
**Post date:** [October 9, 2020, 9:28pm UTC](https://discourse.julialang.org/t/easiest-way-to-do-contour-3d-plots-of-semi-discrete-solution-data/47115/5 "2020-10-09T21:28:25Z")

</div>

You can (should) use `ratio=1` to get equal aspect ratio. And/or set `size=(400, 400)`

---

<div class="post-metadata">

**Author:** ![CosmoProf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cosmoprof/32/15516_2.png) [@CosmoProf](https://discourse.julialang.org/u/CosmoProf)\
**Post date:** [October 9, 2020, 11:11pm UTC](https://discourse.julialang.org/t/easiest-way-to-do-contour-3d-plots-of-semi-discrete-solution-data/47115/6 "2020-10-09T23:11:59Z")

</div>

Hmm, weird, my plots didn’t show any difference at all between `contour` and `contourf`.  
Here’s my command:

`contour(xArr, sol2ndOrd.t, FofTvsX, fill=true, linewidth=0.5, color=cgrad([:red,:white,:blue]), nlevels=15)`

The suggestions of using `ratio` and `size` are good ones; I suppose I could specify other y/x ratios that way too.

---

<div class="post-metadata">

**Author:** ![CosmoProf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cosmoprof/32/15516_2.png) [@CosmoProf](https://discourse.julialang.org/u/CosmoProf)\
**Post date:** [October 9, 2020, 11:45pm UTC](https://discourse.julialang.org/t/easiest-way-to-do-contour-3d-plots-of-semi-discrete-solution-data/47115/7 "2020-10-09T23:45:23Z")

</div>

Aha, apparently `contour` with `fill=true` produces the same plot as `contourf`.
