将同一图绘制为子图两次

Plotting the same plot twice as subplots

我想使用 Plots.jl 创建一个包含几个子图的情节。这是一个例子:

using Plots
gr()

p = plot(1:10, 1:10)
q = plot(1:10, 10:-1:1) 

plot(p, q)

完全符合预期!但是说我想使用相同的情节 两次 像这样:

plot(p, p)

嗯。只有一个情节。也许我需要先copy剧情:

plot(p, copy(p))

但是会报错:

ERROR: MethodError: no method matching copy(::Plots.Plot{Plots.GRBackend})
Closest candidates are:
copy(::Expr) at expr.jl:36
copy(::Core.CodeInfo) at expr.jl:64
copy(::BitSet) at bitset.jl:46
...
Stacktrace:
1 top-level scope at REPL[216]:1

如何绘制同一个子图两次?

你的想法是对的,但试试 deepcopy() 而不是 copy()。 deepcopy() 通常适用于没有特定 copy() 方法的任意对象。