
- 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
Adding textures to graphs using Matplotlib
In this program, we will plot a bar graph using the matplotlib library. The most important Step in solving matplotlib related problems using the matplotlib library is importing the matplotlib library. The syntax is:
import matplotlib.pyplot as plt
Pyplot is a collection of command style functions that make Matplotlib work like MATLAB. In addition to plotting the bar graphs, we will also add some textures to the graphs. The 'hatch' parameter in the bar() function is used to define the texture of the bar
Algorithm
Step 1: Define a list of values. Step 2: Use the bar() function and define parameters like xaxis, yaxis, hatch. Step 3: Plot the graph.
Example Code
import matplotlib.pyplot as plt data_x = ['Mumbai', 'Delhi', 'Ahmedabad', 'Banglore'] data_y = [40, 35, 29, 32] plt.xlabel("CITY") plt.ylabel("POPULATION") plt.title("BAR PLOT") plt.bar(data_x, data_y, color='red', hatch = 'o') plt.show()
Output
- Related Questions & Answers
- Displaying bar graphs using Matplotlib
- Displaying horizontal bar graphs using Matplotlib
- How to plot 3D graphs using Python Matplotlib?
- How to make multipartite graphs using networkx and Matplotlib?
- Plotting multiple line graphs using Pandas and Matplotlib
- Adding extra axis ticks using Matplotlib
- How to show node name in Matplotlib graphs using networkx?
- How to plot multiple graphs in Matplotlib?
- Show Matplotlib graphs to image as fullscreen
- How can I add textures to my bars and wedges in Matplotlib?
- Adding a scatter of points to a boxplot using Matplotlib
- Adding extra contour lines using Matplotlib 2D contour plotting
- How to create broken horizontal bar graphs in matplotlib?
- Matplotlib – Drawing lattices and graphs with Networkx
- Adding a line to a scatter plot using Python's Matplotlib
Advertisements