- 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 make colorbar orientation horizontal in Python using Matplotlib?
To make colorbar orientation horizontal in Python, we can use orientation="horizontal" in the argument.
Steps
- Set the figure size and adjust the padding between and around the subplots.
- Create random x, y and z data points using numpy.
- Create a figure and a set of subplots.
- Use scatter() method to plot x, y and z data points.
- Create a colorbar for a ScalarMappable instance, with horizontal orientation.
- To display the figure, use show() method.
Example
import numpy as np import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True x, y, z = np.random.rand(3, 50) f, ax = plt.subplots() points = ax.scatter(x, y, c=z, s=50, cmap="plasma") f.colorbar(points, orientation="horizontal") plt.show()
Output
- Related Articles
- How to make a discrete colorbar for a scatter plot in matplotlib?
- How to make a broken horizontal bar plot in Matplotlib?
- How to decrease colorbar width in Matplotlib?
- How to animate the colorbar in Matplotlib?
- How to plot a 2D matrix in Python with colorbar Matplotlib?
- How to add Matplotlib Colorbar Ticks?
- How to retrieve colorbar instance from figure in Matplotlib?
- How to shift the colorbar position to right in matplotlib?
- How to make several plots on a single page using matplotlib in Python?
- How to add a colorbar for a hist2d plot in Matplotlib?
- How to make several plots on a single page using Matplotlib(Python)?
- How to plot a pcolor colorbar in a different subplot in Matplotlib?
- How to make an application ignore screen orientation change in Android?
- How to make horizontal line with words in the middle using CSS?
- Displaying horizontal bar graphs using Matplotlib

Advertisements