Created
October 18, 2020 18:53
-
-
Save gvyshnya/82d720756330ec7bb9d48b691a3ac9bc to your computer and use it in GitHub Desktop.
Plotly Facet Plot with Violin Subplots
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def visualize_features_vs_target_label(df_data, label, feature_list, n_cols=3): | |
if len(feature_list) % n_cols == 0: | |
number_of_rows = int(len(feature_list)/n_cols) | |
else: | |
number_of_rows = int(len(feature_list)/n_cols) +1 | |
fig = make_subplots(rows=number_of_rows, cols=n_cols) | |
row_pos = 1 | |
col_pos = 1 | |
for feature_col in feature_list: | |
fig.add_trace( | |
go.Violin(x=df_data[label], y=df_data[feature_col], name=feature_col), | |
row=row_pos, col=col_pos | |
) | |
col_pos = col_pos + 1 | |
if col_pos > n_cols: | |
col_pos = 1 | |
row_pos = row_pos + 1 | |
fig.update_layout(#violingap=0, | |
#violinmode='overlay', | |
title_text="Features-to-Target Relations") | |
fig.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment