MakieOrg / GeoMakie.jl

Geographical plotting utilities for Makie.jl
https://geo.makie.org
MIT License
167 stars 24 forks source link

hidedecorations!() and backgroundcolor not supported for ::GeoAxis #209

Open Zetison opened 6 months ago

Zetison commented 6 months ago

It seems to me that hidedecorations! and backgroundcolor is not provided for ::GeoAxis?

This example then fails.

asinghvi17 commented 4 months ago

Hidedecorations will be supported by #207, backgroundcolor can be added after that though it's a bit more difficult.

Zetison commented 3 months ago

Does it exist a workaround for the backgroundcolor?

asinghvi17 commented 3 months ago

You could set ga.scene.backgroundcolor, but that would cover the area of the scene, not just the geoaxis. If your entire figure has the same background color then it might be worth it though.

Zetison commented 3 months ago

I suspect not, but it does not work with the following example (where I want the ocean to be colored :lightblue1)?

using GLMakie, GeoMakie
fig = Figure(; size=(1920, 1080))

gridlayout1 = fig[1, 1:2] = GridLayout()
gridlayout2 = fig[2:4, 1] = GridLayout()
gridlayout3 = fig[2, 2] = GridLayout()
gridlayout4 = fig[3, 2] = GridLayout()
gridlayout5 = fig[4, 2] = GridLayout()

rowsize!(fig.layout, 3, Relative(0.55))
source = "+proj=merc +lon_0=0 +x_0=0 +y_0=0 +a=6378137 +b=6378137 +units=m +no_defs"
dest = "+proj=merc +lon_0=0 +x_0=0 +y_0=0 +a=6378137 +b=6378137 +units=m +no_defs"
ax1 = GeoMakie.GeoAxis(gridlayout2[1, 1]; source=source, dest=dest)
land = GeoMakie.land();
coastlns = poly!(
    ax1,
    land;
    color=:honeydew,
    colormap=:dense,
    strokecolor=:gray50,
    strokewidth=0.5,
    inspectable=false,
)
ax2 = Axis(gridlayout3[1, 1]; alignmode=Outside(), tellheight=false, tellwidth=false)
ax3 = Axis(gridlayout4[1, 1]; alignmode=Outside(), tellheight=false, tellwidth=false)

x = range(0, 1, 100)
lines!(ax2, x, sin.(2x))
lines!(ax3, x, sin.(3x))
ax1.scene.backgroundcolor = parse(Colorant, :lightblue1)
filchristou commented 3 months ago

for me it worked to pass the backgroundcolor to the Figure initialization. Not the best solution but I think it will do what you want.

filchristou commented 3 months ago

Also related to https://github.com/MakieOrg/GeoMakie.jl/issues/193

Zetison commented 2 months ago

for me it worked to pass the backgroundcolor to the Figure initialization. Not the best solution but I think it will do what you want.

This sets the background color for the entire figure blue (also around the ax2 and ax3 axis), and I only want it for the ax1 object (such that I get a map with a nice blue ocean).

Zetison commented 1 month ago

An ugly fix could be to implement the backgroundcolor option as

ocean_coords = [(180, -90), (-180, -90), (-180, 90), (180, 90)]
ocean = poly!(ax, ocean_coords, color = :lightblue1, strokewidth=0.5, strokecolor=:gray50)
Makie.translate!(ocean, 0, 0, -100)