Conversation
Benchmark ResultsSHA: 2456696c43e1b65a2c968b96a22ff74bd9117123 Warning These results are subject to substantial noise because GitHub's CI runs on shared machines that are not ideally suited for benchmarking. |
|
How would this fit in with an auto-legending or auto-colorbar request? |
|
Can this be used to define axis attributes that update with the data? If so, should that be based on compute graph rather than observables for a later point when we might switch blocks to that infra as well? Because currently you'll have to convert to observables at the border but we might want to hide that from the user. |
We had a discussion internally about axis hints and auto legends and whatnot a while ago. The conclusion was that axis hints and auto legends should be separate, with axis hints generating defaults based on one plot and auto legends being part of some higher level system that may include multiple plots and layouting.
The plot you get in I could try delaying the call to |
|
@ffreyer what is the status of this PR? |
|
I think I was just waiting for review/feedback on this |
It would be great if someone could review this PR. |
|
ping @SimonDanisch |
|
We are looking forward to this feature. Is there any chance that someone could review this PR in the following weeks? |
|
Maybe you can review it as a user and try it out if it covers your use cases? That would be most valuable! |
|
Will do! Just thought that my review wouldn't matter for the merge decision.
Em sáb., 4 de abr. de 2026, 13:30, Simon ***@***.***>
escreveu:
… *SimonDanisch* left a comment (MakieOrg/Makie.jl#5375)
<#5375 (comment)>
Maybe you can review it as a user and try it out if it covers your use
cases? That would be most valuable!
—
Reply to this email directly, view it on GitHub
<#5375 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAZQW3M77BPQYXWVW5Q3HO34UE2CZAVCNFSM6AAAAACKWQCHJKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHM2DCOBXGM3DCMJRGE>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
|
I think we're mainly unsure if this is a good user facing API ;) |
|
@ffreyer the new function works like a charm. Could we also have a method that dispatches on the If we could dispatch on the |
|
@SimonDanisch do you have an opinion about this method with |
|
A slightly modified API is proposed in https://github.com/MakieOrg/Makie.jl/pull/5581/changes |
|
Thank you @jariji. It is good to see that other people already identified this need in other contexts as well. |
* Add argument-level preferred_axis_attributes hook Extend the axis hints system so that data types passed as plot arguments can provide default axis attributes (labels, scales, limits) by defining preferred_axis_attributes(arg). This mirrors args_preferred_axis(arg) which already determines the axis *type* from individual arguments. Recipe-level hints (2-arg form) take priority over argument-level hints, and user-provided axis keywords override both. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Unify preferred_axis_attributes into (AxisType, plot) / (AxisType, args...) Address ffreyer's review: include axis type, pass all args at once, and unify recipe-level and arg-level forms into a single dispatch chain. The (AxisType, plot::Plot) form defaults to unpacking plot.args[] and delegating to (AxisType, args...), so recipe authors override the first and data type authors override the second. This also flips argument order to (AxisType, plot) so the axis type is available for dispatch (different axis types use different attribute names). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: jariji <jariji@users.noreply.github.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
I merged the changes from #5581 though I also reordered the methods. Instead of
it is now
That way you can have plot based defaults and still specialize to (plot and) argument based defaults. I'm basically thinking that the more detail you add to these methods, the priority you should get for setting attributes. I also did the same thing to |
|
Thank you @ffreyer for the update. I will be able to test it again on Wednesday or Thursday. |
|
@ffreyer the latest changes work beautifully: https://github.com/JuliaGeometry/Meshes.jl/pull/1357/changes Looking forward to the next Makie.jl release with this new feature. |
|
Eager to try using this to replace hacky axis attributes setup in packages like MakieExtra and AxisKeysExtra!
ax = Axis(fig[1,1], width=200, height=300)
hidespines!()
...
image!(ax, data)and automatic labels would be natural here, based on |
Does it make sense to overwrite the attributes of an already created axis with |
|
@juliohm note that I haven't said that That's how things work now: data = [
KeyedArray(1:5, time=10:10:50),
KeyedArray(1:5, time=15:10:55),
]
ax = Axis(Figure()[1,1])
for d in data
scatterlines!(d)
endAnd I'd be happy to transition the implementation to |
Is it actually useful? I'd imagine axis related information is one of those things that
Well, you'd need to figure out what attributes the user set for that. I don't think diffing current with default attributes would be enough for that, because it would fail to catch the user setting an attribute to its default value to avoid plot-based overwriting. (Or maybe that's an acceptable shortcoming?) Another option would be to track the state of each attribute through construction and setindex/setproperty. Which seems kind of bloaty but maybe that's ok? In general, when we discussed axis hints we were kind of doubtful about how useful they would be. For units you can use dim converts, probably even with something like KeyedArray. (0.25/#5323 adds functionality for having dim converts affect axis labels and also allows them to hint whether they should be in tick labels or axis labels.) For more complicated things 0.25/#5465 adds complex recipes. They also allow you to add automatic legends, colorbars or anything layout related which seems like the thing people actually want. |
Of course – if my
Would be nice, yes – but even some simple callsite opt-in would help.
IMO tracking "default" vs "explicitly assigned" could generally be useful, not just for this purpose. Haven't read other recent PRs you linked in detail yet, do you suggest that those advanced recipes make these "axis hints" obsolete? |
Hmm, if you're converting between types that have extra information then that makes sense. I view
An opt-in kwarg sounds good to me. That would skip all the extra complexity. Might also be nice to be able to opt-out in the non-mutating calls.
tl;dr for complex/block recipes is that @Block MyBlock (x, y) begin ... end
function Makie.initialize_block!(b::MyBlock)
ax = Axis(b[1, 1])
map!(eachindex, b, :x, :scatter_colors)
p = scatter!(ax, b.x, b.y, color = b.scatter_colors)
Colorbar(b[1, 2], p)
end
f, b = MyBlock(rand(10), rand(10))and if you are creating the axis manually in such a recipe, then you can of course also set all the axis attributes there. It doesn't make axis hints obsolete, but it is another way to get there. |

Description
This pr adds
as an extendable function for providing axis attributes to a generated axis. This is used with non-mutating
plot()calls just likepreferred_axis_type() / args_preferred_axis(). Whenplot(..., axis = (...))is used, both sources are merged with the attributes from the plot call taking priority . If a different axis type is set there, the new type will be used to generate default attributes. The method call order here is:preferred_axis_attributes(AxisType, plot, args...)preferred_axis_attributes(AxisType, plot)preferred_axis_attributes(AxisType, args...)The first one to return a non-empty collection gets to set axis attribute defaults.
This pr also cleans up the dispatch for
args_preferred_axis(). Before we hadpreferred_axis_type(::Plot)args_preferred_axis(::Type, args)args_preferred_axis(::Type)args_preferred_axis(args[i])(iterate arguments)args_preferred_axis(::Type, converted)args_preferred_axis(::Type)args_preferred_axis(converted[i])(iterate converted arguments)where the first method not returning
nothingwould set the axis type. We also hadargs_preferred_axis(::AbstractVector, ::AbstractVector, ::AbstractVector, ::Function)as a method which was unreachable.After my changes we now have:
preferred_axis_type(::Plot, input_args...)preferred_axis_type(::Type{<: Plot}, input_args...)preferred_axis_type(::Plot, converted_args...)preferred_axis_type(::Type{<: Plot}, converted_args...)preferred_axis_type(::Plot)preferred_axis_type(::Type{<: Plot})preferred_axis_type(input_args...)preferred_axis_type(converted_args...)preferred_axis_type(arg)for each argumentpreferred_axis_type(converted)for each converted argumentwhere the first valid method still sets the axis type. This is now a different priority order (e.g. args no longer beat plot type + converted). My thoughts here are to prioritize more specific information over less specific information. That way you can have a general "plot -> Axis" and a specific "plot, angle_args, radial_args -> PolarAxis`.
I've also chosen to soft-deprecate
args_preferred_axis, meaning that they are not longer mentioned in docs but still work without errors or warnings. (Eachpreferred_axis_methoddefaults to tryingargs_preferred_axis.) Imopreferred_axis_typeis a better name here, as there are a few methods that don't include args and many that use converted arguments. It also fits more nicely withpreferred_axis_attributes(), though that's a name I chose. (If we want to actually deprecate this I would suggest doing that in breaking 0.25)Closes #5361
Related: #5345, #5205, #1524, #379, #4174
TODO:
Type of change
Delete options that do not apply:
Checklist