Techno Blender
Digitally Yours.

Data Visualization Using Python. Matplotlib For Beginners | by Ujjwal Dalmia | Oct, 2022

0 63


Matplotlib For Beginners

Photo by Марьян Блан | @marjanblan on Unsplash

While talking to a lot of aspiring analysts/ data scientists, I realized that their only focus/ interest is towards learning predictive models, machine learning algorithms, etc. One important aspect of the data science life cycle that they don’t focus on in the beginning is Data Exploration.

Data Visualization is one of the key tools to effectively explore data. The tutorial aims to introduce the reader to one of the most commonly used visualization libraries in python Matplotlib. We assume that the reader has basic familiarity with python language like Installing Packages, Python Data Structures, Conditions & Loops, and basic know-how on packages like Numpy.

Before we start the tutorial, it is important to understand the structure followed by Matplotlib to make any graph/chart. Referring to the figure below, the outermost container in a Matplotlib graph/chart is called a figure. Each figure can contain one or more axes which are real plots. Each of the axes will have further sub-components like axis (x & y), title, legend, axis labels, major & minor ticks, etc.

Graph/ Chart Structure (Matplotlib Official Documentation)

Matplotlib enables you to construct plots using 2 different interfaces:

  • Using the “pyplot” module
  • Using Object-Oriented interface

In this tutorial, we will primarily work on building knowledge of the “pyplot” module interface. We will further restrict the tutorial to creating the line plots. Other important plots like histograms, scatter, box plots, 2D histograms, etc. will be covered in future tutorials.

Let’s get started with the first plot.

#### Importing the necessary libraries.from matplotlib import pyplot as pltimport numpy as np#### Defining data to be used for plots.x_var = np.random.rand(20)y_var = np.random.rand(20)#### Making the first plotplt.plot(y_var)plt.title("First Plot")plt.show()
First Simple Plot (Image by Author)

C.1 Explaining the first plot

Assuming that the reader is familiar with import statements and the use of the NumPy random module, let’s focus on the code used for plot generation:

  • plt. plot(y_var) — The first statement uses the plot function of the pyplot module to generate the graph. The plot function by default creates a line graph as shown above. You will notice that the tick values on the y-axis are between 0 and 1. This is because the variable being plotted is y_var which contains random values between 0 and 1
  • plt.title(“First Plot”) — The second statement uses the title function with a text argument (in “) to define the title of the plot
  • plt. show()show function of the pyplot module is used to render the plot

As most of you must have noticed, there are a couple of issues with this plot.

  • There are no axis labels
  • The x-axis ticks are shown as decimal numbers. Given we are just constructing a line plot of 20 points, one will expect to see integers (starting from 1 to 20) representing each point number

These issues will be resolved in the next plot

#### Improving the plot.plt.plot(y_var)plt.title("Improved Plot")plt.xlabel("Data Point Number")plt.ylabel("Data Point Value")plt.xticks(range(20), range(1,21))plt.show()
Improved Plot (Image by Author)

C.2 Explaining the Improved Plot

As can be seen, the plot now has axis labels. The tick values on the x-axis now also show the desired values. The explanation of additional lines of codes used to improve the plot is as follows:

  • plt.xlabel(“Data Point Number”) & plt.ylabel(“Data Point Value”) — Both x-label and y-label functions are used to add a label to the x and y-axis. The functions take text (in “”) values as arguments to use them as labels
  • plt. xticks(range(20), range(1,21)) — The x-ticks function has taken 2 arguments, the first argument is the position of the x-axis where the ticks are to be placed whereas the second argument is for defining the labels to be used for ticks. If the second argument is missing, the position values generated using the first argument are used as default labels

Now that we have all the basic issues sorted let us work on the aesthetics of the graph

#### Beautificationplt.plot(y_var, color = "green", marker = "o",linestyle = '--', label = "y Variable")plt.title("Final Plot")plt.xlabel("Data Point Number")plt.ylabel("Data Point Value")plt.xticks(range(20), range(1,21))plt.legend()plt.show()
Line Plot post Beautification (Image by Author)

C.3 Explaining the Final Plot

The plot post-visual improvements look much better. It has marker points, a dashed line style, and legends available. The details of the additional code block used to generate the above plot are as follows:

  • plt.plot(y_var, color = “green”, marker = “o”,linestyle = ‘- -‘, label = “Introductory Plot”) — Rather than using plain vanilla plot, we are now passing few more attributes to the same function. The explanation of these attributes is as follows:
  1. color — used to define the color of the line (green in this case)
  2. marker — used to define the data marker to be used (the dark highlighted dots in this case represented by “o”)
  3. linestyle — used to define the type of line to be generated (dashed in the case represented by “- -“)
  4. label — defining a label is a must if someone wants to have a legend. The value assigned to the label attribute is shown as a legend
  • plt. legend — This code block ensures the presence of a legend in the plot. As mentioned earlier, the legend function uses the label argument of the plot function to define the legend. In case the label argument is missing, the legend will appear but with only the color of the plot and without any plot explanation

The only missing piece in the above plot now is to show the values of data points on the plot. Let’s include that

#### Showing the data point values using annotateplt.plot(y_var, color = "green", marker = "o",linestyle = '--', label = "y variable")plt.title("Final Plot With Data Labels")plt.xlabel("Data Point Number")plt.ylabel("Data Point Value")plt.xticks(range(20), range(1,21))for i in range(len(y_var)):plt.annotate(round(y_var[i],1), xy = [i-.5,y_var[i]+.01])plt.legend()plt.show()
Annotating the Data Labels (Image by Author)

C.4 Explaining Final Plot With Data Labels

The only difference between the last code block and the one used to generate data points is the Annotate function. It is a one-stop solution to display any text on the plot. In this case, the annotate function is used to display the data point values. The details of annotate function are as follows:

  • First Argument — The first argument (round(y_var[i],1) in our case) captures the text we want to display on the graph. In our case, we are just taking the respective value of y_var and rounding it off to single digit
  • Second Argument (XY) — The argument takes the x and y coordinates of the graph (in the form of a list) where the text from the first argument needs to be annotated

Note that the annotate function can only print 1 value at a time and therefore in our case it is used in a loop as we had to print the data point values of 20 different points.

The above code block completes the construction of line graphs. Let us now look at how can we create multiple line plots in the same graph

#### Multiple trend lines in the same plot.plt.plot(y_var, color = "red", marker = "o",linestyle = '--', label = "Plot 1")plt.plot(x_var, color = "black", marker = "o",linestyle = '-', label = "Plot 2")plt.title("Multiple Line Plots")plt.xlabel("Data Point Number")plt.ylabel("Data Point Value")plt.xticks(range(20), range(1,21))plt.legend(loc = [.8,.01])plt.show()
Multiple Trends (Image by Author)

D.1 Explaining Multiple Line Plots

The graph above plots multiple lines on the same graph. The only difference between the code block of single-line and multi-line plots is that to create multiple lines, we have used multiple plt. plot function. Please note that each function is responsible for its style and formatting.

Another noticeable difference in the above code block is the plt. legend function. The loc attribute of the legend function takes the x and y coordinates of the graph (in the form of a list) where the legend needs to be placed. The first value is the distance of the legend from the bottom left corner of the plot in the right direction & second value is the distance of the legend from the bottom left in an upward direction

Further variations in the construction of graphs are to have different graphs for different trend lines. This can be done as follows:

#### Making 2 plots side by side using axes function#### First plotplt.axes([.05,.05,.425,.8])plt.plot(y_var, color = "red", marker = "o",linestyle = '--', label = "Plot 1")plt.title("First Plot")plt.xlabel("Data Point Number")plt.ylabel("Data Point Value")plt.legend()plt.xticks(range(20), range(1,21))#### Second Plotplt.axes([.525,.05,.425,.8])plt.plot(x_var, color = "black", marker = "o",linestyle = '-', label = "Plot 2")plt.title("Second Plot")plt.xlabel("Data Point Number")plt.ylabel("Data Point Value")plt.xticks(range(20), range(1,21))plt.legend()plt.show()
Side by Side Plots (Image by Author)

D.2 Explaining the multiple graphs scenario

As you can see, we have created 2 plots side by side by using the axes function. What does this function do?

Every Axes function creates a new axes container for a user to construct the graph. The function expects 4 values provided in the form of a list to define the position and size of the container. These 4 values are

  • 1st Value — Bottom Left Corner X Coordinate
  • 2nd Value — Bottom Left Corner Y Coordinate
  • 3rd Value — Width of the plot
  • 4th Value — Height of the plot

A few points to note:

  • The use of the axes function leads to the generation of a new axes container and hence all the graphical functions used after the axes function are applied to the new plot only. In our code block, notice that after every axes function we have repeated all the plot, legend, and label statements
  • The Axes function only creates the new axes container and not the new figure container. This means all the plots created using the axes function are part of the same figure
  • One can keep on repeating the axes function with different coordinates and can include multiple plots within the same figure container

You must have noticed that the axis labels of the second plot have overlapped with the first plot and hence drawing multiple plots like this becomes tedious as this would require a strong judgment of X & Y coordinates. This problem can be addressed using another function: Subplot. Let’s have a look

#### Making 2 plots side by side using Subplot function#### First Plotplt.subplot(1,2,1)plt.plot(y_var, color = "red", marker = "o",linestyle = '--', label = "Plot 1")plt.title("First Plot")plt.xlabel("Data Point Number")plt.ylabel("Data Point Value")plt.xticks(range(20), range(1,21))#### Second Plotplt.subplot(1,2,2)plt.plot(x_var, color = "black", marker = "o",linestyle = '-', label = "Plot 2")plt.title("Second Plot")plt.xlabel("Data Point Number")plt.ylabel("Data Point Value")plt.xticks(range(20), range(1,21))#### Avoiding the plot overlapsplt.tight_layout()plt.show()
Tight Layout (Image by Author)

D.3 Explaining the Side By Side Plot Without Overlaps

As can be seen, the plots don’t overlap now. This is made possible using the subplot function and tight_layout function together. Details of the above block of code are as follows:

  • plt. subplot(1,2,2) — The subplot function does the same job as axes with the only difference that depending upon the number of graphs to be created, the graph positions are automatically adjusted. The subplot function takes 3 arguments:
  1. The first argument defines the number of plots we need in rows
  2. The second argument defines the number of plots we need in columns
  3. The third argument is the plot number that you are creating. Please note that the numbering of plots moves from left to right and from top to bottom for example in the case of 2 X 2 plots, the top left plot will be number 1 and the bottom right plot will be number 4
  • plt.tight_layout()tight_layout function ensures that the multiple plots have the right size so that there is no overlap among the plots. Please note that the tight_layout function can only be used when the subplot function is used

One must have noticed that though we have overcome the problem of plot overlaps, the overall figure size remains small. As we will continue to draw more plots using subplots, the actual plot size will keep on reducing. To overcome this challenge, we need some flexibility to modify the figure container of the matplotlib structure. Let’s do it now

#### Changing the figure size to change the size of overall plot#### Changing the size of the figureplt.figure(figsize=(14,3))#### First Plotplt.subplot(1,2,1)plt.plot(y_var, color = "red", marker = "o",linestyle = '--', label = "Plot 1")plt.title("First Plot")plt.xlabel("Data Point Number")plt.ylabel("Data Point Value")plt.xticks(range(20), range(1,21))#### Second Plotplt.subplot(1,2,2)plt.plot(x_var, color = "black", marker = "o",linestyle = '-', label = "Plot 2")plt.title("Second Plot")plt.xlabel("Data Point Number")plt.ylabel("Data Point Value")plt.xticks(range(20), range(1,21))#### Avoiding the plot overlapsplt.tight_layout()plt.show()
Modified Figure Container (Image by Author)

D.4 Explaining the Plot

As you can see, the figure function helped us to change the size of the plot. The figure size attribute passed to the figure function takes a tuple of values where the first value is the width and the second is the height. Using this the figure size is changed and the plots now look much better

In this tutorial, we used multiple functions of matplotlib.pyplot module. A one-liner summary of each of them and the link to their formal matplotlib documentation page is given below for your reference.

  • plt. figure — Used to create a figure container with custom requirements like figure size. Link to matplotlib documentation
  • plt. subplot — Used to create multiple plots within the same figure container. Link to matplotlib documentation
  • plt.tight_layout — To be used with plt. subplot function. Ensures that the multiple axes plots adjust themselves. Link to matplotlib documentation
  • plt. axes — Used to create multiple axes containers. Link to matplotlib documentation
  • plt. plot — Used to create the line plot. Link to matplotlib documentation
  • plt. title — Used to add a title to any plot. Link to matplotlib documentation
  • plt. xlabel — Used to add labels to the x-axis in any plot. Link to matplotlib documentation
  • plt. ylabel — Used to add labels to the y-axis in any plot. Link to matplotlib documentation
  • plt. xticks — Used to add ticks to the x-axis of any plot. Link to matplotlib documentation
  • plt. annotate — Used to add text to any part of the plot. Link to matplotlib documentation


Matplotlib For Beginners

Photo by Марьян Блан | @marjanblan on Unsplash

While talking to a lot of aspiring analysts/ data scientists, I realized that their only focus/ interest is towards learning predictive models, machine learning algorithms, etc. One important aspect of the data science life cycle that they don’t focus on in the beginning is Data Exploration.

Data Visualization is one of the key tools to effectively explore data. The tutorial aims to introduce the reader to one of the most commonly used visualization libraries in python Matplotlib. We assume that the reader has basic familiarity with python language like Installing Packages, Python Data Structures, Conditions & Loops, and basic know-how on packages like Numpy.

Before we start the tutorial, it is important to understand the structure followed by Matplotlib to make any graph/chart. Referring to the figure below, the outermost container in a Matplotlib graph/chart is called a figure. Each figure can contain one or more axes which are real plots. Each of the axes will have further sub-components like axis (x & y), title, legend, axis labels, major & minor ticks, etc.

Graph/ Chart Structure (Matplotlib Official Documentation)

Matplotlib enables you to construct plots using 2 different interfaces:

  • Using the “pyplot” module
  • Using Object-Oriented interface

In this tutorial, we will primarily work on building knowledge of the “pyplot” module interface. We will further restrict the tutorial to creating the line plots. Other important plots like histograms, scatter, box plots, 2D histograms, etc. will be covered in future tutorials.

Let’s get started with the first plot.

#### Importing the necessary libraries.from matplotlib import pyplot as pltimport numpy as np#### Defining data to be used for plots.x_var = np.random.rand(20)y_var = np.random.rand(20)#### Making the first plotplt.plot(y_var)plt.title("First Plot")plt.show()
First Simple Plot (Image by Author)

C.1 Explaining the first plot

Assuming that the reader is familiar with import statements and the use of the NumPy random module, let’s focus on the code used for plot generation:

  • plt. plot(y_var) — The first statement uses the plot function of the pyplot module to generate the graph. The plot function by default creates a line graph as shown above. You will notice that the tick values on the y-axis are between 0 and 1. This is because the variable being plotted is y_var which contains random values between 0 and 1
  • plt.title(“First Plot”) — The second statement uses the title function with a text argument (in “) to define the title of the plot
  • plt. show()show function of the pyplot module is used to render the plot

As most of you must have noticed, there are a couple of issues with this plot.

  • There are no axis labels
  • The x-axis ticks are shown as decimal numbers. Given we are just constructing a line plot of 20 points, one will expect to see integers (starting from 1 to 20) representing each point number

These issues will be resolved in the next plot

#### Improving the plot.plt.plot(y_var)plt.title("Improved Plot")plt.xlabel("Data Point Number")plt.ylabel("Data Point Value")plt.xticks(range(20), range(1,21))plt.show()
Improved Plot (Image by Author)

C.2 Explaining the Improved Plot

As can be seen, the plot now has axis labels. The tick values on the x-axis now also show the desired values. The explanation of additional lines of codes used to improve the plot is as follows:

  • plt.xlabel(“Data Point Number”) & plt.ylabel(“Data Point Value”) — Both x-label and y-label functions are used to add a label to the x and y-axis. The functions take text (in “”) values as arguments to use them as labels
  • plt. xticks(range(20), range(1,21)) — The x-ticks function has taken 2 arguments, the first argument is the position of the x-axis where the ticks are to be placed whereas the second argument is for defining the labels to be used for ticks. If the second argument is missing, the position values generated using the first argument are used as default labels

Now that we have all the basic issues sorted let us work on the aesthetics of the graph

#### Beautificationplt.plot(y_var, color = "green", marker = "o",linestyle = '--', label = "y Variable")plt.title("Final Plot")plt.xlabel("Data Point Number")plt.ylabel("Data Point Value")plt.xticks(range(20), range(1,21))plt.legend()plt.show()
Line Plot post Beautification (Image by Author)

C.3 Explaining the Final Plot

The plot post-visual improvements look much better. It has marker points, a dashed line style, and legends available. The details of the additional code block used to generate the above plot are as follows:

  • plt.plot(y_var, color = “green”, marker = “o”,linestyle = ‘- -‘, label = “Introductory Plot”) — Rather than using plain vanilla plot, we are now passing few more attributes to the same function. The explanation of these attributes is as follows:
  1. color — used to define the color of the line (green in this case)
  2. marker — used to define the data marker to be used (the dark highlighted dots in this case represented by “o”)
  3. linestyle — used to define the type of line to be generated (dashed in the case represented by “- -“)
  4. label — defining a label is a must if someone wants to have a legend. The value assigned to the label attribute is shown as a legend
  • plt. legend — This code block ensures the presence of a legend in the plot. As mentioned earlier, the legend function uses the label argument of the plot function to define the legend. In case the label argument is missing, the legend will appear but with only the color of the plot and without any plot explanation

The only missing piece in the above plot now is to show the values of data points on the plot. Let’s include that

#### Showing the data point values using annotateplt.plot(y_var, color = "green", marker = "o",linestyle = '--', label = "y variable")plt.title("Final Plot With Data Labels")plt.xlabel("Data Point Number")plt.ylabel("Data Point Value")plt.xticks(range(20), range(1,21))for i in range(len(y_var)):plt.annotate(round(y_var[i],1), xy = [i-.5,y_var[i]+.01])plt.legend()plt.show()
Annotating the Data Labels (Image by Author)

C.4 Explaining Final Plot With Data Labels

The only difference between the last code block and the one used to generate data points is the Annotate function. It is a one-stop solution to display any text on the plot. In this case, the annotate function is used to display the data point values. The details of annotate function are as follows:

  • First Argument — The first argument (round(y_var[i],1) in our case) captures the text we want to display on the graph. In our case, we are just taking the respective value of y_var and rounding it off to single digit
  • Second Argument (XY) — The argument takes the x and y coordinates of the graph (in the form of a list) where the text from the first argument needs to be annotated

Note that the annotate function can only print 1 value at a time and therefore in our case it is used in a loop as we had to print the data point values of 20 different points.

The above code block completes the construction of line graphs. Let us now look at how can we create multiple line plots in the same graph

#### Multiple trend lines in the same plot.plt.plot(y_var, color = "red", marker = "o",linestyle = '--', label = "Plot 1")plt.plot(x_var, color = "black", marker = "o",linestyle = '-', label = "Plot 2")plt.title("Multiple Line Plots")plt.xlabel("Data Point Number")plt.ylabel("Data Point Value")plt.xticks(range(20), range(1,21))plt.legend(loc = [.8,.01])plt.show()
Multiple Trends (Image by Author)

D.1 Explaining Multiple Line Plots

The graph above plots multiple lines on the same graph. The only difference between the code block of single-line and multi-line plots is that to create multiple lines, we have used multiple plt. plot function. Please note that each function is responsible for its style and formatting.

Another noticeable difference in the above code block is the plt. legend function. The loc attribute of the legend function takes the x and y coordinates of the graph (in the form of a list) where the legend needs to be placed. The first value is the distance of the legend from the bottom left corner of the plot in the right direction & second value is the distance of the legend from the bottom left in an upward direction

Further variations in the construction of graphs are to have different graphs for different trend lines. This can be done as follows:

#### Making 2 plots side by side using axes function#### First plotplt.axes([.05,.05,.425,.8])plt.plot(y_var, color = "red", marker = "o",linestyle = '--', label = "Plot 1")plt.title("First Plot")plt.xlabel("Data Point Number")plt.ylabel("Data Point Value")plt.legend()plt.xticks(range(20), range(1,21))#### Second Plotplt.axes([.525,.05,.425,.8])plt.plot(x_var, color = "black", marker = "o",linestyle = '-', label = "Plot 2")plt.title("Second Plot")plt.xlabel("Data Point Number")plt.ylabel("Data Point Value")plt.xticks(range(20), range(1,21))plt.legend()plt.show()
Side by Side Plots (Image by Author)

D.2 Explaining the multiple graphs scenario

As you can see, we have created 2 plots side by side by using the axes function. What does this function do?

Every Axes function creates a new axes container for a user to construct the graph. The function expects 4 values provided in the form of a list to define the position and size of the container. These 4 values are

  • 1st Value — Bottom Left Corner X Coordinate
  • 2nd Value — Bottom Left Corner Y Coordinate
  • 3rd Value — Width of the plot
  • 4th Value — Height of the plot

A few points to note:

  • The use of the axes function leads to the generation of a new axes container and hence all the graphical functions used after the axes function are applied to the new plot only. In our code block, notice that after every axes function we have repeated all the plot, legend, and label statements
  • The Axes function only creates the new axes container and not the new figure container. This means all the plots created using the axes function are part of the same figure
  • One can keep on repeating the axes function with different coordinates and can include multiple plots within the same figure container

You must have noticed that the axis labels of the second plot have overlapped with the first plot and hence drawing multiple plots like this becomes tedious as this would require a strong judgment of X & Y coordinates. This problem can be addressed using another function: Subplot. Let’s have a look

#### Making 2 plots side by side using Subplot function#### First Plotplt.subplot(1,2,1)plt.plot(y_var, color = "red", marker = "o",linestyle = '--', label = "Plot 1")plt.title("First Plot")plt.xlabel("Data Point Number")plt.ylabel("Data Point Value")plt.xticks(range(20), range(1,21))#### Second Plotplt.subplot(1,2,2)plt.plot(x_var, color = "black", marker = "o",linestyle = '-', label = "Plot 2")plt.title("Second Plot")plt.xlabel("Data Point Number")plt.ylabel("Data Point Value")plt.xticks(range(20), range(1,21))#### Avoiding the plot overlapsplt.tight_layout()plt.show()
Tight Layout (Image by Author)

D.3 Explaining the Side By Side Plot Without Overlaps

As can be seen, the plots don’t overlap now. This is made possible using the subplot function and tight_layout function together. Details of the above block of code are as follows:

  • plt. subplot(1,2,2) — The subplot function does the same job as axes with the only difference that depending upon the number of graphs to be created, the graph positions are automatically adjusted. The subplot function takes 3 arguments:
  1. The first argument defines the number of plots we need in rows
  2. The second argument defines the number of plots we need in columns
  3. The third argument is the plot number that you are creating. Please note that the numbering of plots moves from left to right and from top to bottom for example in the case of 2 X 2 plots, the top left plot will be number 1 and the bottom right plot will be number 4
  • plt.tight_layout()tight_layout function ensures that the multiple plots have the right size so that there is no overlap among the plots. Please note that the tight_layout function can only be used when the subplot function is used

One must have noticed that though we have overcome the problem of plot overlaps, the overall figure size remains small. As we will continue to draw more plots using subplots, the actual plot size will keep on reducing. To overcome this challenge, we need some flexibility to modify the figure container of the matplotlib structure. Let’s do it now

#### Changing the figure size to change the size of overall plot#### Changing the size of the figureplt.figure(figsize=(14,3))#### First Plotplt.subplot(1,2,1)plt.plot(y_var, color = "red", marker = "o",linestyle = '--', label = "Plot 1")plt.title("First Plot")plt.xlabel("Data Point Number")plt.ylabel("Data Point Value")plt.xticks(range(20), range(1,21))#### Second Plotplt.subplot(1,2,2)plt.plot(x_var, color = "black", marker = "o",linestyle = '-', label = "Plot 2")plt.title("Second Plot")plt.xlabel("Data Point Number")plt.ylabel("Data Point Value")plt.xticks(range(20), range(1,21))#### Avoiding the plot overlapsplt.tight_layout()plt.show()
Modified Figure Container (Image by Author)

D.4 Explaining the Plot

As you can see, the figure function helped us to change the size of the plot. The figure size attribute passed to the figure function takes a tuple of values where the first value is the width and the second is the height. Using this the figure size is changed and the plots now look much better

In this tutorial, we used multiple functions of matplotlib.pyplot module. A one-liner summary of each of them and the link to their formal matplotlib documentation page is given below for your reference.

  • plt. figure — Used to create a figure container with custom requirements like figure size. Link to matplotlib documentation
  • plt. subplot — Used to create multiple plots within the same figure container. Link to matplotlib documentation
  • plt.tight_layout — To be used with plt. subplot function. Ensures that the multiple axes plots adjust themselves. Link to matplotlib documentation
  • plt. axes — Used to create multiple axes containers. Link to matplotlib documentation
  • plt. plot — Used to create the line plot. Link to matplotlib documentation
  • plt. title — Used to add a title to any plot. Link to matplotlib documentation
  • plt. xlabel — Used to add labels to the x-axis in any plot. Link to matplotlib documentation
  • plt. ylabel — Used to add labels to the y-axis in any plot. Link to matplotlib documentation
  • plt. xticks — Used to add ticks to the x-axis of any plot. Link to matplotlib documentation
  • plt. annotate — Used to add text to any part of the plot. Link to matplotlib documentation

FOLLOW US ON GOOGLE NEWS

Read original article here

Denial of responsibility! Techno Blender is an automatic aggregator of the all world’s media. In each content, the hyperlink to the primary source is specified. All trademarks belong to their rightful owners, all materials to their authors. If you are the owner of the content and do not want us to publish your materials, please contact us by email – [email protected]. The content will be deleted within 24 hours.

Leave a comment