×

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 | Horizontal Box Plot

Horizontal Box Plot in Python: In this tutorial, we will learn how to create horizontal box plot using matplotlib? By Anuj Singh Last updated : August 18, 2023

Horizontal Box Plot Using Matplotlib

There is an inbuilt function defined for our desired operation i.e. matplotlib.pyplot.box(data, vert=False).

Example

Following is an example illustrating a normal box and notched box plot.

Python | Horizontal Box Plot

Python program for horizontal box plot

import numpy as np
import matplotlib.pyplot as plt

# Generating Data
spread = np.random.rand(65) * 82
center = np.ones(36) * 50
flier_high = np.random.rand(12) * 100 + 100
flier_low = np.random.rand(10) * -100
data = np.concatenate((spread, center, flier_high, flier_low))

plt.figure()
plt.title('Horizontal Box Plot')
plt.boxplot(data, notch=False, vert=False)
plt.ylabel('Variation')
plt.show()

plt.figure()
plt.title('Horizontal Notched Box Plot')
plt.boxplot(data, notch=True, vert=False)
plt.ylabel('Variation')
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.