GR.jl icon indicating copy to clipboard operation
GR.jl copied to clipboard

wrong with hold(true) for plot3

Open photor opened this issue 4 years ago • 8 comments

The following simple code:

using GR

x = LinRange(0, 30, 1000)
y = cos.(x) .* x
z = sin.(x) .* x
plot3(x, y, z)
hold(true)
plot3(x, 0.5y, 0.5z)

results in a weird error message "origin outside current window" (actually twice), though in the last line "plot3(x, 0.5y, 0.5z)" shouldn't plot anything outside the current window. Actually, even if you plot3 a single point at any position after hold(true), that error message will be thrown out and the output is just a mess.

photor avatar Jun 22 '20 19:06 photor

I cannot reproduce that error. Can you provide more details about your setup, e.g. versioninfo(), whether you are working in the REPL, IJulia, etc.?

heliosdrm avatar Jun 22 '20 20:06 heliosdrm

Hi. I tried that too, but I didn't get any error messages. image

kojix2 avatar Jun 22 '20 22:06 kojix2

I cannot reproduce that error. Can you provide more details about your setup, e.g. versioninfo(), whether you are working in the REPL, IJulia, etc.?

versioninfo()

Julia Version 1.3.1 Commit 2d5741174c (2019-12-30 21:36 UTC) Platform Info: OS: Windows (x86_64-w64-mingw32) CPU: Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz WORD_SIZE: 64 LIBM: libopenlibm LLVM: libLLVM-6.0.1 (ORCJIT, haswell)

It works well in the REPL, but errors in Jupyter: Jupyter

photor avatar Jun 23 '20 00:06 photor

Ok, looks related to a long-standing issue (#70, #206), but things get worse with 3d plots, it seems.

heliosdrm avatar Jun 23 '20 11:06 heliosdrm

Ok, looks related to a long-standing issue (#70, #206), but things get worse with 3d plots, it seems.

Thanks. Do you have any workaround for my case, like in #206?

photor avatar Jun 23 '20 14:06 photor

Unfortunately, that solution only seems to work for 2d plots. The management of multiple figures and hold (particularly when saving or working in IJulia, Atom, etc.) is in my opinion the most problematic issue of the current high-level interface (the jlgr module). As in #324, you can try using GRUtils.jl instead of the high-level functions given in GR.jl, if this problem is critical for your case.

heliosdrm avatar Jun 23 '20 16:06 heliosdrm

Here is my somewhat dirty workaround...

using GR

x = LinRange(0, 30, 1000)
y = cos.(x) .* x
z = sin.(x) .* x
plot3(x, y, z, ax=false, update=false)

hold(true)

x = LinRange(0, 30, 2000)
y = cos.(x) .* x
z = sin.(x) .* x

#  To check if the axis holds, the second plot is bigger than first one.
plot3(x, y*0.5, z*0.5)

#display(plot3(x, y*0.5, z*0.5))
#hold(false)

image

They say ax and update are internal keyword not for users, though. image

kojix2 avatar Jun 24 '20 01:06 kojix2

I'm currently out of office. I'll deal with that problem next week.

jheinen avatar Jun 24 '20 04:06 jheinen