-
Notifications
You must be signed in to change notification settings - Fork 8
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
Use Makie.automatic for colorrange #120
Use Makie.automatic for colorrange #120
Conversation
Can we add this for all plot types? I think it's just FerriteViz.jl/src/makieplotting.jl Line 118 in 24a6112
|
Does this work if min approx max and min or max approx zero? We introduced the fix back then, because the automatic colorrange failed to display at all in these cases. |
ah misread the PR example, I thought it display |
It seems to work, but gives the warning (4 times) ┌ Warning: No strict ticks found
└ @ PlotUtils C:\Users\meyer\.julia\packages\PlotUtils\jEGKP\src\ticks.jl:191 using Ferrite, FerriteViz
import GLMakie as Plt
grid = generate_grid(Quadrilateral, (2, 2))
dh = DofHandler(grid)
add!(dh, :u, 1, Lagrange{2,RefCube,1}())
close!(dh)
a = zeros(ndofs(dh))
apply_analytical!(a, dh, :u, x -> rand() - 0.5) # ∈ [-0.5, 0.5]
plotter = MakiePlotter(dh, a)
fig = Plt.Figure()
ax = Plt.Axis(fig[1,1])
sp = solutionplot!(ax, plotter; colorrange=(-1.0, 1.0))
Plt.Colorbar(fig[1,2], sp)
fig
# Case with zero amplitude of data
apply_analytical!(a, dh, :u, Returns(0.0))
p2 = MakiePlotter(dh, a)
ax2 = Plt.Axis(fig[2,1])
sp2 = solutionplot!(ax2, p2)
Plt.Colorbar(fig[2,2], sp2)
# Case with almost zero amplitude of data (works but warns)
apply_analytical!(a, dh, :u, x -> 1e-20*rand())
p3 = MakiePlotter(dh, a)
ax3 = Plt.Axis(fig[3,1])
sp3 = solutionplot!(ax3, p2)
Plt.Colorbar(fig[3,2], sp3)
fig |
using Ferrite, FerriteViz
import GLMakie as Plt
grid = generate_grid(Quadrilateral, (2, 2))
dh = DofHandler(grid)
add!(dh, :u, 1, Lagrange{2,RefCube,1}())
close!(dh)
a = zeros(ndofs(dh))
plotter = MakiePlotter(dh, a)
fig = Plt.Figure()
ax = Plt.Axis(fig[1,1])
sp = solutionplot!(ax, plotter)
Plt.Colorbar(fig[1,2], sp)
fig using Ferrite, FerriteViz
import GLMakie as Plt
grid = generate_grid(Quadrilateral, (2, 2))
dh = DofHandler(grid)
add!(dh, :u, 1, Lagrange{2,RefCube,1}())
close!(dh)
a = ones(ndofs(dh))
plotter = MakiePlotter(dh, a)
fig = Plt.Figure()
ax = Plt.Axis(fig[1,1])
sp = solutionplot!(ax, plotter)
Plt.Colorbar(fig[1,2], sp)
fig using Ferrite, FerriteViz
import GLMakie as Plt
grid = generate_grid(Quadrilateral, (2, 2))
dh = DofHandler(grid)
add!(dh, :u, 1, Lagrange{2,RefCube,1}())
close!(dh)
a = rand(ndofs(dh))
plotter = MakiePlotter(dh, a)
fig = Plt.Figure()
ax = Plt.Axis(fig[1,1])
sp = solutionplot!(ax, plotter)
Plt.Colorbar(fig[1,2], sp)
fig All work now with the automatic keyword (at least on the latest Makie release). 🚀 Can you add the corresponding change also to CellPlot as Max proposed. And add the information to the docstrings, because it seems this option is missing. Thanks! |
I have locally a fix to recover the NaN handling. If @koehlerson is fine with the changes I will push, we make another round of review and merge. |
supersedes #119, thanks for the tip @termi-official on
Makie.automatic
(haven't checked if this introduces new compat requirements)Reproducer
master (colorrange [-1, 1] not respected):
pr (colorrange [-1, 1] respected)