JuliaPlots / Plots.jl

Powerful convenience for Julia visualizations and data analysis
https://docs.juliaplots.org
Other
1.84k stars 354 forks source link

[FR] Way to modify series labels after plot creation. #2851

Open nathanrboyer opened 4 years ago

nathanrboyer commented 4 years ago

Currently labels have to be added at the same time the series data is plotted. Other attributes like titles and axis labels can be added and modified after the fact. I would like to be able to add and modify the legend after plot creation also.

Ideally, this would be done in the same way as other attributes like plot!(labels=stringarrayoflabels), but a new function like labels!(stringarrayoflabels) could work too.

This would be most helpful to me when a plot is created within a function, but I want to be able to pretty it up outside of the function to avoid passing a lot of variables back and forth.

BeastyBlacksmith commented 4 years ago

There is no official API, but you can already do this via

p = plot(1:5)
p[1][1][:label] = "label"
p
singularitti commented 1 year ago

Is #2880 supposed to work? The proposed method does not work for me.

BeastyBlacksmith commented 1 year ago

Is #2880 supposed to work? The proposed method does not work for me.

That only worked for some cases, but not in general.