- Trending Categories
- Data Structure
- Operating System
- C Programming
- 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 generate statistical graphs using Python?
Python has an amazing graph plotting library called matplotlib. It is the most popular graphing and data visualization module for Python. You can start plotting graphs using 3 lines! For example,
from matplotlib import pyplot as plt # Plot to canvas plt.plot([1,2,3],[4,5,1]) #Showing what we plotted plt.show()
This will create a simple graph with coordinates (1,4), (2,5) and (3,1). You can Assign labels to the axes using the xlabel and ylabel functions. For example,
plt.ylabel('Y axis') plt.xlabel('X axis')
And also provide a title using the title function −
Remember to call these before the show() call as it will render these only if called before show. You can also style these graphs by providing arguments like linewidth=2 to the plt.plot function. You can also use the legend() function to create a legend:
There are many types of charts like bar graph, scatterplots, pie chart, etc. available. You can learn more about these on https://pythonprogramming.net/matplotlib-python-3-basics-tutorial/
- How can Bokeh library be used to generate line graphs in Python?
- How to plot 3D graphs using Python Matplotlib?
- How to generate XML using Python?
- How to generate random samples from different statistical distributions using parameters as a list in R?
- Statistical Functions in Python
- Statistical Thinking in Python
- How to generate prime twins using Python?
- How to generate JSON output using Python?
- How to generate prime numbers using Python?
- How to combine multiple graphs in Python
- How to generate a 24bit hash using Python?
- How to generate pyramid of numbers using Python?
- Adding textures to graphs using Matplotlib
- How to generate secure temporary file name using Python?
- How to generate a string of bits using Python?