Skip to content

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

@HamsterHuey

Description

@HamsterHuey

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.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions