Parallel Coordinates Plot#
A parallel coordinates plot of 4 features of the penguins dataset to analyze how they are related with the species. We can see, for instance, that Gentoo penguins dominate the flipper_length_mm
feature, having the highest flipper lengths.
import hvplot
import pandas as pd
from sklearn.preprocessing import MinMaxScaler
df = hvplot.sampledata.penguins("pandas")
df_scaled = df
cols = ["bill_length_mm", "bill_depth_mm", "flipper_length_mm", "body_mass_g"]
scaler = MinMaxScaler()
scaled_features = scaler.fit_transform(df[cols])
df_scaled = pd.DataFrame(scaled_features, columns=cols)
df_scaled["species"] = df["species"]
hvplot.plotting.parallel_coordinates(
df_scaled,
class_column="species",
title="Parallel Coordinates Plot (Bokeh)",
)
import hvplot
import pandas as pd
from sklearn.preprocessing import MinMaxScaler
hvplot.extension("matplotlib")
df = hvplot.sampledata.penguins("pandas")
df_scaled = df
cols = ["bill_length_mm", "bill_depth_mm", "flipper_length_mm", "body_mass_g"]
scaler = MinMaxScaler()
scaled_features = scaler.fit_transform(df[cols])
df_scaled = pd.DataFrame(scaled_features, columns=cols)
df_scaled["species"] = df["species"]
hvplot.plotting.parallel_coordinates(
df_scaled,
class_column="species",
title="Parallel Coordinates Plot (Matplotlib)",
)
This web page was generated from a Jupyter notebook and not all
interactivity will work on this website.