# GR Plot issue? GR vs PyPlot, PlotlyJS

**URL:** <https://discourse.julialang.org/t/gr-plot-issue-gr-vs-pyplot-plotlyjs/6593>\
**Category:** New to Julia\
**Created:** [October 21, 2017, 1:20pm UTC](https://discourse.julialang.org/t/gr-plot-issue-gr-vs-pyplot-plotlyjs/6593 "2017-10-21T13:20:08Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![rveltz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rveltz/32/2707_2.png) [@rveltz](https://discourse.julialang.org/u/rveltz)\
**Post date:** [October 21, 2017, 1:20pm UTC](https://discourse.julialang.org/t/gr-plot-issue-gr-vs-pyplot-plotlyjs/6593/1 "2017-10-21T13:20:08Z")

</div>

Hi,

I am plotting the same thing with two different backends and yet I don’t get similar plots. For example, the convexity of some levels are inverted.

Hence, I am wondering which one is the good result…  
Note that this is the solution of a PDE.

```julia
gr()
contour(time[1:10:end],e[2:end],(gg)[1:10:end,:]',title=string("g(t,v) network for N =10000"),color=:magma,fill=true)

```

 ![37](https://global.discourse-cdn.com/julialang/original/3X/7/9/7975efba8cc61b1b95b7118eae6974224aad9e21.jpeg)

or

```julia
pyplot()
contour(time[1:10:end],e[2:end],(gg)[1:10:end,:]',title=string("g(t,v) network for N =10000"),color=:magma,fill=true)

```

 ![26](https://global.discourse-cdn.com/julialang/original/3X/5/b/5bdfffed741ae6c2808822d309b9587789e538fd.jpeg)

Thank you for your help,

Best regards

---

<div class="post-metadata">

**Author:** ![rveltz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rveltz/32/2707_2.png) [@rveltz](https://discourse.julialang.org/u/rveltz)\
**Post date:** [November 3, 2017, 10:21am UTC](https://discourse.julialang.org/t/gr-plot-issue-gr-vs-pyplot-plotlyjs/6593/2 "2017-11-03T10:21:19Z")

</div>

I have a minimal working example for this. I put the data [here](https://www.dropbox.com/s/d66yt02ey110np4/example-issue-plot.jld?dl=0).

Does anyone know what is happening?

```julia
using Plots,JLD
gg, e, tt = JLD.load("example-issue-plot.jld", "gg", "e", "tt")
sub = 100

time = tt[1:sub:end]
v = e[2:end] |> collect
z = gg[1:sub:end,:]

gr()
    pyplot()
    heatmap(time,v,z' ,title=string("g(t,v) network for N =10000"))

```

---

<div class="post-metadata">

**Author:** ![rveltz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rveltz/32/2707_2.png) [@rveltz](https://discourse.julialang.org/u/rveltz)\
**Post date:** [November 3, 2017, 11:30am UTC](https://discourse.julialang.org/t/gr-plot-issue-gr-vs-pyplot-plotlyjs/6593/3 "2017-11-03T11:30:45Z")

</div>

I also have the plot from plotlyjs.

@jheinen So it seems GR is the culprit

![network-error](https://global.discourse-cdn.com/julialang/original/3X/f/8/f8c40b63222f7212ccdc1d20792616eff73ef7df.png)

---

<div class="post-metadata">

**Author:** ![John\_Gibson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/john_gibson/32/5321_2.png) [@John\_Gibson](https://discourse.julialang.org/u/John_Gibson)\
**Post date:** [November 3, 2017, 11:50am UTC](https://discourse.julialang.org/t/gr-plot-issue-gr-vs-pyplot-plotlyjs/6593/4 "2017-11-03T11:50:47Z")

</div>

Can you plot something similar but easily replicable with known appearance? Like u(x,y) = (1-y^2) \sin(x + ky) for some small k over x,y \in [0, n\pi] \times [-1, 1]?

---

<div class="post-metadata">

**Author:** ![rveltz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rveltz/32/2707_2.png) [@rveltz](https://discourse.julialang.org/u/rveltz)\
**Post date:** [November 3, 2017, 12:03pm UTC](https://discourse.julialang.org/t/gr-plot-issue-gr-vs-pyplot-plotlyjs/6593/5 "2017-11-03T12:03:13Z")

</div>

```julia
t = linspace(0,5,1000)
X = cumsum(exp(-10sin(2t).^2))
Y = linspace(0,4pi,150)
u = [(1-y^2)*sin(x+y) for x in X, y in Y]

gr()
pyplot()
heatmap(X,Y,u')

```

---

<div class="post-metadata">

**Author:** ![jheinen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jheinen/32/2787_2.png) [@jheinen](https://discourse.julialang.org/u/jheinen)\
**Post date:** [November 3, 2017, 1:12pm UTC](https://discourse.julialang.org/t/gr-plot-issue-gr-vs-pyplot-plotlyjs/6593/6 "2017-11-03T13:12:22Z")

</div>

The problem is, that `time` is non-equidistant. I have to check this in GR and probably re-sample the grid.

---

<div class="post-metadata">

**Author:** ![rveltz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rveltz/32/2707_2.png) [@rveltz](https://discourse.julialang.org/u/rveltz)\
**Post date:** [November 3, 2017, 1:34pm UTC](https://discourse.julialang.org/t/gr-plot-issue-gr-vs-pyplot-plotlyjs/6593/7 "2017-11-03T13:34:51Z")

</div>

Seriously? That may impede a published paper…

---

<div class="post-metadata">

**Author:** ![jheinen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jheinen/32/2787_2.png) [@jheinen](https://discourse.julialang.org/u/jheinen)\
**Post date:** [November 3, 2017, 3:13pm UTC](https://discourse.julialang.org/t/gr-plot-issue-gr-vs-pyplot-plotlyjs/6593/8 "2017-11-03T15:13:46Z")

</div>

Unfortunately, yes. 😞

The following code produces correct results:

```julia
using Plots, JLD
gg, e, tt = JLD.load("example-issue-plot.jld", "gg", "e", "tt")
sub = 100

time = tt[1:sub:end]
v = e[2:end] |> collect
z = gg[1:sub:end,:]

import GR
x = linspace(time[1], time[end], 800)
y = linspace(v[1], v[end], 800)
z = GR.interp2(time, v, z, x, y)

heatmap(x, y, z', title=string("g(t,v) network for N =10000"))

```

 ![40](https://global.discourse-cdn.com/julialang/original/3X/a/3/a3fd66e9541bdedf2f6678cc5f50aeed315140ab.png)

I will change the `heatmap` and `contour` functions accordingly …

Sorry for the trouble.

---

<div class="post-metadata">

**Author:** ![ssfrr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ssfrr/32/3736_2.png) [@ssfrr](https://discourse.julialang.org/u/ssfrr)\
**Post date:** [November 3, 2017, 3:16pm UTC](https://discourse.julialang.org/t/gr-plot-issue-gr-vs-pyplot-plotlyjs/6593/9 "2017-11-03T15:16:02Z")

</div>

> [@rveltz](#):
>
> Seriously? That may impede a published paper…

Please be mindful that someone is offering to donate their time to investigate and fix a problem that doesn’t affect them, to benefit you. @jheinen is one of the more responsive and generous maintainers in the community.

(I was writing this when @jheinen then further proved my point. 🙂 )

---

<div class="post-metadata">

**Author:** ![rveltz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rveltz/32/2707_2.png) [@rveltz](https://discourse.julialang.org/u/rveltz)\
**Post date:** [November 3, 2017, 3:59pm UTC](https://discourse.julialang.org/t/gr-plot-issue-gr-vs-pyplot-plotlyjs/6593/10 "2017-11-03T15:59:43Z")

</div>

Sorry… I meant “Really?”, I did not choose my word carefully. I love GR, the only reason I don’t use it directly instead of Plots is because I use PlotlyJS sometimes for its interactive capabilities.

Thank you for your help,

Best regards
