- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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 a 4D plot with Matplotlib using arbitrary data?
To make a 4D plot, we can create x, y, z and c standard data points. Create a new figure or activate an existing figure.
Steps
Use figure() method to create a figure or activate an existing figure.
Add a figure as part of a subplot arrangement.
Create x, y, z and c data points using numpy.
Create a scatter plot using scatter method.
To display the figure, use show() method.
Example
from matplotlib import pyplot as plt import numpy as np plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True fig = plt.figure() ax = fig.add_subplot(111, projection='3d') x = np.random.standard_normal(100) y = np.random.standard_normal(100) z = np.random.standard_normal(100) c = np.random.standard_normal(100) img = ax.scatter(x, y, z, c=c, cmap='YlOrRd', alpha=1) plt.show()
Output
- Related Articles
- How to plot arbitrary markers on a Pandas data series using Matplotlib?
- How to plot 4D scatter-plot with custom colours and cutom area size in Python Matplotlib?
- How to plot a histogram using Matplotlib in Python with a list of data?
- How to make a quiver plot in polar coordinates using Matplotlib?
- How to plot 1D data at a given Y-value with PyLab using Matplotlib?
- How to make a rug plot in Matplotlib?
- How to make a mosaic plot in Matplotlib?
- How to make a simple lollipop plot in Matplotlib?
- How to extract data from a Matplotlib plot?
- Plot data from a .txt file using matplotlib
- How to plot CSV data using Matplotlib and Pandas in Python?
- How to plot multiple histograms on same plot with Seaborn using Matplotlib?
- How to make a broken horizontal bar plot in Matplotlib?
- How to plot data into imshow() with custom colormap in Matplotlib?
- Plot data from CSV file with Matplotlib

Advertisements