-
-
Notifications
You must be signed in to change notification settings - Fork 372
Description
Details
The following code:
plot(
[
Shape([1,1], [1,2]),
Shape([2,2], [1,2]),
Shape([3,3], [1,2]),
Shape([4,4], [1,2])
],
seriestype=:shape,
linecolor=[:red, :green, :red, :green]
)issues a warning:
┌ Warning: Column vector attribute `linecolor` reinterpreted as row vector (one value per shape).
│ Pass a row vector instead (e.g. using `permutedims`) to suppress this warning.
└ @ Plots /home/yevgeniy/.julia/packages/Plots/z5Msu/src/recipes.jl:1381This did not occur in 1.10.6, and also in 1.10.6 using a row vector for linecolor did not result in the correct behavior. Although in 1.11.0, I can change the code to the following:
plot(
[
Shape([1,1], [1,2]),
Shape([2,2], [1,2]),
Shape([3,3], [1,2]),
Shape([4,4], [1,2])
],
seriestype=:shape,
linecolor=permutedims([:red, :green, :red, :green])
)and this gets rid of the warning, however, in my longer projects, both my old code that uses the column vector as well as using permutedims results in an unacceptable performance regression compared to 1.10.6. (Also, I find it really strange that the linecolor array needs to be a row vector, but the main vector of shapes remains a column vector.)
Benchmarking the above code:
function f1()
plot(
[
Shape([1,1], [1,2]),
Shape([2,2], [1,2]),
Shape([3,3], [1,2]),
Shape([4,4], [1,2])
],
seriestype=:shape,
linecolor=[:red, :green, :red, :green]
)
end
function f2()
plot(
[
Shape([1,1], [1,2]),
Shape([2,2], [1,2]),
Shape([3,3], [1,2]),
Shape([4,4], [1,2])
],
seriestype=:shape,
linecolor=permutedims([:red, :green, :red, :green])
)
end# version 1.11.0
@benchmark f1()
BenchmarkTools.Trial:
memory estimate: 472.20 KiB
allocs estimate: 6975
--------------
minimum time: 3.187 ms (0.00% GC)
median time: 4.031 ms (0.00% GC)
mean time: 4.415 ms (1.34% GC)
maximum time: 15.710 ms (67.08% GC)
--------------
samples: 1133
evals/sample: 1
@benchmark f2()
BenchmarkTools.Trial:
memory estimate: 469.59 KiB
allocs estimate: 6932
--------------
minimum time: 3.032 ms (0.00% GC)
median time: 3.132 ms (0.00% GC)
mean time: 3.252 ms (1.44% GC)
maximum time: 8.681 ms (54.14% GC)
--------------
samples: 1537
evals/sample: 1# version 1.10.6
@benchmark f1()
BenchmarkTools.Trial:
memory estimate: 182.59 KiB
allocs estimate: 2645
--------------
minimum time: 946.502 μs (0.00% GC)
median time: 1.080 ms (0.00% GC)
mean time: 1.067 ms (1.85% GC)
maximum time: 6.898 ms (73.72% GC)
--------------
samples: 4679
evals/sample: 1Backends
This bug occurs on ( insert x below )
| Backend | yes | no | untested |
|---|---|---|---|
| gr (default) | x | ||
| pyplot | x | ||
| plotly | x | ||
| plotlyjs | x | ||
| pgfplotsx | x | ||
| inspectdr | x |
Versions
Plots.jl version: 1.11.0
Backend version (]st -m): GR v0.55.0
Output of versioninfo():
Julia Version 1.6.0
Commit f9720dc2eb (2021-03-24 12:55 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: Intel(R) Core(TM) i5-4460S CPU @ 2.90GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-11.0.1 (ORCJIT, haswell)