Random Scatter Plot Generation with Seaborn

  • Share this:

Code introduction


This function generates a scatter plot using the Seaborn library. The data for the scatter plot is created using random data generated by the Numpy library.


Technology Stack : Seaborn, Numpy, Matplotlib

Code Type : The type of code

Code Difficulty : Intermediate


                
                    
import seaborn as sns
import numpy as np
import matplotlib.pyplot as plt

def generate_random_scatter_plot(data):
    """
    Generates a random scatter plot using Seaborn.
    """
    # Set random seed for reproducibility
    np.random.seed(0)
    
    # Create random data
    x = np.random.rand(50)
    y = np.random.rand(50)
    
    # Create a figure and a set of subplots
    fig, ax = plt.subplots()
    
    # Plot the random data
    sns.scatterplot(x=x, y=y, ax=ax)
    
    # Set title and labels
    ax.set_title("Random Scatter Plot")
    ax.set_xlabel("X-axis")
    ax.set_ylabel("Y-axis")
    
    # Show the plot
    plt.show()