Closed casasgomezuribarri closed 2 years ago
This is already the case, as far as I know
p = plot(...) # old plot
p2 = plot(...) # new plot
display(p) # recover the old one
And then, you could explicitly plot!(p, ....)
to modify it
Thanks for the reply, but maybe I didn't explain myself very well. I want to modify plots that I have already saved as .png
files in the past as part of a julia session that is not running anymore (i.e. the variable p
from you example doesn't exist anymore).
Example: Can I remove the legend from this old plot? I made it months ago but forgot to specify leg = false
. However, to build it again from scratch I would have to evaluate the performance of all those models again, which takes time (and energy because MLJ has been updated since then and the code needs a few changes to work).
2 options
Better yet, keep the data in a file and keep the script to plot the graph. This is not something Plots should do
Also check out the hdf5 backend
You cannot modify the final png
. You have to store the intermediate Plots
object.
@isentropic is right this is a Serialization
job:
Session 1
$ julia
julia> using Plots, Serialization
julia> p = plot([1, 2])
julia> serialize("/tmp/foo", p)
Session 2
$ julia
julia> using Plots, Serialization
julia> p = deserialize("/tmp/foo")
julia> Plots.CURRENT_PLOT.nullableplot = p # optionally set the current plot
julia> savefig(p, "/tmp/foo.png")
But keep in mind that this reuses your old data. Keep data separate from the plotting script, and rerun the plotting script on new data when your model has produced new data.
I'm pretty sure this is not possible right now... Please someone correct me if I'm wrong.
It is very annoying to go and check your saved plots from the last session only to realise there is a typo in one of the axis labels, the legend, or the title. It would be great to be able to save the plots in a format that also stores the instructions for creating them, so that they can be retrieved and modified.
I use Julia for data science. A feature like this would allow me, for example, to train several instances of a model saving the coefficient plots for all of them; and then come back later, recover all those plots and superpose them to get an average coefficient plot.