add mwe as example - fix needs_3d_axes
This commit is contained in:
parent
2a74f556c8
commit
29475890b2
@ -1282,8 +1282,8 @@ function gr_set_window(sp, viewport_plotarea)
|
||||
gr_set_viewport_polar(viewport_plotarea)
|
||||
else
|
||||
xmin, xmax, ymin, ymax = gr_xy_axislims(sp)
|
||||
is3d = RecipesPipeline.is3d(sp)
|
||||
if is3d
|
||||
needs_3d = needs_any_3d_axes(sp)
|
||||
if needs_3d
|
||||
zmin, zmax = gr_z_axislims(sp)
|
||||
zok = zmax > zmin
|
||||
else
|
||||
@ -1292,12 +1292,12 @@ function gr_set_window(sp, viewport_plotarea)
|
||||
|
||||
scaleop = 0
|
||||
if xmax > xmin && ymax > ymin && zok
|
||||
sp[:xaxis][:scale] == :log10 && (scaleop |= GR.OPTION_X_LOG)
|
||||
sp[:yaxis][:scale] == :log10 && (scaleop |= GR.OPTION_Y_LOG)
|
||||
is3d && sp[:zaxis][:scale] == :log10 && (scaleop |= GR.OPTION_Z_LOG)
|
||||
sp[:xaxis][:flip] && (scaleop |= GR.OPTION_FLIP_X)
|
||||
sp[:yaxis][:flip] && (scaleop |= GR.OPTION_FLIP_Y)
|
||||
is3d && sp[:zaxis][:flip] && (scaleop |= GR.OPTION_FLIP_Z)
|
||||
sp[:xaxis][:scale] == :log10 && (scaleop |= GR.OPTION_X_LOG)
|
||||
sp[:yaxis][:scale] == :log10 && (scaleop |= GR.OPTION_Y_LOG)
|
||||
needs_3d && sp[:zaxis][:scale] == :log10 && (scaleop |= GR.OPTION_Z_LOG)
|
||||
sp[:xaxis][:flip] && (scaleop |= GR.OPTION_FLIP_X)
|
||||
sp[:yaxis][:flip] && (scaleop |= GR.OPTION_FLIP_Y)
|
||||
needs_3d && sp[:zaxis][:flip] && (scaleop |= GR.OPTION_FLIP_Z)
|
||||
# NOTE: setwindow sets the "data coordinate" limits of the current "viewport"
|
||||
GR.setwindow(xmin, xmax, ymin, ymax)
|
||||
GR.setscale(scaleop)
|
||||
|
||||
@ -1163,6 +1163,56 @@ const _examples = PlotExample[
|
||||
),
|
||||
],
|
||||
),
|
||||
PlotExample( # 55
|
||||
"3D axis flip / mirror",
|
||||
"",
|
||||
[
|
||||
:(
|
||||
begin
|
||||
meshgrid(x, y) = (ones(eltype(y), length(y)) * x', y * ones(eltype(x), length(x))')
|
||||
scalefontsizes(.5)
|
||||
|
||||
x, y = meshgrid(-6:0.5:10, -8:0.5:8)
|
||||
r = sqrt.(x .^ 2 + y .^ 2) .+ eps()
|
||||
z = sin.(r) ./ r
|
||||
|
||||
args = x[1, :], y[:, 1], z[:]
|
||||
kwargs = Dict(
|
||||
:xlabel => "x", :ylabel => "y", :zlabel => "z",
|
||||
:grid => true, :minorgrid => true, :dpi => 200
|
||||
)
|
||||
|
||||
plots = [wireframe(args..., title = "wire"; kwargs...)]
|
||||
|
||||
for ax ∈ (:x, :y, :z)
|
||||
push!(plots, wireframe(
|
||||
args...,
|
||||
title = "wire-flip-$ax",
|
||||
xflip = ax == :x,
|
||||
yflip = ax == :y,
|
||||
zflip = ax == :z;
|
||||
kwargs...,
|
||||
))
|
||||
end
|
||||
|
||||
for ax ∈ (:x, :y, :z)
|
||||
push!(plots, wireframe(
|
||||
args...,
|
||||
title = "wire-mirror-$ax",
|
||||
xmirror = ax == :x,
|
||||
ymirror = ax == :y,
|
||||
zmirror = ax == :z;
|
||||
kwargs...,
|
||||
))
|
||||
end
|
||||
|
||||
plot(plots..., layout=(@layout [_ ° _; ° ° °; ° ° °]), margin=2Plots.mm)
|
||||
|
||||
scalefontsizes()
|
||||
end
|
||||
),
|
||||
],
|
||||
),
|
||||
]
|
||||
|
||||
# Some constants for PlotDocs and PlotReferenceImages
|
||||
|
||||
@ -338,6 +338,14 @@ function _override_seriestype_check(plotattributes::AKW, st::Symbol)
|
||||
st
|
||||
end
|
||||
|
||||
function needs_any_3d_axes(sp::Subplot)
|
||||
any(
|
||||
RecipesPipeline.needs_3d_axes(
|
||||
_override_seriestype_check(s.plotattributes, s.plotattributes[:seriestype])
|
||||
) for s in series_list(sp)
|
||||
)
|
||||
end
|
||||
|
||||
function _expand_subplot_extrema(sp::Subplot, plotattributes::AKW, st::Symbol)
|
||||
# adjust extrema and discrete info
|
||||
if st == :image
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user