Fix handling of discrete values with ticks = :native for Plotly.
This commit is contained in:
parent
94863d69b1
commit
5017024557
@ -258,7 +258,7 @@ function plotly_axis(axis::Axis, sp::Subplot)
|
|||||||
|
|
||||||
ax[:tickangle] = -axis[:rotation]
|
ax[:tickangle] = -axis[:rotation]
|
||||||
lims = axis_limits(axis)
|
lims = axis_limits(axis)
|
||||||
ax[:range] = map(scalefunc(axis[:scale]), lims)
|
axis[:ticks] != :native ? ax[:range] = map(scalefunc(axis[:scale]), lims) : nothing
|
||||||
|
|
||||||
if !(axis[:ticks] in (nothing, :none, false))
|
if !(axis[:ticks] in (nothing, :none, false))
|
||||||
ax[:titlefont] = plotly_font(guidefont(axis))
|
ax[:titlefont] = plotly_font(guidefont(axis))
|
||||||
@ -465,7 +465,7 @@ function plotly_close_shapes(x, y)
|
|||||||
nanvcat(xs), nanvcat(ys)
|
nanvcat(xs), nanvcat(ys)
|
||||||
end
|
end
|
||||||
|
|
||||||
plotly_data(v) = collect(v)
|
plotly_data(v) = v != nothing ? collect(v) : v
|
||||||
plotly_data(surf::Surface) = surf.surf
|
plotly_data(surf::Surface) = surf.surf
|
||||||
plotly_data(v::AbstractArray{R}) where {R<:Rational} = float(v)
|
plotly_data(v::AbstractArray{R}) where {R<:Rational} = float(v)
|
||||||
|
|
||||||
@ -493,7 +493,16 @@ function plotly_series(plt::Plot, series::Series)
|
|||||||
d_out[:yaxis] = "y$spidx"
|
d_out[:yaxis] = "y$spidx"
|
||||||
d_out[:showlegend] = should_add_to_legend(series)
|
d_out[:showlegend] = should_add_to_legend(series)
|
||||||
|
|
||||||
x, y = plotly_data(series[:x]), plotly_data(series[:y])
|
|
||||||
|
x, y, z = map(letter -> (axis = sp[Symbol(letter, :axis)];
|
||||||
|
if axis[:ticks] == :native && !isempty(axis[:discrete_values])
|
||||||
|
axis[:discrete_values]
|
||||||
|
elseif st in (:heatmap, :contour, :surface, :wireframe)
|
||||||
|
plotly_surface_data(series, series[letter])
|
||||||
|
else
|
||||||
|
plotly_data(series[letter])
|
||||||
|
end), (:x, :y, :z))
|
||||||
|
|
||||||
d_out[:name] = series[:label]
|
d_out[:name] = series[:label]
|
||||||
|
|
||||||
isscatter = st in (:scatter, :scatter3d, :scattergl)
|
isscatter = st in (:scatter, :scatter3d, :scattergl)
|
||||||
@ -502,13 +511,6 @@ function plotly_series(plt::Plot, series::Series)
|
|||||||
hasfillrange = st in (:path, :scatter, :scattergl) &&
|
hasfillrange = st in (:path, :scatter, :scattergl) &&
|
||||||
(isa(series[:fillrange], AbstractVector) || isa(series[:fillrange], Tuple))
|
(isa(series[:fillrange], AbstractVector) || isa(series[:fillrange], Tuple))
|
||||||
|
|
||||||
# for surface types, set the data
|
|
||||||
if st in (:heatmap, :contour, :surface, :wireframe)
|
|
||||||
for letter in [:x,:y,:z]
|
|
||||||
d_out[letter] = plotly_surface_data(series, series[letter])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
d_out[:colorbar] = KW(:title => sp[:colorbar_title])
|
d_out[:colorbar] = KW(:title => sp[:colorbar_title])
|
||||||
|
|
||||||
clims = sp[:clims]
|
clims = sp[:clims]
|
||||||
@ -548,13 +550,13 @@ function plotly_series(plt::Plot, series::Series)
|
|||||||
|
|
||||||
elseif st == :heatmap
|
elseif st == :heatmap
|
||||||
d_out[:type] = "heatmap"
|
d_out[:type] = "heatmap"
|
||||||
# d_out[:x], d_out[:y], d_out[:z] = series[:x], series[:y], transpose_z(series, series[:z].surf, false)
|
d_out[:x], d_out[:y], d_out[:z] = x, y, z
|
||||||
d_out[:colorscale] = plotly_colorscale(series[:fillcolor], series[:fillalpha])
|
d_out[:colorscale] = plotly_colorscale(series[:fillcolor], series[:fillalpha])
|
||||||
d_out[:showscale] = hascolorbar(sp)
|
d_out[:showscale] = hascolorbar(sp)
|
||||||
|
|
||||||
elseif st == :contour
|
elseif st == :contour
|
||||||
d_out[:type] = "contour"
|
d_out[:type] = "contour"
|
||||||
# d_out[:x], d_out[:y], d_out[:z] = series[:x], series[:y], transpose_z(series, series[:z].surf, false)
|
d_out[:x], d_out[:y], d_out[:z] = x, y, z
|
||||||
# d_out[:showscale] = series[:colorbar] != :none
|
# d_out[:showscale] = series[:colorbar] != :none
|
||||||
d_out[:ncontours] = series[:levels]
|
d_out[:ncontours] = series[:levels]
|
||||||
d_out[:contours] = KW(:coloring => series[:fillrange] != nothing ? "fill" : "lines")
|
d_out[:contours] = KW(:coloring => series[:fillrange] != nothing ? "fill" : "lines")
|
||||||
@ -563,7 +565,7 @@ function plotly_series(plt::Plot, series::Series)
|
|||||||
|
|
||||||
elseif st in (:surface, :wireframe)
|
elseif st in (:surface, :wireframe)
|
||||||
d_out[:type] = "surface"
|
d_out[:type] = "surface"
|
||||||
# d_out[:x], d_out[:y], d_out[:z] = series[:x], series[:y], transpose_z(series, series[:z].surf, false)
|
d_out[:x], d_out[:y], d_out[:z] = x, y, z
|
||||||
if st == :wireframe
|
if st == :wireframe
|
||||||
d_out[:hidesurface] = true
|
d_out[:hidesurface] = true
|
||||||
wirelines = KW(
|
wirelines = KW(
|
||||||
@ -595,8 +597,7 @@ function plotly_series(plt::Plot, series::Series)
|
|||||||
else
|
else
|
||||||
hasline ? "lines" : "none"
|
hasline ? "lines" : "none"
|
||||||
end
|
end
|
||||||
d_out[:x], d_out[:y] = x, y
|
d_out[:x], d_out[:y], d_out[:z] = x, y, z
|
||||||
d_out[:z] = plotly_data(series[:z])
|
|
||||||
|
|
||||||
else
|
else
|
||||||
warn("Plotly: seriestype $st isn't supported.")
|
warn("Plotly: seriestype $st isn't supported.")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user