Matplotlib: Object-oriented Interface

Matplotlib is a great data visualization library for Python. Matplotlib can be used in two ways:

  • The functional interface allows us to be  create small plots. 
  • This object-oriented approach is the recommended API in most data visualization scenario.

The object oriented interface give us more control when we create figure that contains multiple plots. It makes it more easier. This helps in knowing how matplotlib structures its plot.

It is used to create figure objects and then just call methods or attributes off of that object. It helps us in better dealing with multiple plot. Here the figure object can be compared to canvas, which different artists act to create the final graphic image.

It is very easy and quick to genterate plots with  matplotlib.pyplot module. The use of object-oriented is  recommended as it can give more control and customization to the plot.

In object-oriented interface, Pyplot module is used for creating figures, it also helps in keeping the track on the figure and axes objects. Here the user tries Pyplot to create figures, and through those figures, one or more axes objects can be created.

It is a better apporach when there is need of multiple plot on the canvas.

In this we use Pyplot to create figure and by using these figures one or more axes objects can be created.

This interface can be accessed so easily that it allow us to reuse its objects and matplotlib is internally used this object-oriented interface.