Recommended design to include data plotting functions in your library

I have written a small scientific library ( where I use matplotlib to both display the data and to interact with it (via the matplotlib widgets).

So far my design has been based in class inheritance: In most cases the user employs an object based on a child class whose parents include the mathematical opertations, the data reading and the data display…

However, I am not sure this is the best design for the data plotting functions. To my basic python knowledge, there are 2 posible designs I can use:

  1. Inheritance:

My current approach. My data consists mainly in histograms, which can be defined with pairs of x and y arrays. Moreover, there is a data container with information of the histograms. It is very convenient while plotting the data to have access to these attributes. In my current design, my plotting class does not define or assign value to these attributes, however, since the child class inherits all the plotting/data functions I can access them via the self. attribute. I undersant this is a bad design, among other things, because plotting class is worthless by itself.

  1. Composition

In this design, the end-user employs objects which include a plotting object as an attribute. In this design, I can define the x and y attributes for the plotting function which do not conflict with those from the data reading/treating classes. However, I am afraid this will make the experience worse for the end-user or myself. For example, if the end-user wants to plot the last measurement, he has to input the reference or data for the x and y attributes. Otherwise, I have to create an intermediate function between the data workflow to pass current x, y data for every plotting function.

I realize this is not a matplotlib issue but I wonder if anyone would share their approach.