Learn Python

Learn Data Structure & Algorithm

Learn Numpy

Learn Pandas

Matplotlib Introduction

Matplotlib Bar Plot

Matplotlib Pie Chart

Matplotlib Hist Plot

Matplotlib Line Plot

Matplotlib Scatter Plot

Matplotlib Subplot

Matplotlib Save image

Learn Seaborn

Learn Statistics

Learn Math

Learn MATLAB

Learn Machine learning

Learn Github

Learn OpenCV

Learn Deep Learning

Learn MySQL

Learn MongoDB

Learn Web scraping

Learn Excel

Learn Power BI

Learn Tableau

Learn Docker

Learn Hadoop

Matplotlib line plot

What is a line plot?

It's connect the data point through a line so it display the data as a line. For visualizing continuous data line plots are commonly used.

How to create a line plot?

To create line plot write module_name.plot().In the bracket pass parameters.

Some mandatory parameters:

The first parameter is for the x-axis. Here we pass variable names where we stored values for creating line plot.

The first parameter is for the y-axis. Here we pass variable names where we stored values for creating line plot.

Some other parameters:

colors="colors name ".Used to give colors of bars.Color name, RGB color, hex color, etc.

markers="o etc". Used to set markers.o,^,* etc

markersize=2,3,4,5 etc. Used to set marker size.

linewidth=1,2,3 etc. Used to set bars borders width.

linestyle=":,--,-.,- etc". Used to set bars borders line style.

How to give title,labels,legend,grid?
Title
For title write module_name.title().
In the bracket write the title as a string. For font size write fontsize:value . Between title name and font size parameter give a coma.

xlabel
For label at x-axis write module_name.ylabel().
In the bracket write the label name as a string. For font size write fontsize:value. Between label name and font size parameter give a coma.

ylabel
For the label at the y-axis write module_name. ylabel().
In the bracket write the label name as a string. For font size write fontsize:value. Between label name and font size parameter give a coma.

legend
If there are multiple bars and every bar defines different things, then you should use the legend to give a name for each bar so that you can understand which bar is for why.To give legend first write module_name.legend().Pass all the names as a list in the bracket. To set the position use the loc parameter. You can give the value of the loc parameter between 0 to 3

grid
For grid first write module_name.grid().
Some parameters of the grid are
1.color: used to set the color of the grid.Example: color="green".
2.linestyle: used to set grid line style.Example: linestyle="--".
3.linewidth: used to set line width of the grid.example: linewidth=2.

Input
import matplotlib.pyplot as plt
value1=[40,45,67,78,90]
value2=[55,70,81,88,100]
plt.plot(value1,value2,color="red",marker="o",linewidth="2.7",linestyle=":",markersize="5")
plt.title("Histogram for practise")
plt.ll("x axis value")
plt.ylabel("y axis value")
plt.grid(color="red",linewidth=2,linestyle=":")
plt.legend(["value1","value2"])
plt.show()

CodersAim is created for learning and training a self learner to become a professional from beginner. While using CodersAim, you agree to have read and accepted our terms of use, privacy policy, Contact Us

© Copyright All rights reserved www.CodersAim.com. Developed by CodersAim.