remove transpose_z
This commit is contained in:
parent
2ef13c19ea
commit
9cf9edffe0
@ -280,8 +280,6 @@ const _series_defaults = KW(
|
||||
:show_empty_bins => false, # should empty bins in 2D histogram be colored as zero (otherwise they are transparent)
|
||||
:contours => false, # add contours to 3d surface and wireframe plots
|
||||
:contour_labels => false,
|
||||
:match_dimensions => false, # do rows match x (true) or y (false) for heatmap/image/spy? see issue 196
|
||||
# this ONLY effects whether or not the z-matrix is transposed for a heatmap display!
|
||||
:subplot => :auto, # which subplot(s) does this series belong to?
|
||||
:series_annotations => nothing, # a list of annotations which apply to the coordinates of this series
|
||||
:primary => true, # when true, this "counts" as a series for color selection, etc. the main use is to allow
|
||||
@ -629,7 +627,6 @@ add_aliases(:quiver, :velocity, :quiver2d, :gradient, :vectorfield)
|
||||
add_aliases(:normalize, :norm, :normed, :normalized)
|
||||
add_aliases(:show_empty_bins, :showemptybins, :showempty, :show_empty)
|
||||
add_aliases(:aspect_ratio, :aspectratio, :axis_ratio, :axisratio, :ratio)
|
||||
add_aliases(:match_dimensions, :transpose, :transpose_z)
|
||||
add_aliases(:subplot, :sp, :subplt, :splt)
|
||||
add_aliases(:projection, :proj)
|
||||
add_aliases(:titlelocation, :title_location, :title_loc, :titleloc, :title_position, :title_pos, :titlepos, :titleposition, :title_align, :title_alignment)
|
||||
|
||||
@ -316,7 +316,6 @@ const _gr_attr = merge_with_base_supported([
|
||||
:layout,
|
||||
:title, :window_title,
|
||||
:guide, :lims, :ticks, :scale, :flip,
|
||||
:match_dimensions,
|
||||
:titlefontfamily, :titlefontsize, :titlefonthalign, :titlefontvalign,
|
||||
:titlefontrotation, :titlefontcolor,
|
||||
:legendfontfamily, :legendfontsize, :legendfonthalign, :legendfontvalign,
|
||||
@ -472,7 +471,6 @@ const _pgfplots_attr = merge_with_base_supported([
|
||||
:polar,
|
||||
# :normalize, :weights, :contours,
|
||||
:aspect_ratio,
|
||||
# :match_dimensions,
|
||||
:tick_direction,
|
||||
:framestyle,
|
||||
:camera,
|
||||
@ -541,7 +539,6 @@ const _pyplot_attr = merge_with_base_supported([
|
||||
:polar,
|
||||
:normalize, :weights,
|
||||
:contours, :aspect_ratio,
|
||||
:match_dimensions,
|
||||
:clims,
|
||||
:inset_subplots,
|
||||
:dpi,
|
||||
@ -627,7 +624,6 @@ const _hdf5_attr = merge_with_base_supported([
|
||||
:polar,
|
||||
:normalize, :weights,
|
||||
:contours, :aspect_ratio,
|
||||
:match_dimensions,
|
||||
:clims,
|
||||
:inset_subplots,
|
||||
:dpi,
|
||||
@ -700,7 +696,6 @@ const _inspectdr_attr = merge_with_base_supported([
|
||||
:polar,
|
||||
# :normalize, :weights,
|
||||
# :contours, :aspect_ratio,
|
||||
:match_dimensions,
|
||||
# :clims,
|
||||
# :inset_subplots,
|
||||
:dpi,
|
||||
@ -761,7 +756,6 @@ const _pgfplotsx_attr = merge_with_base_supported([
|
||||
:ticks,
|
||||
:scale,
|
||||
:flip,
|
||||
:match_dimensions,
|
||||
:titlefontfamily,
|
||||
:titlefontsize,
|
||||
:titlefonthalign,
|
||||
|
||||
@ -1488,14 +1488,12 @@ function gr_add_series(sp, series)
|
||||
|
||||
GR.savestate()
|
||||
|
||||
x, y, z = series[:x], series[:y], series[:z]
|
||||
x, y, z = (handle_surface(series[letter]) for letter in (:x, :y, :z))
|
||||
xscale, yscale = sp[:xaxis][:scale], sp[:yaxis][:scale]
|
||||
frng = series[:fillrange]
|
||||
|
||||
# recompute data
|
||||
if typeof(z) <: Surface
|
||||
z = transpose_z(series, z.surf, false)
|
||||
elseif ispolar(sp)
|
||||
if ispolar(sp)
|
||||
rmin, rmax = axis_limits(sp, :y)
|
||||
if frng !== nothing
|
||||
_, frng = convert_to_polar(x, frng, (rmin, rmax))
|
||||
@ -1752,7 +1750,6 @@ function gr_draw_heatmap(series, x, y, z, clims)
|
||||
end
|
||||
|
||||
function gr_draw_image(series, x, y, z, clims)
|
||||
z = transpose_z(series, series[:z].surf, true)'
|
||||
w, h = size(z)
|
||||
xmin, xmax = ignorenan_extrema(x)
|
||||
ymin, ymax = ignorenan_extrema(y)
|
||||
|
||||
@ -646,7 +646,7 @@ pgfx_series_arguments(series, opt, range) = (arg[range] for arg in pgfx_series_a
|
||||
function pgfx_series_arguments(series, opt)
|
||||
st = series[:seriestype]
|
||||
return if st in (:contour, :contour3d)
|
||||
opt[:x], opt[:y], Array(opt[:z])'
|
||||
opt[:x], opt[:y], handle_surface(opt[:z])
|
||||
elseif st in (:heatmap, :surface, :wireframe)
|
||||
surface_to_vecs(opt[:x], opt[:y], opt[:z])
|
||||
elseif RecipesPipeline.is3d(st)
|
||||
|
||||
@ -459,7 +459,7 @@ function plotly_data(series::Series, letter::Symbol, data)
|
||||
end
|
||||
|
||||
if series[:seriestype] in (:heatmap, :contour, :surface, :wireframe, :mesh3d)
|
||||
plotly_surface_data(series, data)
|
||||
handle_surface(data)
|
||||
else
|
||||
plotly_data(data)
|
||||
end
|
||||
@ -469,10 +469,6 @@ plotly_data(v::AbstractArray) = v
|
||||
plotly_data(surf::Surface) = surf.surf
|
||||
plotly_data(v::AbstractArray{R}) where {R<:Rational} = float(v)
|
||||
|
||||
plotly_surface_data(series::Series, a::AbstractVector) = a
|
||||
plotly_surface_data(series::Series, a::AbstractMatrix) = transpose_z(series, a, false)
|
||||
plotly_surface_data(series::Series, a::Surface) = plotly_surface_data(series, a.surf)
|
||||
|
||||
function plotly_native_data(axis::Axis, data::AbstractArray)
|
||||
if !isempty(axis[:discrete_values])
|
||||
construct_categorical_data(data, axis)
|
||||
@ -588,7 +584,7 @@ function plotly_series(plt::Plot, series::Series)
|
||||
plotattributes_out[:colorscale] = plotly_colorscale(series[:fillcolor], series[:fillalpha])
|
||||
plotattributes_out[:opacity] = series[:fillalpha]
|
||||
if series[:fill_z] !== nothing
|
||||
plotattributes_out[:surfacecolor] = plotly_surface_data(series, series[:fill_z])
|
||||
plotattributes_out[:surfacecolor] = handle_surface(series[:fill_z])
|
||||
end
|
||||
plotattributes_out[:showscale] = hascolorbar(sp)
|
||||
end
|
||||
@ -613,7 +609,7 @@ function plotly_series(plt::Plot, series::Series)
|
||||
plotattributes_out[:color] = rgba_string(plot_color(series[:fillcolor], series[:fillalpha]))
|
||||
plotattributes_out[:opacity] = series[:fillalpha]
|
||||
if series[:fill_z] !== nothing
|
||||
plotattributes_out[:surfacecolor] = plotly_surface_data(series, series[:fill_z])
|
||||
plotattributes_out[:surfacecolor] = handle_surface(series[:fill_z])
|
||||
end
|
||||
plotattributes_out[:showscale] = hascolorbar(sp)
|
||||
else
|
||||
|
||||
@ -344,7 +344,7 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
|
||||
fix_xy_lengths!(plt, series)
|
||||
|
||||
# ax = getAxis(plt, series)
|
||||
x, y, z = series[:x], series[:y], series[:z]
|
||||
x, y, z = (Array(series[letter]) for letter in (:x, :y, :z))
|
||||
if st == :straightline
|
||||
x, y = straightline_data(series)
|
||||
elseif st == :shape
|
||||
@ -512,16 +512,11 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
|
||||
end
|
||||
|
||||
if st in (:contour, :contour3d)
|
||||
z = transpose_z(series, z.surf)
|
||||
if typeof(x)<:Plots.Surface
|
||||
x = Plots.transpose_z(series, x.surf)
|
||||
end
|
||||
if typeof(y)<:Plots.Surface
|
||||
y = Plots.transpose_z(series, y.surf)
|
||||
end
|
||||
|
||||
if st == :contour3d
|
||||
extrakw[:extend3d] = true
|
||||
if !ismatrix(x) || !ismatrix(y)
|
||||
x, y = repeat(x', length(y), 1), repeat(y, 1, length(x))
|
||||
end
|
||||
end
|
||||
|
||||
if typeof(series[:linecolor]) <: AbstractArray
|
||||
@ -556,17 +551,17 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
|
||||
end
|
||||
|
||||
if st in (:surface, :wireframe)
|
||||
if typeof(z) <: AbstractMatrix || typeof(z) <: Surface
|
||||
x, y, z = map(Array, (x,y,z))
|
||||
if z isa AbstractMatrix
|
||||
if !ismatrix(x) || !ismatrix(y)
|
||||
x = repeat(x', length(y), 1)
|
||||
y = repeat(y, 1, length(series[:x]))
|
||||
x, y = repeat(x', length(y), 1), repeat(y, 1, length(x))
|
||||
end
|
||||
z = transpose_z(series, z)
|
||||
if st == :surface
|
||||
if series[:fill_z] !== nothing
|
||||
# the surface colors are different than z-value
|
||||
extrakw[:facecolors] = py_shading(series[:fillcolor], transpose_z(series, series[:fill_z].surf))
|
||||
extrakw[:facecolors] = py_shading(
|
||||
series[:fillcolor],
|
||||
Array(series[:fill_z]),
|
||||
)
|
||||
extrakw[:shade] = false
|
||||
else
|
||||
extrakw[:cmap] = py_fillcolormap(series)
|
||||
@ -618,15 +613,15 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
|
||||
ymin, ymax = ignorenan_extrema(series[:y])
|
||||
dx = (xmax - xmin) / (length(series[:x]) - 1) / 2
|
||||
dy = (ymax - ymin) / (length(series[:y]) - 1) / 2
|
||||
img = Array(transpose_z(series, z.surf))
|
||||
z = if eltype(img) <: Colors.AbstractGray
|
||||
float(img)
|
||||
z = if eltype(z) <: Colors.AbstractGray
|
||||
float(z)
|
||||
elseif eltype(img) <: Colorant
|
||||
map(c -> Float64[red(c),green(c),blue(c),alpha(c)], img)
|
||||
map(c -> Float64[red(c),green(c),blue(c),alpha(c)], z)
|
||||
else
|
||||
z # hopefully it's in a data format that will "just work" with imshow
|
||||
end
|
||||
handle = ax."imshow"(z;
|
||||
handle = ax."imshow"(
|
||||
z;
|
||||
zorder = series[:series_plotindex],
|
||||
cmap = py_colormap(cgrad(plot_color([:black, :white]))),
|
||||
vmin = 0.0,
|
||||
@ -642,7 +637,7 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
|
||||
end
|
||||
|
||||
if st == :heatmap
|
||||
x, y, z = heatmap_edges(x, sp[:xaxis][:scale]), heatmap_edges(y, sp[:yaxis][:scale]), transpose_z(series, z.surf)
|
||||
x, y = heatmap_edges(x, sp[:xaxis][:scale], y, sp[:yaxis][:scale], size(z))
|
||||
|
||||
expand_extrema!(sp[:xaxis], x)
|
||||
expand_extrema!(sp[:yaxis], y)
|
||||
|
||||
@ -874,9 +874,7 @@ end
|
||||
|
||||
x := Plots._bin_centers(edge_x)
|
||||
y := Plots._bin_centers(edge_y)
|
||||
z := Surface(float_weights)
|
||||
|
||||
match_dimensions := true
|
||||
z := Surface(permutedims(float_weights))
|
||||
seriestype := :heatmap
|
||||
()
|
||||
end
|
||||
|
||||
@ -345,6 +345,8 @@ function transpose_z(plotattributes, z, transpose_on_match::Bool = true)
|
||||
z
|
||||
end
|
||||
end
|
||||
handle_surface(z) = z
|
||||
handle_surface(z::Surface) = permutedims(z.surf)
|
||||
|
||||
function ok(x::Number, y::Number, z::Number = 0)
|
||||
isfinite(x) && isfinite(y) && isfinite(z)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user