GR.jl
GR.jl copied to clipboard
wrong with hold(true) for plot3
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.
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.?
Hi.
I tried that too, but I didn't get any error messages.
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:
Ok, looks related to a long-standing issue (#70, #206), but things get worse with 3d plots, it seems.
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?
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.
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)
They say ax and update are internal keyword not for users, though.
I'm currently out of office. I'll deal with that problem next week.