Sunday, 18 August 2024
Python Nested If Examples
Thursday, 11 July 2024
Python program to generate 100 random numbers between 1 to 100
Random Number Generation in Python
Following python program will generate 100 random numbers between 1 to 100.
Output
Generated 100 random numbers in range 1 to 100:
[31, 48, 64, 37, 69, 53, 75, 24, 34, 19, 5, 2, 44, 12, 51, 96, 49, 92, 54, 99, 78, 68, 87, 74, 92, 53, 68, 41, 76, 13, 59, 89, 52, 99, 17, 41, 37, 43, 47, 32, 13, 10, 91, 87, 46, 3, 29, 46, 11, 71, 74, 26, 21, 63, 67, 80, 10, 33, 4, 4, 30, 89, 63, 93, 90, 24, 2, 46, 73, 91, 88, 94, 5, 93, 18, 5, 31, 93, 66, 54, 28, 8, 11, 39, 17, 96, 91, 60, 38, 4, 77, 98, 7, 45, 48, 64, 51, 40, 38, 34]
* * *
< Back to Home >
Sunday, 14 April 2024
Introduction to Matplotlib library
Matplotlib - Python's library for data visualization
What is Matplotlib?
Matplotlib is a fundamental Python library for data visualization. It is a powerful and versatile open-source library in Python that allows you to create various static, animated, and interactive visualizations. It excels at generating a wide range of plot types, including:
- Line plots
- Bar charts
- Scatter plots
- Histograms
- Pie charts
- 3D plots
- And many more
Matplotlib is a cornerstone for data analysis and storytelling in Python. By visualizing your data, you can gain deeper insights, identify trends and patterns, and communicate findings effectively.
Getting Started with Matplotlib - Installation:
If you don't have Matplotlib installed, use pip, and import the matplotlib.pyplot
submodule.
pip install matplotlib
import matplotlib.pyplot as plt
Example: A Line Plot using Matplotlib
This example creates a line plot showing temperature variations over time:
Output of the code
Figure: Line Plot |
Example - Bar Chart using Matplotlib:
Following example creates a bar chart comparing sales figures for different products.
Output of the code
Figure: Bar Chart using Matplotlib |
Figure: Scatter Plot |
Remember to replace the sample data in these examples with your actual data to create meaningful visualizations.
Customization and Beyond
Matplotlib offers extensive customization capabilities. You can fine-tune plot elements like:
- Line styles
- Marker shapes
- Color schemes
- Grid lines
- Legend placement
- Font sizes
Explore the official Matplotlib documentation.