Skip to content

Commit

Permalink
geo datavis
Browse files Browse the repository at this point in the history
  • Loading branch information
lazarusA committed Jan 5, 2024
1 parent 2c82780 commit d6ed25c
Show file tree
Hide file tree
Showing 21 changed files with 163 additions and 84 deletions.
7 changes: 2 additions & 5 deletions docs/gen_mds.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ OUTPUT = joinpath(@__DIR__, "src", "examples")

folders = readdir(joinpath(@__DIR__, "..", "examples"))
setdiff!(folders, [".DS_Store"])
setdiff!(folders, ["geo", "rpr", "datavis"])
setdiff!(folders, ["rpr"])

function get_files(folders)
srcsfiles = []
Expand All @@ -17,11 +17,8 @@ function get_files(folders)
setdiff!(names, [".DS_Store",
"world_energy.jl",
"gapminder.jl",
"vertical_feature_mask.jl",
"gott_azimuthal.jl",
"submarine_cables.jl",
"timeseries_proj.jl",
"earthquakes_proj.jl",
"rasters.jl",
])

fpaths = "$(f)/" .* names
Expand Down
1 change: 1 addition & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ include("theme_light_dark.jl")
set_theme!(merge(theme_latexfonts(), theme_light_dark()))

# ENV["RASTERDATASOURCES_PATH"] = "/Users/lalonso/data/"

makedocs(; sitename="BeautifulMakie", authors="Lazaro Alonso",
clean=true,
checkdocs=:all,
Expand Down
38 changes: 35 additions & 3 deletions docs/src/.vitepress/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ export default defineConfig({
{ text: 'Themes', link: '/examples/themes/black_epicycloid' },
{ text: 'Animations', link: '/examples/animations/scatter_size' },
{ text: 'Dashboards', link: '/examples/dashboards/tesseral_spherical_harmonics' },
{ text: 'Data Visualization', link: '' },
{ text: 'Geo', link: '' },
{ text: 'Data Visualization', link: '/examples/datavis/earthquakes' },
{ text: 'Geo', link: '/examples/geo/projections' },
{ text: 'Algebra of Graphics', link: '/examples/aog/penguins3d' },
{ text: 'Raytracing', link: '' }
]},
Expand Down Expand Up @@ -416,7 +416,39 @@ export default defineConfig({
],
},
],

'/examples/geo/': [
{
text: 'Geo',
collapsed: true,
items: [
{ text: 'blue_marble', link: '/examples/geo/blue_marble' },
{ text: 'coastlines', link: '/examples/geo/coastlines' },
{ text: 'donut_earth_sun', link: '/examples/geo/donut_earth_sun' },
{ text: 'moon', link: '/examples/geo/moon' },
{ text: 'projections', link: '/examples/geo/projections' },
{ text: 'Rasters animation', link: '/examples/geo/rasters' },
{ text: 'us_states', link: '/examples/geo/us_states' },
{ text: 'vertical_feature_mask', link: '/examples/geo/vertical_feature_mask' },
],
},
],
'/examples/datavis/': [
{
text: 'Data Visualization',
collapsed: true,
items: [
{ text: 'astronauts', link: '/examples/datavis/astronauts' },
{ text: 'earthquakes_proj', link: '/examples/datavis/earthquakes_proj' },
{ text: 'earthquakes', link: '/examples/datavis/earthquakes' },
{ text: 'eigenvals_densities', link: '/examples/datavis/eigenvals_densities' },
{ text: 'eigenvals_evolution', link: '/examples/datavis/eigenvals_evolution' },
{ text: 'fractals', link: '/examples/datavis/fractals' },
{ text: 'leos', link: '/examples/datavis/leos' },
{ text: 'multipleTitles', link: '/examples/datavis/multipleTitles' },
{ text: 'strange_attractors', link: '/examples/datavis/strange_attractors' },
],
},
],
},
socialLinks: [
{ icon: 'linkedin', link: 'https://www.linkedin.com/in/lazaro-alonso/' },
Expand Down
16 changes: 12 additions & 4 deletions examples/datavis/astronauts.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using CairoMakie, HTTP, CSV, DataFrames, DataFramesMeta, Suppressor
using Images, ColorSchemes, Colors, Statistics
using Downloads
using Lazy: @>
CairoMakie.activate!(type = "png")

function plotastro()
data_url = "https://bit.ly/3kmlGn2"
@suppress begin
Expand Down Expand Up @@ -30,12 +32,14 @@ function plotastro()
astro
@subset([true; :ascend_shuttle[2:end] .!= :ascend_shuttle[1:end-1]])
end
tierra = "https://climate.nasa.gov/system/internal_resources/details/original/309_ImageWall5_768px-60.jpg"
tierra = "https://eoimages.gsfc.nasa.gov/images/imagerecords/8000/8108/ipcc_bluemarble_west_front.jpg"
@suppress begin
global imgEarth
tierra = HTTP.download(tierra)
tierra = Downloads.download(tierra)
imgEarth = load(tierra)
imgEarth = imgEarth[:,120:end-120]
end

function getPoints(xi, yi, xf, yf)
xyos = []
for i in 1:length(xo)
Expand Down Expand Up @@ -69,7 +73,7 @@ function plotastro()
autolimitaspect = 1)
hidespines!(ax)
hidedecorations!(ax)
image!(-20 .. 20, -17 .. 17, rotr90(imgEarth))
image!(-20 .. 20, -20 .. 20, rotr90(imgEarth))
text!(astro.name, position = @.(Point2f(cos(astro.θ), sin(astro.θ)) * 85),
rotation = astro.texttheta, fontsize = 6, align = astro.align)
text!(string.(valYear.year_of_mission),
Expand Down Expand Up @@ -113,4 +117,8 @@ function plotastro()
fig
end
end
plotastro()
fig = plotastro()

save("astronauts.png", fig); # hide

# ![](astronauts.png)
34 changes: 21 additions & 13 deletions examples/datavis/earthquakes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,32 @@ toPoints3D = [Point3f([toCartesian(lons[i], lats[i];
ms = (exp.(mag) .- minimum(exp.(mag))) ./ maximum(exp.(mag) .- minimum(exp.(mag)))

with_theme(theme_black()) do
fig = Figure(size = (1600, 1600), fontsize = 32)
fig = Figure(size = (900, 900), fontsize = 20)
ax = LScene(fig[1, 1], show_axis = false)
pltobj = meshscatter!(ax, toPoints3D; markersize = ms / 20 .+ 0.001, color = mag,
colormap = resample_cmap(:afmhot, 256)[10:end], shading = FastShading,
ambient = Vec3f(0.99, 0.99, 0.99))
surface!(ax, sphere(; r = 1.0)..., color = tuple.(earth_img, 0.1),
shading = FastShading, transparency = true)
Colorbar(fig[1, 2], pltobj, label = "Magnitude", height = Relative(1.5 / 4))
Label(fig[1, 1, Bottom()], "Visualization by @LazarusAlon\nusing Makie")
Label(fig[1, 1, Top()], "Earthquakes on Earth between January 2021 and January 2022.\nOriginal data from USGS")
zoom!(ax.scene, cameracontrols(ax.scene), 0.65)
Label(fig[1, 1, Top()],
rich("Visualization by ",
rich("Lazaro Alonso\n", color=:dodgerblue),
rich("using Makie", color=:orangered)),
justification=:left,
halign=1.0
)
Label(fig[1, 1, Top()], "Earthquakes on Earth. Jan-2021 to Jan-2022\nOriginal data from USGS",
halign=0.0, justification=:left)
zoom!(ax.scene, cameracontrols(ax.scene), 0.55)
rotate!(ax.scene, 3.0)
## uncomment to get the animation
## record(fig, joinpath(@__DIR__, "earthquakes.mp4"), framerate = 24) do io
## for i in 3.0:0.015:9.5
## rotate!(ax.scene, i)
## recordframe!(io) # record a new frame
## end
## end
fig
end

record(fig, "earthquakes.mp4", framerate = 24, update=false) do io
for i in 3.0:0.015:9.5
rotate!(ax.scene, i)
recordframe!(io) # record a new frame
end
end
end

# ![type:video](earthquakes.mp4)
20 changes: 11 additions & 9 deletions examples/datavis/earthquakes_proj.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,26 @@ plt = data(n15) * mapping(:n, :depth, color=:mag, text = :place => verbatim) *
ptxt = data(n15) * mapping(:x, :n=>(t->t+0.25), text = :place => verbatim) *
visual(Makie.Text, align = (:left, :bottom))

with_theme(theme_black(), size = (1400,800)) do
with_theme(theme_dark(), size = (1400,800)) do
fig = Figure()
gax = GeoAxis(fig[1,2]; aspect = 1,
dest = "+proj=eqdc +lat_1=90 +lat_2=90",
coastlines = true, coastline_attributes = (; color=:papayawhip, linewidth=0.5)
)
gax = GeoAxis(fig[1,2]; aspect = 1, dest = "+proj=eqdc +lat_1=90 +lat_2=90")
axlocs = Axis(fig[1,1], xlabel = "depth [km]", ylabel = "magnitude")
obj = draw!(gax, p)
colorbar!(fig[1,3], obj)
lines!(gax, GeoMakie.coastlines(), color=:papayawhip, linewidth=0.5)
#obj = draw!(gax, p)
obj = scatter!(gax, df[!, :longitude], df[!, :latitude];
color = df[!, :mag], colormap = Reverse(:Hiroshige),
markersize = 50*(exp.(df[!, :mag]) .- mn)/mx )

Colorbar(fig[1,3], obj)
draw!(axlocs, plt)
draw!(axlocs, ptxt)
axlocs.yticks = (1:15, string.(n15[!, :mag]))
colsize!(fig.layout, 1, Auto(0.5))
colgap!(fig.layout,0)
hidespines!(axlocs, :r, :t)
Label(fig[1, 2, Bottom()], "Visualization by @LazarusAlon\nusing Makie")
Label(fig[1, 2, Bottom()], "\n\nVisualization by @LazarusAlon\nusing Makie")
Label(fig[1, 1, Top()],
"Earthquakes on Earth between January 2021 and January 2022.\nOriginal data from USGS",
"Earthquakes on Earth. Jan-2021 to Jan-2022.\nOriginal data from USGS",
color = :gold)
fig
end
Expand Down
4 changes: 2 additions & 2 deletions examples/datavis/eigenvals_densities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ m3(;a=9rand()-5,b=9rand()-5) = [a 1 -1; -1 b 0; 1 -1 -1]
h = HeatMap(range(-4,4,length=1200),range(-2,2,length=1200))
getcounts!(h, m3; n = 1_500_000)

with_theme(theme_ggplot2()) do
with_theme(theme_dark()) do
fig = Figure(figure_padding=0,size=(600,400))
ax = Axis(fig[1,1]; aspect = DataAspect())
heatmap!(ax, -4..4, -2..2,eq_hist(h.counts);
colormap = :seaborn_icefire_gradient)
colormap = :CMRmap)
hidedecorations!(ax)
hidespines!(ax)
fig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ function m12(n=10)
return a, b
end

n = 100
a, b = m12(100)
n = 150
a, b = m12(n)
xs, ys = xy(a,b)
colors = repeat(1:n,inner=500)

Expand Down
8 changes: 6 additions & 2 deletions examples/datavis/leos.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function BezierPath(o, f, co, cf; t = range(0,1, length=30))
return [poly3(t, o, co, cf, f) for t in t]
end
function posFig(ax, x; yoff=100, ylow = 15)
o = ax.scene.px_area[].origin - Point2f(0, yoff)
o = ax.scene.viewport[].origin - Point2f(0, yoff)
return Makie.project(ax.scene, Point2f(x, ylow)) + o
end
function supLine(p1, p2; x=0,y=8)
Expand Down Expand Up @@ -95,4 +95,8 @@ with_theme(theme_black()) do
margin = (30, 10, 10, 10), framecolor = (:white,0.2))
Label(fig[0,:], "Leo's Syndrome", color = "#F79D1EFF", fontsize = 32)
fig
end
end

save("leos.png", current_figure()); # hide

# ![](leos.png)
6 changes: 5 additions & 1 deletion examples/datavis/multipleTitles.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,8 @@ with_theme(theme_dark(), size = (650, 450)) do
inter-bank rate. The dots depict the forward paths for nominal interest rates.
""", tellwidth = false, halign = :left, justification = :left)
fig
end
end

save("multipleTitles.svg", current_figure()); # hide

# ![](multipleTitles.svg)
6 changes: 5 additions & 1 deletion examples/datavis/strange_attractors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,8 @@ with_theme(theme_black()) do
rowgap!(fig.layout,5)
colgap!(fig.layout,1)
fig
end
end

save("strange_attractors.png", current_figure()); # hide

# ![](strange_attractors.png)
15 changes: 0 additions & 15 deletions examples/datavis/timeseries_proj.jl

This file was deleted.

6 changes: 5 additions & 1 deletion examples/geo/blue_marble.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,8 @@ surface!(ax, x, y, z;
)
zoom!(ax.scene, cameracontrols(ax.scene), 0.65)
GLMakie.rotate!(ax.scene, Vec3f(0, 0, 1), 3.0)
fig
fig

save("blue_marble.png", fig); # hide

# ![](blue_marble.png)
6 changes: 5 additions & 1 deletion examples/geo/coastlines.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ GLMakie.activate!()
fig = Figure(; size=(600, 400))
ax = GeoAxis(fig[1, 1]; title="coastlines")
lines!(ax, GeoMakie.coastlines()) # plot coastlines from Natural Earth.
fig
fig

save("coastlines.png", fig); # hide

# ![](coastlines.png)
6 changes: 5 additions & 1 deletion examples/geo/donut_earth_sun.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,8 @@ with_theme(theme_dark()) do
backlight = 1.5f0)
hidedecorations!(ax; grid=false)
fig
end
end

save("donut_earth_sun.png", current_figure()); # hide

# ![](donut_earth_sun.png)
8 changes: 6 additions & 2 deletions examples/geo/gott_azimuthal.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using GeoMakie
using GLMakie

GLMakie.activate!()
# Double-sided disk map: Gott, Goldberg and Vanderbei’s"
fig = Figure(; size=(1200, 600))
ax_top = GeoAxis(fig[1, 1]; dest="+proj=aeqd +lat_0=90 +lon_0=-45",
Expand All @@ -14,4 +14,8 @@ lines!(ax_top, GeoMakie.coastlines())
lines!(ax_bottom, GeoMakie.coastlines())
#ylims!(ax_bottom, -90, 0)
#ylims!(ax_top, 0, 90)
fig
fig

save("gott_azimuthal.png", fig); # hide

# ![](gott_azimuthal.png)
6 changes: 5 additions & 1 deletion examples/geo/moon.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,8 @@ surface!(ax, x, y, z;
hidedecorations!(ax)
hidespines!(ax)
fig[1, 1] = ax
fig
fig

save("moon.png", fig); # hide

# ![](moon.png)
6 changes: 5 additions & 1 deletion examples/geo/projections.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,8 @@ function plotproj()
end
fig
end
plotproj()

fig = plotproj()
save("projections.png", fig); # hide

# ![](projections.png)
Loading

0 comments on commit d6ed25c

Please sign in to comment.