Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign up[DOC] Adding custom labels to axis ticks, and displaying only specific ticks. #551
Comments
|
In pyplot this is simply |
scene = plot(..., ticks = (ranges = ([0, 1], [0, 1]), labels = (["a", "b"], ["a", "b"])))should be possible to pass a node to ranges/labels a la |
|
Your suggestion doesn't work even without
|
|
Here is the code that does what I want:
But unfortunately doesn't work with observables at the moment. That would be cool though!
gives
|
|
Yeah, that's not how you'd use observables... You need to pass the observables to the plotting function... xlab = Observable(["A", "B"])
on(xlab) do xlab
w[Axis][:ticks][:labels] = (xlab, xlab)
end |
|
Alright, this is satisfactory for me. Could you please put a "documentation" label on this one? Seems useful enough to be in the docs. |
|
By the way this is in my opinion the preferred option: using Makie
ranges = Node(([0, 1], [0, 1]))
labels = Node((["a", "b"], ["a", "b"]))
function to_limits(lims)
xy = (lims[1][1], lims[2][1])
xymax = (lims[1][2], lims[2][2])
FRect(xy, xymax .- xy)
end
w = scatter(
rand(10), rand(10),
axis = (
ticks = (
ranges = ranges,
labels = labels
),
),
limits = lift(to_limits, ranges) # really unfortunate we
)
TODO: automatically calculate limits from the ranges instead of the data + have limits work with the |
|
To set alignment: w[Axis][:ticks][:align] = ((:center, :top), (:right, :center)) |


I have a plot. This plot has axis. These axis have ticks and the ticks have labels.
I have a label
"A"and"B"and what I want is to make my axis instead of having numerous ticks and labels to have only ticks at the start and end. And the ticks to be"A"and"B"instead of 0 and 1 or 0.1552151 and 0.1556660. Or any custom string instead of A.Can I do this, and if yes how?
EDIT: Solved, now needs to be documented.
For specific ticks, e.g.
and for specific tick labels, e.g.
(notice that ticks and labels must have same length)
you can also use observables, e.g.