Best practice for return value of a plotting function?

As many I have plotting functions that combine several matplotlib commands to produce some complex graphs. In my case (plotting of mesh) I draw segments, I put markers, I put text at some places…

What is the best practice for the return value of such a plotting function? Should it return the Axes where the plot occured? A list of all the Artists created? It seems to me that the library tends to lean towards the return of the Artists created but for customized plots such as mine (but I do not think I’m any special here) such a list would be very heterogeneous no?

Hello there

it is important to return the axes object where the plot happened. This method allows extra plot modification and changes following the function call. while sending a list of all the produced artist is a possibility; it can result in a disconnected and difficult list, especially for highly customized plots. returning the axes object preserves simplicity and adaptability because it includes all of the plot parts and can be simply changed and searched for any additional changes required. try it and then let me know about the result :+1: :+1:

1 Like

Thanks, that is the conclusion I came about too myself!