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

[BUG] cornerplot y-axis is too large #5007

Open
Jonas-a-Zimmermann opened this issue Oct 24, 2024 · 3 comments
Open

[BUG] cornerplot y-axis is too large #5007

Jonas-a-Zimmermann opened this issue Oct 24, 2024 · 3 comments

Comments

@Jonas-a-Zimmermann
Copy link

Details

The y-lims in the cornerplot subfigures are too large, rendering the scatterplot and row-wise histograms useless.
e.g.

using Random, Plots, StatsPlots
x, y = randn(1000), randn(1000)
cornerplot([x;;y]; compact=false)

leads to
GRNotCompactPlot

Backends

This bug occurs on ( insert x below )

Backend yes no untested
gr (default) x
pythonplot x
plotlyjs x
pgfplotsx x
unicodeplots x
inspectdr x
gaston x

Versions

Plots.jl version:
Backend version: GR v0.73.8, PlotlyJS v0.18.14
Output of versioninfo():
Julia Version 1.10.5
Commit 6f3fdf7b362 (2024-08-27 14:19 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: macOS (arm64-apple-darwin22.4.0)
CPU: 14 × Apple M3 Max
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-15.0.7 (ORCJIT, apple-m1)

@Jonas-a-Zimmermann
Copy link
Author

Jonas-a-Zimmermann commented Oct 24, 2024

A (naive) fix for this is to add the xlims and ylims in the cornerplot, as e.g.

# scatters
    for i = 1:N
        vi = view(mat, :, i)
        for j = 1:N
            # only the lower triangle
            if compact && i <= j
                continue
            end

            vj = view(mat, :, j)
            @series begin
                ticks := :auto
                if i == N
                    xformatter := :auto
                    xguide := _cycle(labs, j)
                end
                if j == 1
                    yformatter := :auto
                    yguide := _cycle(labs, i)
                end
                seriestype := :scatter
                subplot := indices[i + 1 - k, j]
                markercolor := grad[0.5 + 0.5C[i, j]]
                smooth --> true
                markerstrokewidth --> 0
                xlims --> extrema(vj).*1.05
                ylims --> extrema(vi).*1.05
                vj, vi
            end
        end
        # end
    end

leading to the desired outcome
GRNotCompactPlotFix

@Jonas-a-Zimmermann
Copy link
Author

Jonas-a-Zimmermann commented Oct 29, 2024

After some digging I came to the conclusion that the cause of the issue is the usage of the depracted orientation in the definition of the histogram series (to clarify: line 71 of cornerplot.jl). After changing it to permute, it works as expected.
However, the histograms on the right corner suffer from the same issue as in #4949 .

@Jonas-a-Zimmermann
Copy link
Author

Jonas-a-Zimmermann commented Oct 31, 2024

While it also suffers from #4949 , there is the more intricate and serious issue of expand_extrema not fixing the lower limits of the (post permute)x-axis. This is set during the bar recipe. I believe the best course of action would be to just not handle axis widening during recipes.
With expand_extrema!(axis, scale_lims(ignorenan_extrema(xseg.pts)..., default_widen_factor)) in the bar recipe
Incorrect_Lower_bounds

Without expand_extrema!(axis, scale_lims(ignorenan_extrema(xseg.pts)..., default_widen_factor)) in the bar recipe
Correct_Lower_Bounds

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants