×

Python Tutorial

Python Basics

Python I/O

Python Operators

Python Conditions & Controls

Python Functions

Python Strings

Python Modules

Python Lists

Python OOPs

Python Arrays

Python Dictionary

Python Sets

Python Tuples

Python Exception Handling

Python NumPy

Python Pandas

Python File Handling

Python WebSocket

Python GUI Programming

Python Image Processing

Python Miscellaneous

Python Practice

Python Programs

Python | Categorical Plotting

Python | Categorical Plotting: In this tutorial, we will learn about the categorical plotting and its Python implementation. By Anuj Singh Last updated : August 18, 2023

Categorical Plotting

Visualizing different variables is also a part of basic plotting. Such variables can have different classes, for example, numerical or a category. Matplotlib has an important feature of Categorical Plotting. We can plot multiple categorical variables within different types of plots such as line, dot, bar, scatter, etc.

Syntax

matplotlib.pyplot.figure(figsize=(4,3))

#figsize(float, float)
width, height in inches.

Examples

Following are some examples of categorical plotting:

Example 1: Line Plot

Python | Categorical Plotting (1)

Example 2: Bar Plot

Python | Categorical Plotting (2)

Example 3: Dot Plot

Python | Categorical Plotting (3)

Python program for categorical plotting

# Data Visualization using Python
# Categorical Plotting

import matplotlib.pyplot as plt

names = ['Rabhes', 'Grpsh J.', 'John C. Dave']
values = [45646, 75640, 42645]

# example 1
plt.figure()
plt.plot(names, values, color='y')
plt.ylabel('Income')
plt.title('Income Comparison')
plt.show()

# example 2
plt.figure()
plt.bar(names, values, color='y')
plt.ylabel('Income')
plt.title('Income Comparison')
plt.show()

# example 3
plt.figure()
plt.plot(names, values, 'or')
plt.ylabel('Income')
plt.title('Income Comparison')
plt.show()

Output:

Output is as figure
Advertisement
Advertisement

Comments and Discussions!

Load comments ↻


Advertisement
Advertisement
Advertisement

Copyright © 2025 www.includehelp.com. All rights reserved.