easyplot icon indicating copy to clipboard operation
easyplot copied to clipboard

`new_plot()` should not mutate existing EasyPlot instance. Instead, create duplicate EasyPlot object

Open HamsterHuey opened this issue 11 years ago • 0 comments

In EasyPlot 1.0.0, the new_plot() instance method mutates the EasyPlot instance on which it is called to create a new plot while retaining plot parameters that were previously set on the EasyPlot instance.

This behavior is not ideal as it forces the user to give up access to an existing EasyPlot object/figure in order to reuse it as a template for another plot. The correct behavior would be for new_plot() to return a new EasyPlot instance that is a duplicate of the EasyPlot instance on which new_plot() is being called. See the code snippet below as an example:

eplot = EasyPlot(x, y, showlegend=True, xlabel='x', ylabel='y',
                 label='plot 1', grid='on')
# Create new EasyPlot object that uses eplot as template
eplot2 = eplot.new_plot(x2, y2) 
# User can choose to overwrite existing EasyPlot instance
eplot = eplot.new_plot(x3,y3) 

This WILL BREAK backwards compatibility Alternate option would be to introduce a new instance method, eg: copy_plot() that produces the behavior mentioned above while retaining the current behaviour of the new_plot() method.

HamsterHuey avatar May 31 '14 05:05 HamsterHuey