How to generate scatter plot using Pandas and Seaborn?
DATA VISUALIZATION

How to generate scatter plot using Pandas and Seaborn?

How to generate scatter plot using Pandas and Seaborn?

This recipe helps you generate scatter plot using Pandas and Seaborn

0
This data science python source code does the following : 1.Importing necessary libraries for making plot 2. Sets style of the scatter plot 3. Plots without regression line 4. Plots by fitting regession line
In [2]:
## How to generate scatter plot using Pandas and Seaborn
def Snippet_116():
    print()
    print(format('How to scatter plot using Pandas and Seaborn','*^82'))

    import warnings
    warnings.filterwarnings("ignore")

    # load libraries
    import pandas as pd
    import random
    import matplotlib.pyplot as plt
    import seaborn as sns

    # Create empty dataframe
    df = pd.DataFrame()

    # Add columns
    df['x'] = random.sample(range(1, 1000), 75)
    df['y'] = random.sample(range(1, 1000), 75)

    # View first few rows of data
    print(); print(df.head())

    # Set style of scatterplot
    sns.set_context("notebook", font_scale=1.1)
    sns.set_style("ticks")

    # Create scatterplot of dataframe without regression line
    sns.lmplot('x', 'y', data=df, fit_reg=False, # Don't fit a regression line
               scatter_kws={"marker": "D", "s": 100}) # S marker size

    # Set title & labels
    plt.title('Scatter Plot of Data without Regression Line')
    plt.xlabel('X Axis')
    plt.ylabel('Y Axis')
    plt.show()

    # Create scatterplot of dataframe with regression line
    sns.lmplot('x', 'y', data=df, fit_reg=True, # Don't fit a regression line
               scatter_kws={"marker": "D", "s": 100}) # S marker size

    # Set title & labels
    plt.title('Scatter Plot of Data with Regression Line')
    plt.xlabel('X Axis')
    plt.ylabel('Y Axis')
    plt.show()

Snippet_116()
*******************How to scatter plot using Pandas and Seaborn*******************

     x    y
0   85  510
1  220  820
2  285  495
3  354  409
4  442  647

Relevant Projects

Solving Multiple Classification use cases Using H2O
In this project, we are going to talk about H2O and functionality in terms of building Machine Learning models.

Data Science Project-All State Insurance Claims Severity Prediction
Data science project in R to develop automated methods for predicting the cost and severity of insurance claims.

Music Recommendation System Project using Python and R
Machine Learning Project - Work with KKBOX's Music Recommendation System dataset to build the best music recommendation engine.

Perform Time series modelling using Facebook Prophet
In this project, we are going to talk about Time Series Forecasting to predict the electricity requirement for a particular house using Prophet.

Ecommerce product reviews - Pairwise ranking and sentiment analysis
This project analyzes a dataset containing ecommerce product reviews. The goal is to use machine learning models to perform sentiment analysis on product reviews and rank them based on relevance. Reviews play a key role in product recommendation systems.

Walmart Sales Forecasting Data Science Project
Data Science Project in R-Predict the sales for each department using historical markdown data from the Walmart dataset containing data of 45 Walmart stores.

Zillow’s Home Value Prediction (Zestimate)
Data Science Project in R -Build a machine learning algorithm to predict the future sale prices of homes.

Data Science Project-TalkingData AdTracking Fraud Detection
Machine Learning Project in R-Detect fraudulent click traffic for mobile app ads using R data science programming language.

Credit Card Fraud Detection as a Classification Problem
In this data science project, we will predict the credit card fraud in the transactional dataset using some of the predictive models.

Mercari Price Suggestion Challenge Data Science Project
Data Science Project in Python- Build a machine learning algorithm that automatically suggests the right product prices.