I’m trying to plot a bunch of infinite straight lines, where each line is defined by a pair of points.
julia> lines = hcat([[(0, 0), (cos(θ), sin(θ))] for θ=range(0, π, 10)]...)
2×10 Matrix{Tuple{Real, Real}}:
(0, 0) (0, 0) (0, 0) … (0, 0)
(1.0, 0.0) (0.939693, 0.34202) (0.766044, 0.642788) (-1.0, 1.22465e-16)
(Each column of lines
defines a line.)
This can be done with
using Plots
plot(vec(lines), seriestype = :straightline)
except that I get this complaint:
AssertionError: Misformed data. straightline_data
either accepts vectors of length 2 or 3k. The provided series has length 20
I’m not sure why it accepts a pair of points or a multiple of three points.
I can get around this by adding placeholder points:
julia> lines_with_dummy_points = [lines; fill((NaN, NaN), 1, size(lines, 2))]
3×10 Matrix{Tuple{Real, Real}}:
(0, 0) (0, 0) (0, 0) … (0, 0)
(1.0, 0.0) (0.939693, 0.34202) (0.766044, 0.642788) (-1.0, 1.22465e-16)
(NaN, NaN) (NaN, NaN) (NaN, NaN) (NaN, NaN)
and then this plots as expected:
plot(vec(lines_with_dummy_points), seriestype = :straightline)
My question is: why?
It’s ugly having to inject my data with dummy points in every third position. These points don’t appear to influence the plot (except for affecting the axis limits), so why does :straightlines
expect data in the shape 3n?