infinite shapes
This commit is contained in:
parent
c8cdade884
commit
9a5f42c251
@ -289,6 +289,8 @@ function extract_points(d)
|
||||
dim = is3d(d) ? 3 : 2
|
||||
array = if d[:seriestype] == :straightline
|
||||
straightline_data(d)
|
||||
elseif d[:seriestype] == :shape
|
||||
shape_data(series)
|
||||
else
|
||||
(d[:x], d[:y], d[:z])[1:dim]
|
||||
end
|
||||
|
||||
@ -1186,6 +1186,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
||||
GR.selntran(1)
|
||||
|
||||
elseif st == :shape
|
||||
x, y = shape_data(series)
|
||||
for (i,rng) in enumerate(iter_segments(x, y))
|
||||
if length(rng) > 1
|
||||
# connect to the beginning
|
||||
|
||||
@ -272,6 +272,7 @@ For st in :shape:
|
||||
=#
|
||||
|
||||
if st in (:shape,)
|
||||
x, y = shape_data(series)
|
||||
nmax = 0
|
||||
for (i,rng) in enumerate(iter_segments(x, y))
|
||||
nmax = i
|
||||
|
||||
@ -222,6 +222,8 @@ function pgf_series(sp::Subplot, series::Series)
|
||||
d[:x], d[:y], d[:z]
|
||||
elseif st == :straightline
|
||||
straightline_data(series)
|
||||
elseif st == :shape
|
||||
shape_data(series)
|
||||
elseif d[:marker_z] != nothing
|
||||
# If a marker_z is used pass it as third coordinate to a 2D plot.
|
||||
# See "Scatter Plots" in PGFPlots documentation
|
||||
|
||||
@ -704,7 +704,7 @@ function plotly_series_shapes(plt::Plot, series::Series)
|
||||
base_d[:name] = series[:label]
|
||||
# base_d[:legendgroup] = series[:label]
|
||||
|
||||
x, y = plotly_data(series[:x]), plotly_data(series[:y])
|
||||
x, y = shape_data(series)
|
||||
for (i,rng) in enumerate(iter_segments(x,y))
|
||||
length(rng) < 2 && continue
|
||||
|
||||
|
||||
@ -454,6 +454,8 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
|
||||
x, y, z = series[:x], series[:y], series[:z]
|
||||
if st == :straightline
|
||||
x, y = straightline_data(series)
|
||||
elseif st == :shape
|
||||
x, y = shape_data(series)
|
||||
end
|
||||
xyargs = (st in _3dTypes ? (x,y,z) : (x,y))
|
||||
|
||||
|
||||
@ -157,6 +157,8 @@ function addUnicodeSeries!(o, d::KW, addlegend::Bool, xlim, ylim)
|
||||
# get the series data and label
|
||||
x, y = if st == :straightline
|
||||
straightline_data(d)
|
||||
elseif st == :shape
|
||||
shape_data(series)
|
||||
else
|
||||
[collect(float(d[s])) for s in (:x, :y)]
|
||||
end
|
||||
|
||||
22
src/utils.jl
22
src/utils.jl
@ -1121,3 +1121,25 @@ function straightline_data(xl, yl, x, y)
|
||||
return xdata, a .* xdata .+ b
|
||||
end
|
||||
end
|
||||
|
||||
function shape_data(series)
|
||||
sp = series[:subplot]
|
||||
xl, yl = isvertical(series) ? (xlims(sp), ylims(sp)) : (ylims(sp), xlims(sp))
|
||||
x, y = series[:x], series[:y]
|
||||
factor = 100
|
||||
for i in eachindex(x)
|
||||
if x[i] == -Inf
|
||||
x[i] = xl[1] - factor * (xl[2] - xl[1])
|
||||
elseif x[i] == Inf
|
||||
x[i] = xl[2] + factor * (xl[2] - xl[1])
|
||||
end
|
||||
end
|
||||
for i in eachindex(y)
|
||||
if y[i] == -Inf
|
||||
y[i] = yl[1] - factor * (yl[2] - yl[1])
|
||||
elseif y[i] == Inf
|
||||
y[i] = yl[2] + factor * (yl[2] - yl[1])
|
||||
end
|
||||
end
|
||||
return x, y
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user