Plotting graph

Plotting graph:

To Plotting graph of the given function:

In this section, we will discuss how to plotting graph for various functions. It includes various functions like how to plot n-array, the graph of sin function, plotting of cos function, plotting of absolute function, exponential function, logarithm function, a graph of 1/ax+b the graph of a parabola, hyperbola and ellipse and plot surface of a parabola, hyperbola and ellipse function in python.

we will study each of the function code with output. If we talk about plotting graph in python Programming then we plot using matplotlib. so first we read about the matplotlib, you can also check Python Libraries tutorial to learn how to use matplotlib in Python.

What is Python Matplotlib?

Matplotlib allows you to plot charts, histograms, scatter graphs, etc to non-Cartesian coordinates graphs. It integrates with other Python shells and runtime shells such as Jupyter Notebook. 

You can display the results of your work in a visually compelling manner. Data visualization helps you to better understand your data, discover things that you wouldn’t discover in raw format and communicate your findings more efficiently to others.

matplotlib.pyplot is a plotting library used for 2D pics in the python programming language. It can be used in python scripts, shell, net software servers, and other graphical person interface toolkits. 

There are a number of toolkits that are available that extend python matplotlib functionality. Some of them are separate downloads, others can be shipped with the matplotlib supply code but have external dependencies. 

The most popular plotting library in python is Matplotlib. By using matplotlib library, we can create pretty much any type of plot. However, as the plots get more complex, the learning curve can get steeper. In this, we understand ‘how plotting with matplotlib works’ and make you comfortable to build full-featured plots with matplotlib.

  • Basemap: It is a map plotting toolkit with a number of map projections, coastlines and political boundaries.
  • Cartopy: It's a mapping library offering object-oriented projection definitions, and arbitrary point, line, polygon and photograph transformation capabilities.
  • Excel tools: Matplotlib affords utilities for changing statistics with Microsoft Excel.
  • Mplot3d: It is used for 3-D plots.
  • Natgrid: It is an interface for irregular gridding of the spaced data.
The following piece of code is discovered in rather an awful lot any python code that has matplotlib plots.

import matplotlib.pyplot as plt

%matplotlib inline

matplotlib.pyplot is commonly imported as plt. It is the core object that incorporates the methods to create all kinds of charts and aspects in a plot.

Suppose you desire to draw a unique type of plot, say a scatterplot, the first thing you want to test out is the techniques beneath plt (type plt and hit tab or kind dir(plt) in python prompt).

In this section, we learn how to plot elements of an array, to plot sine function, to plot cosine function, to plot absolute function, to plot exponential function, to plot the logarithm of a function, to plot the graph of a parabola, hyperbola, and ellipse, to plot the surface of revolution of the curve of parabola, hyperbola, and ellipse function in detail with code and output.

The list of these functions are given below: