Generating 3D scatter plotsΒΆ

This example uses the method psynlig.scatter.plot_3d_scatter() for explorative plotting of raw data using three variables (i.e. for generating 3D plots). The data points can be colored according to class labels if this is available. This is done by passing the labels for each data point (using the parameter class_data) and a mapping from the labels to something more human-readable (using the parameter class_names).

Generating several plots (for all combinations of 3 variables) can be done using the method psynlig.scatter.generate_3d_scatter(). Note that this can create a large number of plots and that the method will only generate these if the number of plots does not exceed the parameter max_plots of this method.

plot 007 scatter 3d
from matplotlib import pyplot as plt
import pandas as pd
from sklearn.datasets import load_iris
from psynlig import plot_3d_scatter
plt.style.use('seaborn-talk')


data_set = load_iris()
data = pd.DataFrame(data_set['data'], columns=data_set['feature_names'])
class_data = data_set['target']
class_names = dict(enumerate(data_set['target_names']))

plot_3d_scatter(
    data,
    'sepal length (cm)', 'petal width (cm)', 'petal length (cm)',
    class_names=class_names,
    class_data=class_data,
    cmap_class='viridis',
    marker='o', s=250, alpha=0.8, edgecolor='0.4'
)

plt.show()

Total running time of the script: ( 0 minutes 0.312 seconds)

Gallery generated by Sphinx-Gallery