I have a pre-existing figure with multiple curves and an existing label vector. I need to change the labels - probably using the plot! command - but I am not able to do it. I don’t think this is not a row vector label issue.
I am using Plots package and the GR backend (although I found the same issue using PyPlot). Julia version 1.5.3.
fig = plot(1:5, rand(5,2), label=[“A” “B”])
plot!(fig, label = [“C” “D”] )
The last command fails to change labels to C and D. I also tried using labels instead of label, no success.
My apologies if this is a trivial question!
I think you will need to dig into the plot object
fig. In an interactive environment like the REPL you can use
fig.<TAB> and then keep going down until you find where the actual strings are stored inside and change them.
Or just use the correct labels to start with
@dpsanders, that is nice to know.
Plots.jl does not seem to listen to changes made to the plot attributes and any plot update seems to require displaying the whole shebang. So it might be pointless to try partial plot updates.
This can be tested in a plot with thousands of points:
using Plots; gr()
fig = plot(1:2_000, rand(2_000,2), label=["A" "B"])
fig.series_list[:label] = "C"
fig.series_list[:label] = "D"
SmoothLivePlot.jl implements this key capability by using Observables.jl and WebIO.jl but did not try it to confirm whether it solves the problem above.