I just want to express the feeling that it seems that all Makie plots shown I’ve seen have all those saturated colors (including most plots in this thread). If I were to use Makie, I will definitely define my own color cycle.
go for it. And let’s see how it turns out, if possible.
Fantastic. I learned a fair bit, from reading your code. Not sure if the challenger @StevenSiew was expecting such a response?
Either way, I think challenges/competitions are a great way to draw out clever use of code.
In that spirit, here is something that can be done in MATLAB. I’d be very impressed if the bottom right figure could be produced in Makie
Disclaimer: I’m really just hoping someone can do it, so I can borrow their code!
There is a package build for GR/Plots called TernaryPlots.jl . Maybe this includes a lot things that are needed for this, in case it is not implemented yet.
The only problem should be drawing the axis Which isn’t a big problem I suppose, just a bit of work
Thanks, converting to barrycentric coordinates is fairly trivial. I’ve had some success making 2d ternary quiver plots using plots.jl and just drawing the axes as plots. I’ve managed to make a ternary surface in pgfplots, but the wasn’t very polished. Looking at the plots produced by @lazarusA I think Makie would be ideal for making a really nice ternary surface plot. Better than the one I attached. I will have a crack at it tonight, if the kids let me.
everything is just a little bit of work
I thought it could be tricky in terms of converts and projections if one wanted to add this as a real axis type. Like a scatter! with three arguments referring to a position in the triangle in that axis, not a 3d plot, etc.
Just drawing a thing like that while manually preparing the projected data etc, would not be very tricky I think.
A next-level challenge is adding a data dimension: tetrahedral plot with 4 axes, 3 independent.
Here’s a chromaticity diagram, including blackbody curve and the sRGB gamut:
This is my effort to learn a bit about Makie, so my code may not be ideal. I welcome any improvements.
### A Pluto.jl notebook ###
# v0.14.8
using Markdown
using InteractiveUtils
# ╔═╡ 0dc0ad8d-9451-405c-8cd9-894553ab5cc0
begin
using Pkg
Pkg.activate(mktempdir())
Pkg.add("Colors"); using Colors
Pkg.add("GLMakie"); using GLMakie
#Pkg.add("Images"); using Images
Pkg.add("PolygonOps"); using PolygonOps
end
# ╔═╡ f22934c0-c99c-11eb-02bd-7f3d9d71104e
md"""
##### Chromaticity diagram in Makie
"""
# ╔═╡ 2fdc73a2-eaad-4b9a-a1cf-bc03cf873d8b
function xy_from_λ(λ)
c = xyY(colormatch(λ))
return c.x,c.y
end
# ╔═╡ 5344f9c7-e7ab-428e-9ff5-a03ea3ee3ea6
begin
ml_xy = xy_from_λ.(400:700)
ml_poly = [ml_xy; ml_xy[begin]]
end;
# ╔═╡ bd8d96ca-ea38-4134-929d-29de7cf7543f
begin
scale = 2
alpha=1.0 # set to 0.75 for slightly visible gridlines
xi = 0:770scale
yi = 0:870scale
z = zeros(RGBA, length(xi), length(yi))
for x in xi
for y in yi
cx = x/1000scale
cy = y/1000scale
if inpolygon((cx,cy), ml_poly)==1
c = RGB(xyY(cx,cy,1e-6))
k = 1.0/maximum((c.r, c.g, c.b))
c = RGBA(k*c.r, k*c.g, k*c.b, alpha)
z[x+1,y+1] = c
else
z[x+1,y+1] = RGBA(0, 0, 0, alpha)
end
end
end
end
# ╔═╡ 1b6264d2-1f32-44b5-b616-afcdde57bf93
ml_ticks = [400, 470, 480, 485, 490, 495, 500, 505, 510, 520,
530, 540, 550, 560, 570, 580, 590, 600, 620, 700];
# ╔═╡ b1251318-2bd8-4d97-9fda-8839a193a03c
function M(λ,T)
h = 6.62607015e-34 # J/Hz
c = 2.99792458e8 # m/s
k = 1.380649e-23 # J/K
c1 = 2π*h*c^2
c2 = h*c/k
λ = λ/1e9
return c1/λ^5/(exp(c2/(λ*T))-1)
end
# ╔═╡ 77daa5fd-25b2-43aa-990e-07d9cde8cf6d
function xy_from_T(T)
c = sum(colormatch.(360:760).*M.(360:760,T))
m = max(c.x, c.y, c.z)
c = xyY(XYZ(c.x/m, c.y/m, c.z/m))
return c.x, c.y
end
# ╔═╡ cc5500cc-9c8c-4af1-95a3-8f7f5ba1c61e
Planckian_ticks = [1500, 2000, 3000, 4000, 5000, 6500, 10000]
# ╔═╡ df5c10ce-21a6-487f-9f07-28d3b6486b97
begin
fig = Figure(backgroundcolor = RGB(0,0,0),
textcolor=:white,
resolution = (1000, 1000))
ax1 = fig[1, 1] = Axis(fig, title = "Chromaticity Diagram")
ax1.xticks=0.0:0.1:0.8
ax1.yticks=0.0:0.1:0.9
image!(ax1,
0.0:.01:0.77,
0.0:0.01:0.87,
z)
lines!(ax1,
[p[1] for p in ml_poly],
[p[2] for p in ml_poly],
linewidth=1.5,
color=:black)
scatter!(ax1,
xy_from_λ.(ml_ticks),
color=:white,
marker=:x)
annotations!(ax1,
string.(ml_ticks),
Point.(xy_from_λ.(ml_ticks));
color=:grey60)
lines!(ax1,
xy_from_T.(1000:5:10000), color=:white)
scatter!(ax1,
xy_from_T.(Planckian_ticks),
marker=:x)
annotations!(ax1,
string.(Planckian_ticks),
Point.(xy_from_T.(Planckian_ticks)),
offset = (-20, -30),
color=:white)
lines!(ax1,
[(0.64, 0.33), (0.3, 0.6), (0.15, 0.06), (0.64, 0.33)],
color=:white)
fig
end
# ╔═╡ Cell order:
# ╟─f22934c0-c99c-11eb-02bd-7f3d9d71104e
# ╠═2fdc73a2-eaad-4b9a-a1cf-bc03cf873d8b
# ╠═5344f9c7-e7ab-428e-9ff5-a03ea3ee3ea6
# ╠═bd8d96ca-ea38-4134-929d-29de7cf7543f
# ╠═1b6264d2-1f32-44b5-b616-afcdde57bf93
# ╠═b1251318-2bd8-4d97-9fda-8839a193a03c
# ╠═77daa5fd-25b2-43aa-990e-07d9cde8cf6d
# ╠═cc5500cc-9c8c-4af1-95a3-8f7f5ba1c61e
# ╠═df5c10ce-21a6-487f-9f07-28d3b6486b97
# ╠═0dc0ad8d-9451-405c-8cd9-894553ab5cc0
Got a rough version going.
The original was actually a density plot of data. I’ll need to play around with KDEs and transformations and recreate the original post, with code.
A plot of the Palmer penguins with a map would be interesting. Google maps is not particularly good for that neighbourhood, like Dream island pointed to a place that is just empty.
Edit: there’s a pengun webcam, but it’s not online this time of the year. That makes sense, there’d be winter now. The USAP Portal: Science and Support in Antarctica - Palmer Station Webcams
drop some coordinates, and let’s see what can be done
Not sure if it helps, but here there is an example of plotting the Antarctic coastline with AlgebraOfGraphics (including a small snippet to download coordinates as a shapefile).
Finding a good map is a challenge, I’ll update when I’ve found something.
I mean, just show me where the penguins are (coordinates) and I will do a map. There are probably a few trackers on them. Or some stations where they are normally observed.