

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to create a line chart using Matplotlib?
To create a line chart using matplotlib, we can take the following steps −
- Set the figure size and adjust the padding between and around the subplots.
- Make lists of years and population growth.
- Plot years and population on the line using plot() method.
- To display the figure, use show() method.
Example
from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True years = [1901, 1911, 1921, 1931, 1941, 1951, 1961, 1971, 1981, 1991, 2001, 2011] population = [237.4, 238.4, 252.09, 251.31, 278.98, 318.66, 361.09, 439.23, 548.16, 683.33, 846.42, 1028.74] plt.plot(years, population, color='red', marker='o') plt.show()
Output
- Related Questions & Answers
- How to create a line chart using JavaFX?
- How to create a Matplotlib bar chart with a threshold line?
- How to create a line chart using ggplot2 with a vertical line in R?
- How to create grouped line chart using ggplotly in R?
- How to create a line chart using ggplot2 with larger width in R?
- How to Create a Diverging Stacked Bar Chart in Matplotlib?
- How to create a 100% stacked Area Chart with Matplotlib?
- How to create a line chart in R using plot function with larger width?
- How to create a line chart using ggplot2 that touches the edge in R?
- How to create a Pie chart using JavaFX?
- How to create a bar chart using JavaFX?
- How to create a bubble chart using JavaFX?
- How to create a scatter chart using JavaFX?
- How to create a stacked bar chart for my DataFrame using Seaborn in Matplotlib?
- How to create line chart using ggplot2 in R with 3-sigma limits?
Advertisements