- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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 plot an emoji as a label for a bar in Matplotlib?
We can use annotate() to place an emoji at the top of a bar.
Steps
- Set the figure size and adjust the padding between and around the subplots.
- Make a list of frequencies and labels conatining emojis.
- Create a new figure or activate an existing figure using figure() method.
- Plot bars using bar() method.
- Use annotate() method to place emojis as a label
- To display the figure, use show() method.
Example
import numpy as np from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True freqs = [7, 8, 5, 3, 6] labels = ['😊', '😲', '😂', '😃', '😛'] plt.figure() p1 = plt.bar(np.arange(len(labels)), freqs) for rect1, label in zip(p1, labels): height = rect1.get_height() plt.annotate( label, (rect1.get_x() + rect1.get_width()/2, height+.05), ha="center", va="bottom", fontsize=30 ) plt.show()
Output
- Related Articles
- How to plot a bar chart for a list in Python matplotlib?
- How to add a shared x-label and y-label to a plot created with Pandas' plot? (Matplotlib)
- How to make a broken horizontal bar plot in Matplotlib?
- Dynamically updating a bar plot in Matplotlib
- How to plot a bar graph in Matplotlib from a Pandas series?
- How to plot a Bar Chart with multiple labels in Matplotlib?
- How to sort bars in a bar plot in ascending order (Matplotlib)?
- Plot a bar using matplotlib using a dictionary
- How to plot a time as an index value in a Pandas dataframe in Matplotlib?
- How to draw an average line for a scatter plot in MatPlotLib?
- How to set label for an already plotted line in Matplotlib?
- How to create a legend for a 3D bar in Matplotlib?
- How to add a legend on Seaborn facetgrid bar plot using Matplotlib?
- How to convert the X-axis label in a bar plot to italic using ggplot2 in R?
- How to label a patch in matplotlib?

Advertisements