Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix offset array hist #4860

Merged
merged 2 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/backends/pythonplot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1229,10 +1229,10 @@ function _before_layout_calcs(plt::Plot{PythonPlotBackend})
# link axes
x_ax_link, y_ax_link = xaxis.sps[1].o, yaxis.sps[1].o
if Bool(ax != x_ax_link) # twinx
ax.get_shared_x_axes().join(ax, x_ax_link)
ax.sharey(y_ax_link)
end
if Bool(ax != y_ax_link) # twiny
ax.get_shared_y_axes().join(ax, y_ax_link)
ax.sharex(x_ax_link)
end
end # for sp in pl.subplots
_py_drawfig(fig)
Expand Down
10 changes: 6 additions & 4 deletions src/recipes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,16 @@ function make_steps(x::AbstractArray, st, even)
n = length(x)
n == 0 && return zeros(0)
newx = zeros(2n - (even ? 0 : 1))
newx[1] = x[1]
xstartindex = firstindex(x)
newx[1] = x[xstartindex]
for i in 2:n
xindex = xstartindex - 1 + i
idx = 2i - 1
if st === :mid
newx[idx] = newx[idx - 1] = (x[i] + x[i - 1]) / 2
newx[idx] = newx[idx - 1] = (x[xindex] + x[xindex - 1]) / 2
else
newx[idx] = x[i]
newx[idx - 1] = x[st === :pre ? i : i - 1]
newx[idx] = x[xindex]
newx[idx - 1] = x[st === :pre ? xindex : xindex - 1]
end
end
even && (newx[end] = x[end])
Expand Down
2 changes: 1 addition & 1 deletion test/test_axes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ end
@testset "Twinx" begin
pl = plot(1:10, margin = 2Plots.cm)
twpl = twinx(pl)
pl! = plot!(twinx(), -(1:10))
pl! = plot!(twpl, -(1:10))
@test twpl[:right_margin] == 2Plots.cm
@test twpl[:left_margin] == 2Plots.cm
@test twpl[:top_margin] == 2Plots.cm
Expand Down
7 changes: 7 additions & 0 deletions test/test_recipes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ end
@test Plots.ylims(vsp) == (-2, 5)
end

@testset "steps offset" begin
data = OffsetArray(rand(11), -5:5)
plot(data, linetype = :steppre)
plot(data, linetype = :stepmid)
plot(data, linetype = :steppost)
end

@testset "offset axes" begin
tri = OffsetVector(vcat(1:5, 4:-1:1), 11:19)
sticks = plot(tri, seriestype = :sticks)
Expand Down
Loading