nansat
nansat copied to clipboard
nansat.figure.Figure should have a method to return a legend/colorbar as a separate image
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.
Added 'image' option in a8660ed. If 'image' = False and 'legend' = True, Figure.create_pilImage() returns only legend/colorbar.
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.
Made a new function fig.get_legend() in 9f04c63 and the test is modified in 0712687. Fixed.