This question was posted in other forum: https://discourse.julialang.org/t/plot-a-graph-with-specific-sub-labels/68491
I need plot something with a particular axis labels. More specifically, sub-labels.
First, I'm gointo to plot the standar plot:
tg = 0:0.001:0.7
points = rand(size(tg)[1])
sublabels = fill("Julia", size(tg)[1] )
tab = [tg points]
sublabels[ tab[:,1] .<= 0.2 ] .= "A"
sublabels[ 0.2 .< tab[:,1] .<= 0.6 ] .= "B"
sublabels[ 0.6 .< tab[:,1] .<= 0.7 ] .= "C"
tab = [tab sublabels]
plot(tab[:,1], tab[:,2], xlabel = "tax")
I would like to keep this graph and add these sub labels according to the last column of the matrix tab. The limits of these ranges must be highlighted. I would also like to keep the main "tax" label.
Some help?
Copy-paste of my answer on discourse:
A hacky solution is
xlims = (-0.05, 0.75)
plot(tab[:,1], tab[:,2]; xlabel="tax", xticks=[0.0, 0.2, 0.6, 0.7], xlims)
plot!([NaN], [NaN]; label="", yticks=[],
xticks=([0.1, 0.4, 0.65], ["A", "B", "C"]), tick_direction=:none,
grid=:none,
inset = (1, bbox(0.0, 0.0, 1.0, 1.0, :bottom, :right)),
subplot = 2,
bg_inside = nothing, xlims
)
and gives