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

xlims! error on GeoAxis #196

Closed
jjgecon opened this issue Feb 2, 2024 · 2 comments
Closed

xlims! error on GeoAxis #196

jjgecon opened this issue Feb 2, 2024 · 2 comments

Comments

@jjgecon
Copy link

jjgecon commented Feb 2, 2024

I'm trying to set up a map with xlims!

where

lons = -180:180
lats = -90:90
field = [exp(cosd(l)) + 3(y/90) for l in lons, y in lats]

fig = Figure()
ax = GeoAxis(fig[1,1])
surface!(ax, lons, lats, field; shading = NoShading)
xlims!(ax,-90,90)
fig

gives the error MethodError: no method matching convert_limit_attribute(::Rect2{Float64})

I think there is an error in the source code makie-axis.jl because unlike ylims! (which work) have ax.finallimits[] in line 446 instead ax.limits[].

@Zetison
Copy link

Zetison commented Feb 3, 2024

Seems to be the same issue as #191

@asinghvi17
Copy link
Member

Try running this code and see if it works?

function Makie.xlims!(ax::GeoAxis, xlims)
    if length(xlims) != 2
        error("Invalid xlims length of $(length(xlims)), must be 2.")
    elseif xlims[1] == xlims[2] && xlims[1] !== nothing
        error("Can't set x limits to the same value $(xlims[1]).")
    elseif all(x -> x isa Real, xlims) && xlims[1] > xlims[2]
        xlims = reverse(xlims)
        ax.xreversed[] = true
    else
        ax.xreversed[] = false
    end
    mlims = Makie.convert_limit_attribute(ax.limits[])

    ax.limits.val = (xlims, mlims[2])
    Makie.reset_limits!(ax; yauto=false)
    return nothing
end

It's basically what you suggested @jjgecon :) - if this works will create a new patch release with these two fixes!

asinghvi17 added a commit that referenced this issue Feb 5, 2024
asinghvi17 added a commit that referenced this issue Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants