nansat icon indicating copy to clipboard operation
nansat copied to clipboard

nansat.figure.Figure should have a method to return a legend/colorbar as a separate image

Open mortenwh opened this issue 10 years ago • 3 comments

The Figure.create_legend adds a legend to the figure by increasing the figure size and adding the legend to the actual figure. There should be a method that just returns a legend as a separate image which can then be added to the actual figure or used separately.

mortenwh avatar Oct 30 '14 11:10 mortenwh

Added 'image' option in a8660ed. If 'image' = False and 'legend' = True, Figure.create_pilImage() returns only legend/colorbar.

asumak avatar Jan 23 '15 16:01 asumak

I don't like the way you're just adding a new option to the function. I asked for a new function that simply returns the legend - this will provide much clearer functionality than how it is now with a lot of different options and corresponding if-tests in the __init__-function.

As a general rule: splitting the code into sections where each function serves one clearly defined purpose will make the code much more comprehensible.

mortenwh avatar Mar 05 '15 11:03 mortenwh

Made a new function fig.get_legend() in 9f04c63 and the test is modified in 0712687. Fixed.

asumak avatar Apr 01 '15 08:04 asumak