How to project 3D data to every axis with matplotlib?

Viewed 77

For 2D data, we can use the seaborn tool to display the marginal distributions (https://seaborn.pydata.org/examples/regression_marginals.html). I generate 4D data and want to display the data trend with each of 3 axes(as the figure). Please, how to make it?

enter image description here

the 4D data displaying code is:

import numpy as np
import matplotlib.pyplot as plt

# only for example, use your grid
z = np.linspace(0, 1, 15)
x = np.linspace(0, 1, 15)
y = np.linspace(0, 1, 15)

X, Y, Z = np.meshgrid(x, y, z)

# Your 4dimension, only for example use yours
U = np.exp(-(X/2) ** 2 - (Y/3) ** 2 - Z ** 2)

# Creating figure
fig = plt.figure()
ax = plt.axes(projection="3d")

# Creating plot
ax.scatter3D(X, Y, Z, c=U, alpha=0.7, marker='.')
plt.show()

I am hoping that by posting this someone who is more familiar with matplotlib than myself might be able to let me know a way to fix this issue I am having.

0 Answers
Related