How to plot Multiple plots in a row in Azure ML Studio Notebooks Without Compromising Size?

143 Views Asked by At

I want to plot different plots in a single row so that it is easier for comparison. For example Distribution of a categorical feature in different data versions.

In one of my use cases I plot the target distribution changes for Target Column Species-

code:

def plot_target_ditributions(dataframes, target, versions=["Previous", "Latest"], save=False):

    nrows = 1
    ncols = len(dataframes)

    fig, axes = plt.subplots(nrows, ncols, figsize=(20, 5))

    for col in range(ncols):
        df = dataframes[col]
        ax = axes[col]
        sns.countplot(data=df, x="Species", ax=ax)
        ax.set_title(f'Target Distribution in {versions[col]} Version', fontsize = 14)

    if save:
        plt.savefig(f"./saved_plots/targetdist/target_distribution_{date.today()}", bbox_inches='tight', dpi=400)

    plt.show()

plot_target_ditributions([previous_df,intermediate_df, current_df], target,versions=["Previous" ,"Intermediate", "Latest"])

data:

The Dataset used in this example above is the Iris Dataset obtained from https://archive.ics.uci.edu/ml/datasets/iris.

Different versions of the data are simulated by adding random values for testing purposes.

previous_df data can be found here. intermediate_df data can be found here. current_df data can be found here.

The "Species" column is used in all three data sources for plotting.

enter image description here

The function is written in such a way that i can input even 10 data versions and 10 side-by-side plots will be generated.

The issue I face is that, when I increase the number of plots to be plotted, each individual plot becomes smaller.

What I want is that the Individual plot to retain its size but the output cell to expand and have a horizontal scrollable functionaility. As I remember this use to happen in my local jupyter lab and notebook but in Azure Notebooks, the horizoontal scroll is not there and the individual figure size is smaller as the number of plots increase.

What can I do to get pass this? Is there way with matplotlib to solve this or is there a solution with Azure ML Studio Notebooks itself?

0

There are 0 best solutions below