🕷️ Crawler Inspector

URL Lookup

Direct Parameter Lookup

Raw Queries and Responses

1. Shard Calculation

Query:
Response:
Calculated Shard: 40 (from laksa081)

2. Crawled Status Check

Query:
Response:

3. Robots.txt Check

Query:
Response:

4. Spam/Ban Check

Query:
Response:

5. Seen Status Check

ℹ️ Skipped - page is already crawled

📄
INDEXABLE
CRAWLED
22 days ago
🤖
ROBOTS ALLOWED

Page Info Filters

FilterStatusConditionDetails
HTTP statusPASSdownload_http_code = 200HTTP 200
Age cutoffPASSdownload_stamp > now() - 6 MONTH0.7 months ago
History dropPASSisNull(history_drop_reason)No drop reason
Spam/banPASSfh_dont_index != 1 AND ml_spam_score = 0ml_spam_score=0
CanonicalPASSmeta_canonical IS NULL OR = '' OR = src_unparsedNot set

Page Details

PropertyValue
URLhttps://indianaiproduction.com/seaborn-scatter-plot/
Last Crawled2026-03-22 04:00:27 (22 days ago)
First Indexed2019-10-02 20:40:48 (6 years ago)
HTTP Status Code200
Meta TitleSeaborn Scatter Plot using sns.scatterplot() | Python Seaborn Tutorial
Meta DescriptionYou want to find the relationship between x & y variable dataset for getting insights. Then the seaborn scatter plot function sns.scatterplot() will help.
Meta Canonicalnull
Boilerpipe Text
If, you have x and y numeric or one of them a categorical dataset. You want to find the relationship between x and y to getting insights. Then the seaborn scatter plot function sns.scatterplot() will help. Along with sns.scatterplot() function, seaborn have multiple functions like sns.lmplot(), sns.relplot(), sns.pariplot(). But sns.scatterplot() is the best way to create sns scatter plot . Bonus: 1. Jupyter NoteBook file for download which contains all practical source code explained here. 2. 4 examples with 2 different dataset What is seaborn scatter plot and Why use it? The seaborn scatter plot use to find the relationship between x and y variable. It may be both a numeric type or one of them a categorical data. The main goal is data visualization through the scatter plot. To get insights from the data then different data visualization methods usage is the best decision. Up to, we learn in python seaborn tutorial . How to create a seaborn line plot , histogram , barplot ? So, maybe you definitely observe these methods are not sufficient. How to create a seaborn scatter plot using sns.scatterplot() function? To create a scatter plot use sns.scatterplot() function. In this tutorial, we will learn how to create a sns scatter plot step by step. Here, we use multiple parameters, keyword arguments, and other seaborn and matplotlib functions. Syntax: sns.scatterplot(                                            x=None,                                            y=None,                                            hue=None,                                            style=None,                                            size=None,                                            data=None,                                            palette=None,                                            hue_order=None,                                            hue_norm=None,                                            sizes=None,                                            size_order=None,                                            size_norm=None,                                            markers=True,                                            style_order=None,                                            x_bins=None,                                            y_bins=None,                                            units=None,                                            estimator=None,                                            ci=95,                                            n_boot=1000,                                            alpha=’auto’,                                            x_jitter=None,                                            y_jitter=None,                                            legend=’brief’,                                            ax=None,                                            **kwargs,                                           ) For the best understanding, I suggest you follow the matplotlib scatter plot tutorial. Import libraries As you can see, we import the Seaborn and Matplotlib pyplot module for data visualization. Note: Practical perform on Jupyter NoteBook and at the end of this seaborn scatter plot tutorial, you will get ‘. ipynb ‘ file for download. 1 2 3 4 5 6 import seaborn as sns import matplotlib.pyplot as plt import pandas as pd sns: Short name was given to seaborn plt : Short name was given to matplolib.pyplot module Import Dataset Here, we are importing or loading “titanic.csv” dataset from GitHub Seaborn repository using sns.load_dataset() function but you can import your business dataset using Pandas read_csv function. 1 2 3 titanic_df = sns.load_dataset( "titanic" ) titanic_df or 1 2 3 titanic_df = pd.read_csv( "C:\\Users\\IndianAIProduction\\seaborn-data\\titanic.csv" ) titanic_df Output >>> Titanic Data Frame What is Titanic DataFrame? I hope, you watched Titanic historical Hollywood movie. Titanic was a passenger ship which crashed. The “titanic.csv” contains all the information about that passenger. The ‘ titanic.csv’ DataFrame contains 891 rows and 15 columns. Using this DataFrame our a goal to scatter it first using seaborn sns.scatterplot() function and find insights. Titanic ship accident Note: In this tutorial, we are not going to clean ‘titanic’ DataFrame but in real life project, you should first clean it and then visualize. Plot seaborn scatter plot using sns.scatterplot() x, y, data parameters Create a scatter plot is a simple task using sns.scatterplot() function just pass x, y, and data to it. you can follow any one method to create a scatter plot from given below. 1. Method 1 2 sns.scatterplot(x = "age" , y = "fare" , data = titanic_df) 2. Method 1 2 sns.scatterplot(x = titanic_df.age, y = titanic_df.fare) 3. Method 1 2 sns.scatterplot(x = titanic_df[ 'age' ], y = titanic_df[ 'fare' ]) Output >>> x, y: Pass value as a name of variables or vector from DataFrame, optional data: Pass DataFrame sns.scatterplot() hue parameter hue: Pass value as a name of variables or vector from DataFrame, optional To distribute x and y variables with a third categorical variable using color. 1 2 sns.scatterplot(x = "age" , y = "fare" , data = titanic_df, hue = "sex" ) output >>> sns.scatterplot() hue_order parameter hue_order: Pass value as a tuple or Normalize object, optional As you can observe in above scatter plot, we used the hue parameter to distribute scatter plot in male and female. The order of that hue in this manner [‘male’, ‘female’] but your requirement is [‘female’, ‘male’]. Then hue_order parameter will help to change hue categorical data order. 1 2 3 sns.scatterplot(x = "age" , y = "fare" , data = titanic_df, hue = "sex" ,                 hue_order = [ 'female' , 'male' ]) output >>> sns.scatterplot() size parameter size: Pass value as a name of variables or vector from DataFrame, optional Its name tells us why to use it, to distribute scatter plot in size by passing the categorical or numeric variable. 1 2 sns.scatterplot(x = "age" , y = "fare" , data = titanic_df, size = "who" ) output >>> sns.scatterplot() sizes parameter sizes: Pass value as a list, dict, or tuple, optional To minimize and maximize the size of the size parameter . 1 2 3 sns.scatterplot(x = "age" , y = "fare" , data = titanic_df, size = "who" ,                  sizes = ( 50 , 300 )) output >>> sns.scatterplot() size_order parameter size_order: Pass value as a list, optional Same like hue_order size_order parameter change the size order of size variable. Current size order is [‘man’, ‘woman’, ‘child’] now we change like [‘child’, ‘man’, ‘woman’]. 1 2 3 sns.scatterplot(x = "age" , y = "fare" , data = titanic_df, size = "who" ,                  size_order = [ 'child' , 'man' , 'woman' ],) output >>> sns.scatterplot() style parameter style: Pass value as a name of variables or vector from DataFrame, optional To change the style with a different marker. 1 2 sns.scatterplot(x = "age" , y = "fare" , data = titanic_df, style = "who" ,) Output >>> sns.scatterplot() style_order parameter style_order: Pass value as a list, optional Like hue_order, size_order, style_order parameter change the order of style levels. Here, we changed the style order [‘man’, ‘woman’, ‘child’] to [‘child’,’woman’,’man’]. 1 2 sns.scatterplot(x = "age" , y = "fare" , data = titanic_df, style = "who" , style_order = [ 'child' , 'woman' , 'man' ]) Output >>> sns.scatterplot() palette parameter palette: Pass value as a palette name, list, or dict, optional To change the color of the seaborn scatterplot. While using the palette, first mention hue parameter. Here, we pass the hot value to the scatter plot palette parameter. 1 2 3 sns.scatterplot(x = "age" , y = "fare" , data = titanic_df, hue = "sex" ,                  palette = "hot" ) Palette values: Choose one of them 1 2 3 4 5 6 Possible values are: Accent, Accent_r, Blues, Blues_r, BrBG, BrBG_r, BuGn, BuGn_r, BuPu, BuPu_r, CMRmap, CMRmap_r, Dark2, Dark2_r, GnBu, GnBu_r, Greens, Greens_r, Greys, Greys_r, OrRd, OrRd_r, Oranges, Oranges_r, PRGn, PRGn_r, Paired, Paired_r, Pastel1, Pastel1_r, Pastel2, Pastel2_r, PiYG,   PiYG_r, PuBu, PuBuGn, PuBuGn_r, PuBu_r, PuOr, PuOr_r, PuRd, PuRd_r, Purples, Purples_r, RdBu, RdBu_r, RdGy, RdGy_r, RdPu, RdPu_r, RdYlBu, RdYlBu_r, RdYlGn, RdYlGn_r, Reds, Reds_r, Set1, Set1_r, Set2, Set2_r, Set3, Set3_r, Spectral, Spectral_r, Wistia, Wistia_r, YlGn, YlGnBu, YlGnBu_r,   YlGn_r, YlOrBr, YlOrBr_r, YlOrRd, YlOrRd_r, afmhot, afmhot_r, autumn, autumn_r, binary, binary_r, bone, bone_r, brg, brg_r, bwr, bwr_r, cividis, cividis_r, cool, cool_r, coolwarm, coolwarm_r, copper, copper_r, cubehelix, cubehelix_r, flag, flag_r, gist_earth, gist_earth_r, gist_gray, gist_gray_r,   gist_heat, gist_heat_r, gist_ncar, gist_ncar_r, gist_rainbow, gist_rainbow_r, gist_stern, gist_stern_r, gist_yarg, gist_yarg_r, gnuplot, gnuplot2, gnuplot2_r, gnuplot_r, gray, gray_r, hot, hot_r, hsv, hsv_r, icefire, icefire_r, inferno, inferno_r, jet, jet_r, magma, magma_r, mako,   mako_r, nipy_spectral, nipy_spectral_r, ocean, ocean_r, pink, pink_r, plasma, plasma_r, prism, prism_r, rainbow, rainbow_r, rocket, rocket_r, seismic, seismic_r, spring, spring_r, summer, summer_r, tab10, tab10_r, tab20, tab20_r, tab20b, tab20b_r, tab20c, tab20c_r, terrain, terrain_r,   twilight, twilight_r, twilight_shifted, twilight_shifted_r, viridis, viridis_r, vlag, vlag_r, winter, winter_r Output >>> sns.scatterplot() markers parameter markers: Pass value as a boolean, list, or dictionary, optional Use to change the marker of style categories. Below is the list of matplotlib.markers . 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 ============================== ====== ============================== marker                         symbol description ============================== ====== ============================== ``"."``                        |m00|  point ``","``                        |m01|  pixel ``"o"``                        |m02|  circle ``"v"``                        |m03|  triangle_down ``"^"``                        |m04|  triangle_up ``"<"``                        |m05|  triangle_left ``">"``                        |m06|  triangle_right ``"1"``                        |m07|  tri_down ``"2"``                        |m08|  tri_up ``"3"``                        |m09|  tri_left ``"4"``                        |m10|  tri_right ``"8"``                        |m11|  octagon ``"s"``                        |m12|  square ``"p"``                        |m13|  pentagon ``"P"``                        |m23|  plus (filled) ``"*"``                        |m14|  star ``"h"``                        |m15|  hexagon1 ``"H"``                        |m16|  hexagon2 ``"+"``                        |m17|  plus ``"x"``                        |m18|  x ``"X"``                        |m24|  x (filled) ``"D"``                        |m19|  diamond ``"d"``                        |m20|  thin_diamond ``"|"``                        |m21|  vline ``"_"``                        |m22|  hline ``0`` (``TICKLEFT``)           |m25|  tickleft ``1`` (``TICKRIGHT``)          |m26|  tickright ``2`` (``TICKUP``)             |m27|  tickup ``3`` (``TICKDOWN``)           |m28|  tickdown ``4`` (``CARETLEFT``)          |m29|  caretleft ``5`` (``CARETRIGHT``)         |m30|  caretright ``6`` (``CARETUP``)            |m31|  caretup ``7`` (``CARETDOWN``)          |m32|  caretdown ``8`` (``CARETLEFTBASE``)      |m33|  caretleft (centered at base) ``9`` (``CARETRIGHTBASE``)     |m34|  caretright (centered at base) ``10`` (``CARETUPBASE``)       |m35|  caretup (centered at base) ``11`` (``CARETDOWNBASE``)     |m36|  caretdown (centered at base) ``"None"``, ``" "`` or  ``""``        nothing ``'$...$'``                    |m37|  Render the string using mathtext.                                        E.g ``"$f$"`` for marker showing the                                        letter ``f``. 1 2 sns.scatterplot(x = "age" , y = "fare" , data = titanic_df, style = "who" , markers = [ '3' , '1' , 3 ]) Output >>> sns.scatterplot() alpha parameter alpha: Pass a float value between 0 to 1 To change the transparency of points. 0 value means full transparent point and 1 value means full clear. For nonvisibility pass 0 value to scatter plot alpha parameter. Here, we pass the 0.4 float value. 1 2 sns.scatterplot(x = "age" , y = "fare" , data = titanic_df, alpha = 0.4 ) Output >>> sns.scatterplot() legend parameter legend: Pass value as “full”, “brief” or False, optional When we used hue, style, size the scatter plot parameters then by default legend apply on it but you can change. Here, we don’t want to show legend, so we pass False value to scatter plot legend parameter . 1 2 sns.scatterplot(x = "age" , y = "fare" , data = titanic_df, hue = "sex" , legend = False ) Output >>> sns.scatterplot() ax (Axes) parameter ax (Axes): Pass value as a matplotlib Axes, optional Use multiple methods to change the sns scatter plot format and style using the seaborn scatter plot ax (Axes) parameter. here, used ax.set() method to change the scatter plot x-axis, y-axis label, and title. 1 2 3 4 5 ax = sns.scatterplot(x = "age" , y = "fare" , data = titanic_df, ) ax. set (xlabel = "Age" ,        ylabel = "Fare" ,        title = "Seaborn Scatter Plot of Age and Fare" ) Output >>> sns.scatterplot() kwargs (Keyword Arguments) parameter kwargs (Keyword Arguments): Pass the key and value mapping as a dictionary If you want to the artistic look of scatter plot then you must have to use the seaborn scatter plot kwargs (keyword arguments). The seaborn sns.scatterplot() allow all kwargs of matplotlib plt.scatter() like: edgecolor: Change the edge color of the scatter point. Pass value as a color code, name or hex code. facecolor: Change the face (point) color of the scatter plot. Pass value as a color code, name or hex code. linewidth: Change line width of scatter plot. Pass float or int value linestyle: Change the line style of the scatter plot. Pass line style has given below in the table. Color Parameter Values Character Color b blue g green r red c cyan m magenta y yellow k black w white Line Style parameter values Character Description _ solid line style — dashed line style _. dash-dot line style : dotted line style 1 2 3 4 5 6 7 8 9 10 plt.figure(figsize = ( 16 , 9 )) kwargs  =    { 'edgecolor' : "r" ,               'facecolor' : "k" ,               'linewidth' : 2.7 ,               'linestyle' : '--' ,              } sns.scatterplot(x = "age" , y = "fare" , data = titanic_df, size = "sex" , sizes = ( 500 , 1000 ), alpha = . 7 ,  * * kwargs) Or , you can also pass kwargs as a parameter. Output remain will be the same. 1 2 3 4 5 6 7 8 9 # scatter plot kwrgs (keyword arguments) parameter plt.figure(figsize=(16,9)) # figure size in 16:9 ratio sns.scatterplot(x = "age", y = "fare", data = titanic_df, size = "sex", sizes = (500, 1000), alpha = .7,                 edgecolor='r',                  facecolor="k",                  linewidth=2.7,                  linestyle='--',                 ) Output >>> 1. sns Scatter Plot Example 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 import seaborn as sns import matplotlib.pyplot as plt sns. set () titanic_df = sns.load_dataset( "titanic" ) plt.figure(figsize = ( 16 , 9 )) sns.scatterplot(x = "age" , y = "fare" , data = titanic_df, hue = "sex" , palette = "magma" ,size = "who" ,                  sizes = ( 50 , 300 )) plt.title( "Scatter Plot of Age and Fare" , fontsize = 25 ) plt.xlabel( "Age" , fontsize = 20 ) plt.ylabel( "Fare" , fontsize = 20 ) plt.savefig( "Scatter Plot of Age and Fare" ) plt.show() Output >>> 2. sns Scatter Plot Example 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 import seaborn as sns import matplotlib.pyplot as plt sns. set () titanic_df = sns.load_dataset( "titanic" ) plt.figure(figsize = ( 16 , 9 )) sns.scatterplot(x = "who" , y = "fare" , data = titanic_df, hue = "alive" , style = "alive" , palette = "viridis" ,size = "who" ,                  sizes = ( 200 , 500 )) plt.title( "Scatter Plot of Age and Fare" , fontsize = 25 ) plt.xlabel( "Age" , fontsize = 20 ) plt.ylabel( "Fare" , fontsize = 20 ) plt.savefig( "Scatter Plot of Age and Fare" ) plt.show() Output >>> 3. sns Scatter Plot Example 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 import seaborn as sns import matplotlib.pyplot as plt sns. set () tips_df = sns.load_dataset( "tips" ) plt.figure(figsize = ( 16 , 9 )) sns.scatterplot(x = "tip" , y = "total_bill" , data = tips_df, hue = "sex" , palette = "hot" ,                  size = "day" ,sizes = ( 50 , 300 ), alpha = 0.7 ) plt.title( "Scatter Plot of Tip and Total Bill" , fontsize = 25 ) plt.xlabel( "Tip" , fontsize = 20 ) plt.ylabel( "Total Bill" , fontsize = 20 ) plt.savefig( "Scatter Plot of Tip and Total Bill" ) plt.show() Output >>> 4. sns Scatter Plot Example 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 import seaborn as sns import matplotlib.pyplot as plt sns. set () tips_df = sns.load_dataset( "tips" ) plt.figure(figsize = ( 16 , 9 )) kwargs  =    { 'edgecolor' : "w" ,               'linewidth' : 2 ,               'linestyle' : ':' ,              } sns.scatterplot(x = "tip" , y = "total_bill" , data = tips_df, hue = "sex" , palette = "ocean_r" ,                  size = "day" ,sizes = ( 200 , 500 ), * * kwargs) plt.title( "Scatter Plot of Tip and Total Bill" , fontsize = 25 ) plt.xlabel( "Tip" , fontsize = 20 ) plt.ylabel( "Total Bill" , fontsize = 20 ) plt.savefig( "Scatter Plot of Tip and Total Bill" ) plt.show() Output >>> Conclusion In the  seaborn scatter plot tutorial, we learn how to create a seaborn scatter plot with a real-time example using  sns.barplot()  function. Along with that used different functions, parameter, and keyword arguments(kwargs). We suggest you make your hand dirty with each and every parameter of the above function because This is the best coding practice. Still, you didn’t complete  matplotlib tutorial  then I recommend to you, catch it. Download above  seaborn scatter plot source code  in Jupyter NoteBook file formate.
Markdown
[Skip to content](https://indianaiproduction.com/seaborn-scatter-plot/#content "Skip to content") [![Indian AI Production](https://indianaiproduction.com/wp-content/uploads/2019/06/cropped-Channel-logo-in-circle-473-x-472-px.png)](https://indianaiproduction.com/) - [Home](https://indianaiproduction.com/home/) - [Courses](https://indianaiproduction.com/courses/) Menu Toggle - [Artificial Intelligence](https://indianaiproduction.com/artificial-intelligence/) - [Machine Learning](https://indianaiproduction.com/machine-learning/) - [Data Science](https://indianaiproduction.com/data-science/) - [Blog](https://indianaiproduction.com/blog/) - [Video](https://indianaiproduction.com/video/) - [About Us](https://indianaiproduction.com/about-us/) - [Contact](https://indianaiproduction.com/contact/) [Start Learning](https://indianaiproduction.com/data-science/) [Start Learning](https://indianaiproduction.com/data-science/) [![Indian AI Production](https://indianaiproduction.com/wp-content/uploads/2019/06/cropped-Channel-logo-in-circle-473-x-472-px.png)](https://indianaiproduction.com/) Main Menu - [Home](https://indianaiproduction.com/home/) - [Courses](https://indianaiproduction.com/courses/) Menu Toggle - [Artificial Intelligence](https://indianaiproduction.com/artificial-intelligence/) - [Machine Learning](https://indianaiproduction.com/machine-learning/) - [Data Science](https://indianaiproduction.com/data-science/) - [Blog](https://indianaiproduction.com/blog/) - [Video](https://indianaiproduction.com/video/) - [About Us](https://indianaiproduction.com/about-us/) - [Contact](https://indianaiproduction.com/contact/) ![Python Seaborn Tutorial](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/Python-Seaborn-Tutorial.png?fit=1024%2C576&ssl=1) # Seaborn Scatter Plot using sns.scatterplot() \| Python Seaborn Tutorial [Leave a Comment](https://indianaiproduction.com/seaborn-scatter-plot/#respond) / [Python Seaborn Tutorial](https://indianaiproduction.com/python-seaborn-tutorial/) / By [Indian AI Production](https://indianaiproduction.com/author/indianaiproduction/ "View all posts by Indian AI Production") If, you have x and y numeric or one of them a categorical dataset. You want to find the relationship between x and y to getting insights. Then the **seaborn scatter plot** function **sns.scatterplot()** will help. Along with sns.scatterplot() function, seaborn have multiple functions like sns.lmplot(), sns.relplot(), sns.pariplot(). But sns.scatterplot() is the best way to create **sns scatter plot**. > **Bonus:** > > 1\. Jupyter NoteBook file for download which contains all practical source code explained here. > > 2\. 4 examples with 2 different dataset ## What is seaborn scatter plot and Why use it? The **seaborn scatter plot** use to find the relationship between x and y variable. It may be both a numeric type or one of them a categorical data. The main goal is **data visualization** through the scatter plot. To get **insights** from the data then different data visualization methods usage is the best decision. Up to, we learn in [python seaborn tutorial](https://indianaiproduction.com/python-seaborn-tutorial-mastery-seaborn-library/). How to create a seaborn [line plot](https://indianaiproduction.com/seaborn-line-plot/), [histogram](https://indianaiproduction.com/seaborn-histogram-using-seaborn-distplot/), [barplot](https://indianaiproduction.com/seaborn-barplot/)? So, maybe you definitely observe these methods are not sufficient. ## How to create a seaborn scatter plot using sns.scatterplot() function? To create a scatter plot use **sns.scatterplot()** function. In this tutorial, we will learn how to create a sns scatter plot step by step. Here, we use multiple parameters, keyword arguments, and other [seaborn](https://indianaiproduction.com/python-seaborn-tutorial-mastery-seaborn-library/) and [matplotlib](https://indianaiproduction.com/python-matplotlib-tutorial/) functions. **Syntax: sns.scatterplot(** **x=None,** **y=None,** **hue=None,** **style=None,** **size=None,** **data=None,** **palette=None,** **hue\_order=None,** **hue\_norm=None,** **sizes=None,** **size\_order=None,** **size\_norm=None,** **markers=True,** **style\_order=None,** **x\_bins=None,** **y\_bins=None,** **units=None,** **estimator=None,** **ci=95,** **n\_boot=1000,** **alpha=’auto’,** **x\_jitter=None,** **y\_jitter=None,** **legend=’brief’,** **ax=None,** **\*\*kwargs,** **)** For the best understanding, I suggest you follow the [matplotlib scatter plot](https://indianaiproduction.com/matplotlib-scatter-plot/) tutorial. ### Import libraries As you can see, we import the Seaborn and Matplotlib pyplot module for data visualization. > **Note:** Practical perform on **Jupyter NoteBook** and at the end of this seaborn scatter plot tutorial, you will get ‘.**ipynb**‘ file for download. | | | |---|---| | 123456 | `# Import libraries` `import` `seaborn as sns``# for Data visualization` `import` `matplotlib.pyplot as plt``# for Data visualization` `#It used only for read_csv in this tutorial` `import` `pandas as pd``# for data analysis` | - **sns:** Short name was given to seaborn - **plt**: Short name was given to matplolib.pyplot module ### Import Dataset Here, we are importing or loading **“titanic.csv”** dataset from [GitHub Seaborn repository](http://thub.com/mwaskom/seaborn-data) using **sns.load\_dataset() function** but you can import your business dataset using [Pandas read\_csv](https://indianaiproduction.com/pandas-read-csv/) function. | | | |---|---| | 123 | `#Import dataset from GitHub Seborn Repository` `titanic_df``=` `sns.load_dataset(``"titanic"``)` `titanic_df``# call titanic DataFrame` | **or** | | | |---|---| | 123 | `# Import dataset from local folder using pandas read_csv function` `titanic_df``=` `pd.read_csv(``"C:\\Users\\IndianAIProduction\\seaborn-data\\titanic.csv"``)` `titanic_df``# call titanic DataFrame` | **Output \>\>\>** ![Titanic Data Frame](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/titanic-DataFrame.png?resize=858%2C544&ssl=1) ![Titanic Data Frame](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/titanic-DataFrame.png?resize=858%2C544&ssl=1) Titanic Data Frame #### What is Titanic DataFrame? I hope, you watched Titanic historical Hollywood movie. Titanic was a passenger ship which crashed. The “titanic.csv” contains all the information about that passenger. The ‘**titanic.csv’** DataFrame contains 891 rows and 15 columns. Using this DataFrame our a goal to scatter it first using seaborn sns.scatterplot() function and find insights. ![](https://upload.wikimedia.org/wikipedia/commons/thumb/6/6e/St%C3%B6wer_Titanic.jpg/300px-St%C3%B6wer_Titanic.jpg) ![](https://upload.wikimedia.org/wikipedia/commons/thumb/6/6e/St%C3%B6wer_Titanic.jpg/300px-St%C3%B6wer_Titanic.jpg) Titanic ship accident > Note: In this tutorial, we are not going to clean **‘titanic’** DataFrame but in real life project, you should first clean it and then visualize. ### Plot seaborn scatter plot using sns.scatterplot() x, y, data parameters Create a scatter plot is a simple task using **sns.scatterplot()** function just pass x, y, and data to it. you can follow any one method to create a scatter plot from given below. **1\. Method** | | | |---|---| | 12 | `# Draw Seaborn Scatter Plot to find relationship between age and fare` `sns.scatterplot(x``=` `"age"``, y``=` `"fare"``, data``=` `titanic_df)` | **2\. Method** | | | |---|---| | 12 | `# Draw Seaborn Scatter Plot to find relationship between age and fare` `sns.scatterplot(x``=` `titanic_df.age, y``=` `titanic_df.fare)` | **3\. Method** | | | |---|---| | 12 | `# Draw Seaborn Scatter Plot to find relationship between age and fare` `sns.scatterplot(x``=` `titanic_df[``'age'``], y``=` `titanic_df[``'fare'``])` | **Output \>\>\>** ![seaborn scatter plot](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/1-seaborn-scatter-plot.png?resize=392%2C266&ssl=1) ![seaborn scatter plot](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/1-seaborn-scatter-plot.png?resize=392%2C266&ssl=1) - **x, y:** Pass value as a name of variables or vector from DataFrame, optional - **data:** Pass DataFrame ### sns.scatterplot() hue parameter - **hue:** Pass value as a name of variables or vector from DataFrame, optional To distribute x and y variables with a third categorical variable using color. | | | |---|---| | 12 | `# scatter plot hue parameter` `sns.scatterplot(x``=` `"age"``, y``=` `"fare"``, data``=` `titanic_df, hue``=` `"sex"``)` | **output \>\>\>** ![seaborn scatter plot hue](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/2-seaborn-scatter-plot-hue.png?resize=392%2C266&ssl=1) ![seaborn scatter plot hue](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/2-seaborn-scatter-plot-hue.png?resize=392%2C266&ssl=1) ### sns.scatterplot() hue\_order parameter - **hue\_order:** Pass value as a tuple or Normalize object, optional As you can observe in above scatter plot, we used the **hue parameter** to distribute scatter plot in male and female. The order of that hue in this manner \[‘male’, ‘female’\] but your requirement is \[‘female’, ‘male’\]. Then **hue\_order parameter** will help to change hue categorical data order. | | | |---|---| | 123 | `# scatter plot hue_order parameter` `sns.scatterplot(x``=` `"age"``, y``=` `"fare"``, data``=` `titanic_df, hue``=` `"sex"``,` `               ``hue_order``=` `[``'female'``,``'male'``])` | **output \>\>\>** ![sns scatter plot hue\_order](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/3-sns-scatter-plot-hue_order.png?resize=392%2C266&ssl=1) ![sns scatter plot hue\_order](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/3-sns-scatter-plot-hue_order.png?resize=392%2C266&ssl=1) ### sns.scatterplot() size parameter - **size:** Pass value as a name of variables or vector from DataFrame, optional Its name tells us why to use it, to distribute scatter plot in size by passing the categorical or numeric variable. | | | |---|---| | 12 | `# scatter plot size parameter` `sns.scatterplot(x``=` `"age"``, y``=` `"fare"``, data``=` `titanic_df, size``=` `"who"``)` | **output \>\>\>** ![seaborn scatterplot size](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/4-seaborn-scatterplot-size.png?resize=392%2C266&ssl=1) ![seaborn scatterplot size](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/4-seaborn-scatterplot-size.png?resize=392%2C266&ssl=1) ### sns.scatterplot() sizes parameter - **sizes:** Pass value as a list, dict, or tuple, optional To minimize and maximize the size of the **size parameter**. | | | |---|---| | 123 | `# scatter plot sizes parameter` `sns.scatterplot(x``=` `"age"``, y``=` `"fare"``, data``=` `titanic_df, size``=` `"who"``,` `                ``sizes``=` `(``50``,``300``))` | **output \>\>\>** ![seaborn scatterplot sizes](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/5-seaborn-scatterplot-sizes.png?resize=392%2C266&ssl=1) ![seaborn scatterplot sizes](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/5-seaborn-scatterplot-sizes.png?resize=392%2C266&ssl=1) ### sns.scatterplot() size\_order parameter - **size\_order:** Pass value as a list, optional Same like hue\_order **size\_order parameter** change the size order of size variable. Current size order is \[‘man’, ‘woman’, ‘child’\] now we change like \[‘child’, ‘man’, ‘woman’\]. | | | |---|---| | 123 | `# scatter plot size_order parameter` `sns.scatterplot(x``=` `"age"``, y``=` `"fare"``, data``=` `titanic_df, size``=` `"who"``,` `                ``size_order``=``[``'child'``,``'man'``,``'woman'``],)` | **output \>\>\>** ![sns.scatterplot() size\_order](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/6-sns.scatterplot-size_order.png?resize=392%2C266&ssl=1) ![sns.scatterplot() size\_order](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/6-sns.scatterplot-size_order.png?resize=392%2C266&ssl=1) ### sns.scatterplot() style parameter - **style:** Pass value as a name of variables or vector from DataFrame, optional To change the style with a different marker. | | | |---|---| | 12 | `# scatter plot style parameter` `sns.scatterplot(x``=` `"age"``, y``=` `"fare"``, data``=` `titanic_df, style``=` `"who"``,)` | **Output \>\>\>** ![sns scatter plot style](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/7-sns-scatter-plot-style.png?resize=392%2C266&ssl=1) ![sns scatter plot style](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/7-sns-scatter-plot-style.png?resize=392%2C266&ssl=1) ### sns.scatterplot() style\_order parameter - **style\_order:** Pass value as a list, optional Like hue\_order, size\_order, **style\_order parameter** change the order of style levels. Here, we changed the style order \[‘man’, ‘woman’, ‘child’\] to \[‘child’,’woman’,’man’\]. | | | |---|---| | 12 | `# scatter plot style_order parameter` `sns.scatterplot(x``=` `"age"``, y``=` `"fare"``, data``=` `titanic_df, style``=` `"who"``, style_order``=``[``'child'``,``'woman'``,``'man'``])` | **Output \>\>\>** ![sns scatterplot style\_order](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/8-sns-scatterplot-style_order.png?resize=392%2C266&ssl=1) ![sns scatterplot style\_order](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/8-sns-scatterplot-style_order.png?resize=392%2C266&ssl=1) ### sns.scatterplot() palette parameter - **palette:** Pass value as a palette name, list, or dict, optional To change the color of the seaborn scatterplot. While using the palette, first mention hue parameter. Here, we pass the **hot** value to the **scatter plot palette** parameter. | | | |---|---| | 123 | `# scatter plot palette parameter` `sns.scatterplot(x``=` `"age"``, y``=` `"fare"``, data``=` `titanic_df, hue``=` `"sex"``,` `                ``palette``=``"hot"``)``# palette does not work without hue` | **Palette values:** Choose one of them | | | |---|---| | 123456 | `Possible values are: Accent, Accent_r, Blues, Blues_r, BrBG, BrBG_r, BuGn, BuGn_r, BuPu, BuPu_r, CMRmap, CMRmap_r, Dark2, Dark2_r, GnBu, GnBu_r, Greens, Greens_r, Greys, Greys_r, OrRd, OrRd_r, Oranges, Oranges_r, PRGn, PRGn_r, Paired, Paired_r, Pastel1, Pastel1_r, Pastel2, Pastel2_r, PiYG,` ` ``PiYG_r, PuBu, PuBuGn, PuBuGn_r, PuBu_r, PuOr, PuOr_r, PuRd, PuRd_r, Purples, Purples_r, RdBu, RdBu_r, RdGy, RdGy_r, RdPu, RdPu_r, RdYlBu, RdYlBu_r, RdYlGn, RdYlGn_r, Reds, Reds_r, Set1, Set1_r, Set2, Set2_r, Set3, Set3_r, Spectral, Spectral_r, Wistia, Wistia_r, YlGn, YlGnBu, YlGnBu_r,` ` ``YlGn_r, YlOrBr, YlOrBr_r, YlOrRd, YlOrRd_r, afmhot, afmhot_r, autumn, autumn_r, binary, binary_r, bone, bone_r, brg, brg_r, bwr, bwr_r, cividis, cividis_r, cool, cool_r, coolwarm, coolwarm_r, copper, copper_r, cubehelix, cubehelix_r, flag, flag_r, gist_earth, gist_earth_r, gist_gray, gist_gray_r,` ` ``gist_heat, gist_heat_r, gist_ncar, gist_ncar_r, gist_rainbow, gist_rainbow_r, gist_stern, gist_stern_r, gist_yarg, gist_yarg_r, gnuplot, gnuplot2, gnuplot2_r, gnuplot_r, gray, gray_r, hot, hot_r, hsv, hsv_r, icefire, icefire_r, inferno, inferno_r, jet, jet_r, magma, magma_r, mako,` ` ``mako_r, nipy_spectral, nipy_spectral_r, ocean, ocean_r, pink, pink_r, plasma, plasma_r, prism, prism_r, rainbow, rainbow_r, rocket, rocket_r, seismic, seismic_r, spring, spring_r, summer, summer_r, tab10, tab10_r, tab20, tab20_r, tab20b, tab20b_r, tab20c, tab20c_r, terrain, terrain_r,` ` ``twilight, twilight_r, twilight_shifted, twilight_shifted_r, viridis, viridis_r, vlag, vlag_r, winter, winter_r` | **Output \>\>\>** ![seaborn scatterplot palette](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/9-seaborn-scatterplot-palette.png?resize=392%2C266&ssl=1) ![seaborn scatterplot palette](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/9-seaborn-scatterplot-palette.png?resize=392%2C266&ssl=1) ### sns.scatterplot() markers parameter - **markers:** Pass value as a boolean, list, or dictionary, optional Use to change the marker of style categories. Below is the list of [matplotlib.markers](https://matplotlib.org/3.1.1/api/markers_api.html). | | | |---|---| | 1234567891011121314151617181920212223242526272829303132333435363738394041424344 | `============================== ====== ==============================` `marker                         symbol description` `============================== ====== ==============================` ` ``"."``                        |m00|  point ` ` ``","``                        |m01|  pixel ` ` ``"o"``                        |m02|  circle ` ` ``"v"``                        |m03|  triangle_down ` ` ``"^"``                        |m04|  triangle_up ` ` ``"<"``                        |m05|  triangle_left ` ` ``">"``                        |m06|  triangle_right ` ` ``"1"``                        |m07|  tri_down ` ` ``"2"``                        |m08|  tri_up ` ` ``"3"``                        |m09|  tri_left ` ` ``"4"``                        |m10|  tri_right ` ` ``"8"``                        |m11|  octagon ` ` ``"s"``                        |m12|  square ` ` ``"p"``                        |m13|  pentagon ` ` ``"P"``                        |m23|  plus (filled) ` ` ``"*"``                        |m14|  star ` ` ``"h"``                        |m15|  hexagon1 ` ` ``"H"``                        |m16|  hexagon2 ` ` ``"+"``                        |m17|  plus ` ` ``"x"``                        |m18|  x ` ` ``"X"``                        |m24|  x (filled) ` ` ``"D"``                        |m19|  diamond ` ` ``"d"``                        |m20|  thin_diamond ` ` ``"|"``                        |m21|  vline ` ` ``"_"``                        |m22|  hline ` ` ``0`` (``TICKLEFT``)           |m25|  tickleft ` ` ``1`` (``TICKRIGHT``)          |m26|  tickright ` ` ``2`` (``TICKUP``)             |m27|  tickup ` ` ``3`` (``TICKDOWN``)           |m28|  tickdown ` ` ``4`` (``CARETLEFT``)          |m29|  caretleft ` ` ``5`` (``CARETRIGHT``)         |m30|  caretright ` ` ``6`` (``CARETUP``)            |m31|  caretup ` ` ``7`` (``CARETDOWN``)          |m32|  caretdown ` ` ``8`` (``CARETLEFTBASE``)      |m33|  caretleft (centered at base) ` ` ``9`` (``CARETRIGHTBASE``)     |m34|  caretright (centered at base) ` ` ``10`` (``CARETUPBASE``)       |m35|  caretup (centered at base) ` ` ``11`` (``CARETDOWNBASE``)     |m36|  caretdown (centered at base) ` ` ``"None"``, ``" "`` or  ``""``        nothing ` ` ``'$...$'``                    |m37|  Render the string using mathtext. ` `                                      ``E.g ``"$f$"`` for marker showing the` `                                      ``letter ``f``.` | | | | |---|---| | 12 | `# scatter plot markers parameter` `sns.scatterplot(x``=` `"age"``, y``=` `"fare"``, data``=` `titanic_df, style``=` `"who"``, markers``=` `[``'3'``,``'1'``,``3``])` | **Output \>\>\>** ![sns.scatterplot() markers](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/10-sns.scatterplot-markers.png?resize=392%2C266&ssl=1) ![sns.scatterplot() markers](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/10-sns.scatterplot-markers.png?resize=392%2C266&ssl=1) ### sns.scatterplot() alpha parameter - **alpha:** Pass a float value between 0 to 1 To change the transparency of points. 0 value means full transparent point and 1 value means full clear. For nonvisibility pass 0 value to **scatter plot alpha** parameter. Here, we pass the **0\.4** float value. | | | |---|---| | 12 | `# scatter plot alpha parameter` `sns.scatterplot(x``=` `"age"``, y``=` `"fare"``, data``=` `titanic_df, alpha``=` `0.4``)` | **Output \>\>\>** ![sns.scatterplot() alpha](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/11-sns.scatterplot-alpha.png?resize=392%2C266&ssl=1) ![sns.scatterplot() alpha](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/11-sns.scatterplot-alpha.png?resize=392%2C266&ssl=1) ### sns.scatterplot() legend parameter - **legend:** Pass value as “full”, “brief” or False, optional When we used hue, style, size the scatter plot parameters then by default legend apply on it but you can change. Here, we don’t want to show legend, so we pass **False** value to **scatter plot legend parameter**. | | | |---|---| | 12 | `# scatter plot legend parameter` `sns.scatterplot(x``=` `"age"``, y``=` `"fare"``, data``=` `titanic_df, hue``=` `"sex"``, legend``=` `False` `)` | **Output \>\>\>** ![seaborn scatterplot legend](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/12-seaborn-scatterplot-legend.png?resize=392%2C266&ssl=1) ![seaborn scatterplot legend](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/12-seaborn-scatterplot-legend.png?resize=392%2C266&ssl=1) ### sns.scatterplot() ax (Axes) parameter - **ax (Axes):** Pass value as a matplotlib Axes, optional Use multiple methods to change the sns scatter plot format and style using the **seaborn scatter plot ax** (Axes) parameter. here, used **ax.set()** method to change the scatter plot x-axis, y-axis label, and title. | | | |---|---| | 12345 | `ax``=` `sns.scatterplot(x``=` `"age"``, y``=` `"fare"``, data``=` `titanic_df, )` `ax.``set``(xlabel``=` `"Age"``,` `      ``ylabel``=` `"Fare"``,` `      ``title``=` `"Seaborn Scatter Plot of Age and Fare"``)` | **Output \>\>\>** ![sns scatterplot ax (axes)](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/13-sns-scatterplot-ax-axes.png?resize=392%2C278&ssl=1) ![sns scatterplot ax (axes)](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/13-sns-scatterplot-ax-axes.png?resize=392%2C278&ssl=1) ### sns.scatterplot() kwargs (Keyword Arguments) parameter - **kwargs (Keyword Arguments):** Pass the key and value mapping as a dictionary If you want to the artistic look of scatter plot then you must have to use the **seaborn scatter plot kwargs** (keyword arguments). The **seaborn sns.scatterplot()** allow all kwargs of [matplotlib plt.scatter()](https://indianaiproduction.com/matplotlib-scatter-plot/) like: - **edgecolor:** Change the edge color of the scatter point. Pass value as a color code, name or hex code. - **facecolor:** Change the face (point) color of the scatter plot. Pass value as a color code, name or hex code. - **linewidth:** Change line width of scatter plot. Pass float or int value - **linestyle:** Change the line style of the scatter plot. Pass line style has given below in the table. **Color Parameter Values** | | | |---|---| | **Character** | **Color** | | **b** | **blue** | | **g** | **green** | | **r** | **red** | | **c** | **cyan** | | **m** | **magenta** | | **y** | **yellow** | | **k** | **black** | | **w** | **white** | **Line Style parameter values** | | | |---|---| | **Character** | **Description** | | **\_** | **solid line style** | | **—** | **dashed line style** | | **\_.** | **dash-dot line style** | | **:** | **dotted line style** | | | | |---|---| | 12345678910 | `# scatter plot kwrgs (keyword arguments)` `plt.figure(figsize``=``(``16``,``9``))``# figure size in 16:9 ratio` `kwargs ``=` `{``'edgecolor'``:``"r"``,` `             ``'facecolor'``:``"k"``,` `             ``'linewidth'``:``2.7``,` `             ``'linestyle'``:``'--'``,` `            ``}` `sns.scatterplot(x``=` `"age"``, y``=` `"fare"``, data``=` `titanic_df, size``=` `"sex"``, sizes``=` `(``500``,``1000``), alpha``=` `.``7``, ``*``*``kwargs)` | **Or**, you can also pass kwargs as a parameter. Output remain will be the same. | | | |---|---| | 123456789 | `# scatter plot kwrgs (keyword arguments) parameter` `plt.figure(figsize=(16,9)) # figure size in 16:9 ratio` `sns.scatterplot(x = "age", y = "fare", data = titanic_df, size = "sex", sizes = (500, 1000), alpha = .7,` `               ``edgecolor='r',` `                ``facecolor="k",` `                ``linewidth=2.7,` `                ``linestyle='--',` `               ``)` | Output \>\>\> ![seaborn scatter plot kwargs](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/14-seaborn-scatter-plot-kwargs.png?resize=950%2C538&ssl=1) ![seaborn scatter plot kwargs](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/14-seaborn-scatter-plot-kwargs.png?resize=950%2C538&ssl=1) ## Python Seaborn Scatter Plot Examples ### 1\. sns Scatter Plot Example | | | |---|---| | 12345678910111213141516171819202122 | `# Seaborn Scatter Plot Example 1 created by www.IndianAIProduction.com` `# Import libraries` `import` `seaborn as sns``# for Data visualization` `import` `matplotlib.pyplot as plt``# for Data visualization` `sns.``set``()``#  set background 'darkgrid'` `#Import 'titanic' dataset from GitHub Seborn Repository` `titanic_df``=` `sns.load_dataset(``"titanic"``)` `plt.figure(figsize``=` `(``16``,``9``))``# figure size in 16:9 ratio` `# create scatter plot` `sns.scatterplot(x``=` `"age"``, y``=` `"fare"``, data``=` `titanic_df, hue``=` `"sex"``, palette``=` `"magma"``,size``=` `"who"``,` `                ``sizes``=` `(``50``,``300``))` `plt.title(``"Scatter Plot of Age and Fare"``, fontsize``=` `25``)``# title of scatter plot` `plt.xlabel(``"Age"``, fontsize``=` `20``)``# x-axis label` `plt.ylabel(``"Fare"``, fontsize``=` `20``)``# y-axis label` `plt.savefig(``"Scatter Plot of Age and Fare"``)``# save generated scatter plot at program location` `plt.show()``# show scatter plot` | **Output \>\>\>** ![seaborn scatter plot example](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/15-seaborn-scatter-plot-example-1.png?resize=964%2C570&ssl=1) ![seaborn scatter plot example](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/15-seaborn-scatter-plot-example-1.png?resize=964%2C570&ssl=1) ### 2\. sns Scatter Plot Example | | | |---|---| | 12345678910111213141516171819202122 | `# Seaborn Scatter Plot Example 2 created by www.IndianAIProduction.com` `# Import libraries` `import` `seaborn as sns``# for Data visualization` `import` `matplotlib.pyplot as plt``# for Data visualization` `sns.``set``()``#  set background 'darkgrid'` `#Import 'titanic' dataset from GitHub Seborn Repository` `titanic_df``=` `sns.load_dataset(``"titanic"``)` `plt.figure(figsize``=` `(``16``,``9``))``# figure size in 16:9 ratio` `# create scatter plot` `sns.scatterplot(x``=` `"who"``, y``=` `"fare"``, data``=` `titanic_df, hue``=` `"alive"``, style``=` `"alive"``, palette``=` `"viridis"``,size``=` `"who"``,` `                ``sizes``=` `(``200``,``500``))` `plt.title(``"Scatter Plot of Age and Fare"``, fontsize``=` `25``)``# title of scatter plot` `plt.xlabel(``"Age"``, fontsize``=` `20``)``# x-axis label` `plt.ylabel(``"Fare"``, fontsize``=` `20``)``# y-axis label` `plt.savefig(``"Scatter Plot of Age and Fare"``)``# save generated scatter plot at program location` `plt.show()``# show scatter plot` | **Output \>\>\>** ![seaborn scatter plot example](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/16-seaborn-scatter-plot-example-2.png?resize=964%2C570&ssl=1) ![seaborn scatter plot example](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/16-seaborn-scatter-plot-example-2.png?resize=964%2C570&ssl=1) ### 3\. sns Scatter Plot Example | | | |---|---| | 12345678910111213141516171819202122 | `# Seaborn Scatter Plot Example 3 created by www.IndianAIProduction.com` `# Import libraries` `import` `seaborn as sns``# for Data visualization` `import` `matplotlib.pyplot as plt``# for Data visualization` `sns.``set``()``#  set background 'darkgrid'` `#Import 'tips' dataset from GitHub Seborn Repository` `tips_df``=` `sns.load_dataset(``"tips"``)` `plt.figure(figsize``=` `(``16``,``9``))``# figure size in 16:9 ratio` `# create scatter plot` `sns.scatterplot(x``=` `"tip"``, y``=` `"total_bill"``, data``=` `tips_df, hue``=` `"sex"``, palette``=` `"hot"``,` `                ``size``=` `"day"``,sizes``=` `(``50``,``300``), alpha``=` `0.7``)` `plt.title(``"Scatter Plot of Tip and Total Bill"``, fontsize``=` `25``)``# title of scatter plot` `plt.xlabel(``"Tip"``, fontsize``=` `20``)``# x-axis label` `plt.ylabel(``"Total Bill"``, fontsize``=` `20``)``# y-axis label` `plt.savefig(``"Scatter Plot of Tip and Total Bill"``)``# save generated scatter plot at program location` `plt.show()``# show scatter plot` | **Output \>\>\>** ![seaborn scatter plot example](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/17-seaborn-scatter-plot-example-3.png?resize=958%2C570&ssl=1) ![seaborn scatter plot example](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/17-seaborn-scatter-plot-example-3.png?resize=958%2C570&ssl=1) ### 4\. sns Scatter Plot Example | | | |---|---| | 123456789101112131415161718192021222324252627 | `# Seaborn Scatter Plot Example 4 created by www.IndianAIProduction.com` `# Import libraries` `import` `seaborn as sns``# for Data visualization` `import` `matplotlib.pyplot as plt``# for Data visualization` `sns.``set``()``#  set background 'darkgrid'` `#Import 'tips' dataset from GitHub Seborn Repository` `tips_df``=` `sns.load_dataset(``"tips"``)` `plt.figure(figsize``=` `(``16``,``9``))``# figure size in 16:9 ratio` `# create scatter plot` `kwargs ``=` `{``'edgecolor'``:``"w"``,` `             ``'linewidth'``:``2``,` `             ``'linestyle'``:``':'``,` `            ``}` `sns.scatterplot(x``=` `"tip"``, y``=` `"total_bill"``, data``=` `tips_df, hue``=` `"sex"``, palette``=` `"ocean_r"``,` `                ``size``=` `"day"``,sizes``=` `(``200``,``500``),``*``*``kwargs)` `plt.title(``"Scatter Plot of Tip and Total Bill"``, fontsize``=` `25``)``# title of scatter plot` `plt.xlabel(``"Tip"``, fontsize``=` `20``)``# x-axis label` `plt.ylabel(``"Total Bill"``, fontsize``=` `20``)``# y-axis label` `plt.savefig(``"Scatter Plot of Tip and Total Bill"``)``# save generated scatter plot at program location` `plt.show()``# show scatter plot` | **Output \>\>\>** ![seaborn scatter plot example](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/18-seaborn-scatter-plot-example-4.png?resize=958%2C570&ssl=1) ![seaborn scatter plot example](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/18-seaborn-scatter-plot-example-4.png?resize=958%2C570&ssl=1) ### Conclusion In the **seaborn scatter plot tutorial,** we learn how to create a seaborn scatter plot with a real-time example using **sns.barplot()** function. Along with that used different functions, parameter, and keyword arguments(kwargs). We suggest you make your hand dirty with each and every parameter of the above function because This is the best coding practice. Still, you didn’t complete [matplotlib tutorial](https://indianaiproduction.com/python-matplotlib-tutorial/) then I recommend to you, catch it. Download above **seaborn scatter plot source code** in Jupyter NoteBook file formate. [Download Seaborn Scatter Plot Practical Source Code](https://drive.google.com/file/d/1r5tyWtYZ_iOonGtqKzDLTTmRBIhETNAy/view?usp=sharing) ### Share this: - [Twitter](https://indianaiproduction.com/seaborn-scatter-plot/?share=twitter&nb=1 "Click to share on Twitter") - [Facebook](https://indianaiproduction.com/seaborn-scatter-plot/?share=facebook&nb=1 "Click to share on Facebook") - [LinkedIn](https://indianaiproduction.com/seaborn-scatter-plot/?share=linkedin&nb=1 "Click to share on LinkedIn") - [Telegram](https://indianaiproduction.com/seaborn-scatter-plot/?share=telegram&nb=1 "Click to share on Telegram") - [WhatsApp](https://indianaiproduction.com/seaborn-scatter-plot/?share=jetpack-whatsapp&nb=1 "Click to share on WhatsApp") - [More](https://indianaiproduction.com/seaborn-scatter-plot/) - [Reddit](https://indianaiproduction.com/seaborn-scatter-plot/?share=reddit&nb=1 "Click to share on Reddit") - [Tumblr](https://indianaiproduction.com/seaborn-scatter-plot/?share=tumblr&nb=1 "Click to share on Tumblr") - [Pinterest](https://indianaiproduction.com/seaborn-scatter-plot/?share=pinterest&nb=1 "Click to share on Pinterest") - [Pocket](https://indianaiproduction.com/seaborn-scatter-plot/?share=pocket&nb=1 "Click to share on Pocket") - [Skype](https://indianaiproduction.com/seaborn-scatter-plot/?share=skype&nb=1 "Click to share on Skype") - [Email](mailto:?subject=%5BShared%20Post%5D%20Seaborn%20Scatter%20%20Plot%20using%20sns.scatterplot%28%29%20%7C%20Python%20Seaborn%20Tutorial&body=https%3A%2F%2Findianaiproduction.com%2Fseaborn-scatter-plot%2F&share=email&nb=1 "Click to email a link to a friend") ### *Related* [![Python Seaborn Tutorial](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/Python-Seaborn-Tutorial.png?fit=1200%2C675&ssl=1&resize=350%2C200)](https://indianaiproduction.com/seaborn-pairplot/ "Seaborn Pairplot in Detail| Python Seaborn Tutorial") #### [Seaborn Pairplot in Detail\| Python Seaborn Tutorial](https://indianaiproduction.com/seaborn-pairplot/ "Seaborn Pairplot in Detail| Python Seaborn Tutorial") Seaborn Pairplot uses to get the relation between each and every variable present in Pandas DataFrame. It works like a seaborn scatter plot but it plot only two variables plot and sns paiplot plot the pairwise plot of multiple features/variable in a grid format. How to plot Seaborn Pairplot? To… In "Python Seaborn Tutorial" [![Python Seaborn Tutorial](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/Python-Seaborn-Tutorial.png?fit=1200%2C675&ssl=1&resize=350%2C200)](https://indianaiproduction.com/python-seaborn-tutorial-mastery-seaborn-library/ "Python Seaborn Tutorial &#8211; Mastery in Seaborn Library") #### [Python Seaborn Tutorial – Mastery in Seaborn Library](https://indianaiproduction.com/python-seaborn-tutorial-mastery-seaborn-library/ "Python Seaborn Tutorial &#8211; Mastery in Seaborn Library") If you are working on data and try to find out insights from it. Then data visualization is the best way for that Python seaborn library is the best choice. Now, you are wondering about matplotlib because it also uses of data visualization. Don't worry, we will discuss it later.… In "Python Seaborn Tutorial" [![Python Seaborn Tutorial](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/Python-Seaborn-Tutorial.png?fit=1200%2C675&ssl=1&resize=350%2C200)](https://indianaiproduction.com/seaborn-line-plot/ "Seaborn Line Plot &#8211; Draw Multiple Line Plot | Python Seaborn Tutorial") #### [Seaborn Line Plot – Draw Multiple Line Plot \| Python Seaborn Tutorial](https://indianaiproduction.com/seaborn-line-plot/ "Seaborn Line Plot &#8211; Draw Multiple Line Plot | Python Seaborn Tutorial") If you have two numeric variable datasets and worry about what relationship between them. Then Python seaborn line plot function will help to find it. Seaborn library provides sns.lineplot() function to draw a line graph of two numeric variables like x and y. Lest jump on practical. Import Libraries import… In "Python Seaborn Tutorial" Post navigation [← Previous Post](https://indianaiproduction.com/seaborn-barplot/) [Next Post →](https://indianaiproduction.com/seaborn-heatmap/) ### Leave a Reply [Cancel reply](https://indianaiproduction.com/seaborn-scatter-plot/#respond) ## Join Our Community Enter your email address to register to our newsletter subscription delivered on regular basis\! ## Pages - [Courses](https://indianaiproduction.com/courses/) - [About Us](https://indianaiproduction.com/about-us/) - [Disclaimer](https://indianaiproduction.com/disclaimer/) - [Privacy Policy](https://indianaiproduction.com/privacy-policy/) - [Terms & Conditions](https://indianaiproduction.com/terms-conditions/) [![](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/06/cropped-Channel-logo-in-square-150-x-150-px.png?fit=100%2C100&ssl=1)](https://indianaiproduction.com/) Indian AI Production provide online training in disciplines such as Artificial Intelligence, Machine Learning, Deep Learning, and Data Science among others, where technologies and best practices are changing rapidly. ## Categories - [Deep Learning Projects](https://indianaiproduction.com/deep-learning-projects/) (7) - [Feature Engineering](https://indianaiproduction.com/feature-engineering/) (4) - [Interview Preparation](https://indianaiproduction.com/interview-preparation/) (1) - [Machine Learning Algorithms](https://indianaiproduction.com/machine-learning-algorithms/) (14) - [ML Projects](https://indianaiproduction.com/ml-projects/) (6) - [OpenCV Project](https://indianaiproduction.com/opencv-project/) (30) - [Python Matplotlib Tutorial](https://indianaiproduction.com/python-matplotlib-tutorial-mastery-in-matplotlib-library/) (9) - [Python NumPy Tutorial](https://indianaiproduction.com/python-numpy-tutorial-mastery-in-numpy-library/) (8) - [Python Pandas Tutorial](https://indianaiproduction.com/python-pandas-tutorial/) (9) - [Python Seaborn Tutorial](https://indianaiproduction.com/python-seaborn-tutorial/) (7) - [Python Tutorial](https://indianaiproduction.com/python-tutorial/) (2) - [Resume](https://indianaiproduction.com/interview-preparation/resume-interview-preparation/) (1) - [Statistics for Machine Learning](https://indianaiproduction.com/statistics-for-machine-learning/) (1) - [TensorFlow 2.x Tutorial](https://indianaiproduction.com/tensorflow-2-x-tutorial/) (14) ## Resent Posts - [ML Project – Seoul Bike Sharing Demand Prediction Project](https://indianaiproduction.com/seoul-bike-sharing-demand-prediction-ml-project/) - [Write World’s Best Resume – 10 Techniques Explained Step By Step](https://indianaiproduction.com/write-best-resume-format/) - [How To Get Minimum Value From Tensors In TensorFlow?](https://indianaiproduction.com/tensorflow-minimum-function/) ## Popular Courses - [Expert in Data Science](https://indianaiproduction.com/data-science/) - [Expert in Artificial Intelligence](https://indianaiproduction.com/artificial-intelligence/) - [Expert in Machine Learning](https://indianaiproduction.com/machine-learning/) - [Expert in Python](https://indianaiproduction.com/data-science/) - [Expert in Deep Learning](https://indianaiproduction.com/data-science/) - [Expert in Computer Vision](https://indianaiproduction.com/data-science/) - [Expert in Natural Language Processing](https://indianaiproduction.com/data-science/) ## Contact Info **Address** Hitech City, Hyderabad, India **Phone** 7123595622 **Email** indianaiproduction.business@gmail.com Copyright © 2026 Indian AI Production Powered by Indian AI Production
Readable Markdown
If, you have x and y numeric or one of them a categorical dataset. You want to find the relationship between x and y to getting insights. Then the **seaborn scatter plot** function **sns.scatterplot()** will help. Along with sns.scatterplot() function, seaborn have multiple functions like sns.lmplot(), sns.relplot(), sns.pariplot(). But sns.scatterplot() is the best way to create **sns scatter plot**. > **Bonus:** > > 1\. Jupyter NoteBook file for download which contains all practical source code explained here. > > 2\. 4 examples with 2 different dataset ## What is seaborn scatter plot and Why use it? The **seaborn scatter plot** use to find the relationship between x and y variable. It may be both a numeric type or one of them a categorical data. The main goal is **data visualization** through the scatter plot. To get **insights** from the data then different data visualization methods usage is the best decision. Up to, we learn in [python seaborn tutorial](https://indianaiproduction.com/python-seaborn-tutorial-mastery-seaborn-library/). How to create a seaborn [line plot](https://indianaiproduction.com/seaborn-line-plot/), [histogram](https://indianaiproduction.com/seaborn-histogram-using-seaborn-distplot/), [barplot](https://indianaiproduction.com/seaborn-barplot/)? So, maybe you definitely observe these methods are not sufficient. ## How to create a seaborn scatter plot using sns.scatterplot() function? To create a scatter plot use **sns.scatterplot()** function. In this tutorial, we will learn how to create a sns scatter plot step by step. Here, we use multiple parameters, keyword arguments, and other [seaborn](https://indianaiproduction.com/python-seaborn-tutorial-mastery-seaborn-library/) and [matplotlib](https://indianaiproduction.com/python-matplotlib-tutorial/) functions. **Syntax: sns.scatterplot(** **x=None,** **y=None,** **hue=None,** **style=None,** **size=None,** **data=None,** **palette=None,** **hue\_order=None,** **hue\_norm=None,** **sizes=None,** **size\_order=None,** **size\_norm=None,** **markers=True,** **style\_order=None,** **x\_bins=None,** **y\_bins=None,** **units=None,** **estimator=None,** **ci=95,** **n\_boot=1000,** **alpha=’auto’,** **x\_jitter=None,** **y\_jitter=None,** **legend=’brief’,** **ax=None,** **\*\*kwargs,** **)** For the best understanding, I suggest you follow the [matplotlib scatter plot](https://indianaiproduction.com/matplotlib-scatter-plot/) tutorial. ### Import libraries As you can see, we import the Seaborn and Matplotlib pyplot module for data visualization. > **Note:** Practical perform on **Jupyter NoteBook** and at the end of this seaborn scatter plot tutorial, you will get ‘.**ipynb**‘ file for download. | | | |---|---| | 123456 | `import` `seaborn as sns` `import` `matplotlib.pyplot as plt` `import` `pandas as pd` | - **sns:** Short name was given to seaborn - **plt**: Short name was given to matplolib.pyplot module ### Import Dataset Here, we are importing or loading **“titanic.csv”** dataset from [GitHub Seaborn repository](http://thub.com/mwaskom/seaborn-data) using **sns.load\_dataset() function** but you can import your business dataset using [Pandas read\_csv](https://indianaiproduction.com/pandas-read-csv/) function. | | | |---|---| | 123 | `titanic_df``=` `sns.load_dataset(``"titanic"``)` `titanic_df` | **or** | | | |---|---| | 123 | `titanic_df``=` `pd.read_csv(``"C:\\Users\\IndianAIProduction\\seaborn-data\\titanic.csv"``)` `titanic_df` | **Output \>\>\>** ![Titanic Data Frame](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/titanic-DataFrame.png?resize=858%2C544&ssl=1) Titanic Data Frame #### What is Titanic DataFrame? I hope, you watched Titanic historical Hollywood movie. Titanic was a passenger ship which crashed. The “titanic.csv” contains all the information about that passenger. The ‘**titanic.csv’** DataFrame contains 891 rows and 15 columns. Using this DataFrame our a goal to scatter it first using seaborn sns.scatterplot() function and find insights. ![](https://upload.wikimedia.org/wikipedia/commons/thumb/6/6e/St%C3%B6wer_Titanic.jpg/300px-St%C3%B6wer_Titanic.jpg) Titanic ship accident > Note: In this tutorial, we are not going to clean **‘titanic’** DataFrame but in real life project, you should first clean it and then visualize. ### Plot seaborn scatter plot using sns.scatterplot() x, y, data parameters Create a scatter plot is a simple task using **sns.scatterplot()** function just pass x, y, and data to it. you can follow any one method to create a scatter plot from given below. **1\. Method** | | | |---|---| | 12 | `sns.scatterplot(x``=` `"age"``, y``=` `"fare"``, data``=` `titanic_df)` | **2\. Method** | | | |---|---| | 12 | `sns.scatterplot(x``=` `titanic_df.age, y``=` `titanic_df.fare)` | **3\. Method** | | | |---|---| | 12 | `sns.scatterplot(x``=` `titanic_df[``'age'``], y``=` `titanic_df[``'fare'``])` | **Output \>\>\>** ![seaborn scatter plot](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/1-seaborn-scatter-plot.png?resize=392%2C266&ssl=1) - **x, y:** Pass value as a name of variables or vector from DataFrame, optional - **data:** Pass DataFrame ### sns.scatterplot() hue parameter - **hue:** Pass value as a name of variables or vector from DataFrame, optional To distribute x and y variables with a third categorical variable using color. | | | |---|---| | 12 | `sns.scatterplot(x``=` `"age"``, y``=` `"fare"``, data``=` `titanic_df, hue``=` `"sex"``)` | **output \>\>\>** ![seaborn scatter plot hue](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/2-seaborn-scatter-plot-hue.png?resize=392%2C266&ssl=1) ### sns.scatterplot() hue\_order parameter - **hue\_order:** Pass value as a tuple or Normalize object, optional As you can observe in above scatter plot, we used the **hue parameter** to distribute scatter plot in male and female. The order of that hue in this manner \[‘male’, ‘female’\] but your requirement is \[‘female’, ‘male’\]. Then **hue\_order parameter** will help to change hue categorical data order. | | | |---|---| | 123 | `sns.scatterplot(x``=` `"age"``, y``=` `"fare"``, data``=` `titanic_df, hue``=` `"sex"``,` `               ``hue_order``=` `[``'female'``,``'male'``])` | **output \>\>\>** ![sns scatter plot hue\_order](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/3-sns-scatter-plot-hue_order.png?resize=392%2C266&ssl=1) ### sns.scatterplot() size parameter - **size:** Pass value as a name of variables or vector from DataFrame, optional Its name tells us why to use it, to distribute scatter plot in size by passing the categorical or numeric variable. | | | |---|---| | 12 | `sns.scatterplot(x``=` `"age"``, y``=` `"fare"``, data``=` `titanic_df, size``=` `"who"``)` | **output \>\>\>** ![seaborn scatterplot size](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/4-seaborn-scatterplot-size.png?resize=392%2C266&ssl=1) ### sns.scatterplot() sizes parameter - **sizes:** Pass value as a list, dict, or tuple, optional To minimize and maximize the size of the **size parameter**. | | | |---|---| | 123 | `sns.scatterplot(x``=` `"age"``, y``=` `"fare"``, data``=` `titanic_df, size``=` `"who"``,` `                ``sizes``=` `(``50``,``300``))` | **output \>\>\>** ![seaborn scatterplot sizes](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/5-seaborn-scatterplot-sizes.png?resize=392%2C266&ssl=1) ### sns.scatterplot() size\_order parameter - **size\_order:** Pass value as a list, optional Same like hue\_order **size\_order parameter** change the size order of size variable. Current size order is \[‘man’, ‘woman’, ‘child’\] now we change like \[‘child’, ‘man’, ‘woman’\]. | | | |---|---| | 123 | `sns.scatterplot(x``=` `"age"``, y``=` `"fare"``, data``=` `titanic_df, size``=` `"who"``,` `                ``size_order``=``[``'child'``,``'man'``,``'woman'``],)` | **output \>\>\>** ![sns.scatterplot() size\_order](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/6-sns.scatterplot-size_order.png?resize=392%2C266&ssl=1) ### sns.scatterplot() style parameter - **style:** Pass value as a name of variables or vector from DataFrame, optional To change the style with a different marker. | | | |---|---| | 12 | `sns.scatterplot(x``=` `"age"``, y``=` `"fare"``, data``=` `titanic_df, style``=` `"who"``,)` | **Output \>\>\>** ![sns scatter plot style](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/7-sns-scatter-plot-style.png?resize=392%2C266&ssl=1) ### sns.scatterplot() style\_order parameter - **style\_order:** Pass value as a list, optional Like hue\_order, size\_order, **style\_order parameter** change the order of style levels. Here, we changed the style order \[‘man’, ‘woman’, ‘child’\] to \[‘child’,’woman’,’man’\]. | | | |---|---| | 12 | `sns.scatterplot(x``=` `"age"``, y``=` `"fare"``, data``=` `titanic_df, style``=` `"who"``, style_order``=``[``'child'``,``'woman'``,``'man'``])` | **Output \>\>\>** ![sns scatterplot style\_order](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/8-sns-scatterplot-style_order.png?resize=392%2C266&ssl=1) ### sns.scatterplot() palette parameter - **palette:** Pass value as a palette name, list, or dict, optional To change the color of the seaborn scatterplot. While using the palette, first mention hue parameter. Here, we pass the **hot** value to the **scatter plot palette** parameter. | | | |---|---| | 123 | `sns.scatterplot(x``=` `"age"``, y``=` `"fare"``, data``=` `titanic_df, hue``=` `"sex"``,` `                ``palette``=``"hot"``)` | **Palette values:** Choose one of them | | | |---|---| | 123456 | `Possible values are: Accent, Accent_r, Blues, Blues_r, BrBG, BrBG_r, BuGn, BuGn_r, BuPu, BuPu_r, CMRmap, CMRmap_r, Dark2, Dark2_r, GnBu, GnBu_r, Greens, Greens_r, Greys, Greys_r, OrRd, OrRd_r, Oranges, Oranges_r, PRGn, PRGn_r, Paired, Paired_r, Pastel1, Pastel1_r, Pastel2, Pastel2_r, PiYG,` ` ``PiYG_r, PuBu, PuBuGn, PuBuGn_r, PuBu_r, PuOr, PuOr_r, PuRd, PuRd_r, Purples, Purples_r, RdBu, RdBu_r, RdGy, RdGy_r, RdPu, RdPu_r, RdYlBu, RdYlBu_r, RdYlGn, RdYlGn_r, Reds, Reds_r, Set1, Set1_r, Set2, Set2_r, Set3, Set3_r, Spectral, Spectral_r, Wistia, Wistia_r, YlGn, YlGnBu, YlGnBu_r,` ` ``YlGn_r, YlOrBr, YlOrBr_r, YlOrRd, YlOrRd_r, afmhot, afmhot_r, autumn, autumn_r, binary, binary_r, bone, bone_r, brg, brg_r, bwr, bwr_r, cividis, cividis_r, cool, cool_r, coolwarm, coolwarm_r, copper, copper_r, cubehelix, cubehelix_r, flag, flag_r, gist_earth, gist_earth_r, gist_gray, gist_gray_r,` ` ``gist_heat, gist_heat_r, gist_ncar, gist_ncar_r, gist_rainbow, gist_rainbow_r, gist_stern, gist_stern_r, gist_yarg, gist_yarg_r, gnuplot, gnuplot2, gnuplot2_r, gnuplot_r, gray, gray_r, hot, hot_r, hsv, hsv_r, icefire, icefire_r, inferno, inferno_r, jet, jet_r, magma, magma_r, mako,` ` ``mako_r, nipy_spectral, nipy_spectral_r, ocean, ocean_r, pink, pink_r, plasma, plasma_r, prism, prism_r, rainbow, rainbow_r, rocket, rocket_r, seismic, seismic_r, spring, spring_r, summer, summer_r, tab10, tab10_r, tab20, tab20_r, tab20b, tab20b_r, tab20c, tab20c_r, terrain, terrain_r,` ` ``twilight, twilight_r, twilight_shifted, twilight_shifted_r, viridis, viridis_r, vlag, vlag_r, winter, winter_r` | **Output \>\>\>** ![seaborn scatterplot palette](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/9-seaborn-scatterplot-palette.png?resize=392%2C266&ssl=1) ### sns.scatterplot() markers parameter - **markers:** Pass value as a boolean, list, or dictionary, optional Use to change the marker of style categories. Below is the list of [matplotlib.markers](https://matplotlib.org/3.1.1/api/markers_api.html). | | | |---|---| | 1234567891011121314151617181920212223242526272829303132333435363738394041424344 | `============================== ====== ==============================` `marker                         symbol description` `============================== ====== ==============================` ` ``"."``                        |m00|  point ` ` ``","``                        |m01|  pixel ` ` ``"o"``                        |m02|  circle ` ` ``"v"``                        |m03|  triangle_down ` ` ``"^"``                        |m04|  triangle_up ` ` ``"<"``                        |m05|  triangle_left ` ` ``">"``                        |m06|  triangle_right ` ` ``"1"``                        |m07|  tri_down ` ` ``"2"``                        |m08|  tri_up ` ` ``"3"``                        |m09|  tri_left ` ` ``"4"``                        |m10|  tri_right ` ` ``"8"``                        |m11|  octagon ` ` ``"s"``                        |m12|  square ` ` ``"p"``                        |m13|  pentagon ` ` ``"P"``                        |m23|  plus (filled) ` ` ``"*"``                        |m14|  star ` ` ``"h"``                        |m15|  hexagon1 ` ` ``"H"``                        |m16|  hexagon2 ` ` ``"+"``                        |m17|  plus ` ` ``"x"``                        |m18|  x ` ` ``"X"``                        |m24|  x (filled) ` ` ``"D"``                        |m19|  diamond ` ` ``"d"``                        |m20|  thin_diamond ` ` ``"|"``                        |m21|  vline ` ` ``"_"``                        |m22|  hline ` ` ``0`` (``TICKLEFT``)           |m25|  tickleft ` ` ``1`` (``TICKRIGHT``)          |m26|  tickright ` ` ``2`` (``TICKUP``)             |m27|  tickup ` ` ``3`` (``TICKDOWN``)           |m28|  tickdown ` ` ``4`` (``CARETLEFT``)          |m29|  caretleft ` ` ``5`` (``CARETRIGHT``)         |m30|  caretright ` ` ``6`` (``CARETUP``)            |m31|  caretup ` ` ``7`` (``CARETDOWN``)          |m32|  caretdown ` ` ``8`` (``CARETLEFTBASE``)      |m33|  caretleft (centered at base) ` ` ``9`` (``CARETRIGHTBASE``)     |m34|  caretright (centered at base) ` ` ``10`` (``CARETUPBASE``)       |m35|  caretup (centered at base) ` ` ``11`` (``CARETDOWNBASE``)     |m36|  caretdown (centered at base) ` ` ``"None"``, ``" "`` or  ``""``        nothing ` ` ``'$...$'``                    |m37|  Render the string using mathtext. ` `                                      ``E.g ``"$f$"`` for marker showing the` `                                      ``letter ``f``.` | | | | |---|---| | 12 | `sns.scatterplot(x``=` `"age"``, y``=` `"fare"``, data``=` `titanic_df, style``=` `"who"``, markers``=` `[``'3'``,``'1'``,``3``])` | **Output \>\>\>** ![sns.scatterplot() markers](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/10-sns.scatterplot-markers.png?resize=392%2C266&ssl=1) ### sns.scatterplot() alpha parameter - **alpha:** Pass a float value between 0 to 1 To change the transparency of points. 0 value means full transparent point and 1 value means full clear. For nonvisibility pass 0 value to **scatter plot alpha** parameter. Here, we pass the **0\.4** float value. | | | |---|---| | 12 | `sns.scatterplot(x``=` `"age"``, y``=` `"fare"``, data``=` `titanic_df, alpha``=` `0.4``)` | **Output \>\>\>** ![sns.scatterplot() alpha](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/11-sns.scatterplot-alpha.png?resize=392%2C266&ssl=1) ### sns.scatterplot() legend parameter - **legend:** Pass value as “full”, “brief” or False, optional When we used hue, style, size the scatter plot parameters then by default legend apply on it but you can change. Here, we don’t want to show legend, so we pass **False** value to **scatter plot legend parameter**. | | | |---|---| | 12 | `sns.scatterplot(x``=` `"age"``, y``=` `"fare"``, data``=` `titanic_df, hue``=` `"sex"``, legend``=` `False` `)` | **Output \>\>\>** ![seaborn scatterplot legend](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/12-seaborn-scatterplot-legend.png?resize=392%2C266&ssl=1) ### sns.scatterplot() ax (Axes) parameter - **ax (Axes):** Pass value as a matplotlib Axes, optional Use multiple methods to change the sns scatter plot format and style using the **seaborn scatter plot ax** (Axes) parameter. here, used **ax.set()** method to change the scatter plot x-axis, y-axis label, and title. | | | |---|---| | 12345 | `ax``=` `sns.scatterplot(x``=` `"age"``, y``=` `"fare"``, data``=` `titanic_df, )` `ax.``set``(xlabel``=` `"Age"``,` `      ``ylabel``=` `"Fare"``,` `      ``title``=` `"Seaborn Scatter Plot of Age and Fare"``)` | **Output \>\>\>** ![sns scatterplot ax (axes)](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/13-sns-scatterplot-ax-axes.png?resize=392%2C278&ssl=1) ### sns.scatterplot() kwargs (Keyword Arguments) parameter - **kwargs (Keyword Arguments):** Pass the key and value mapping as a dictionary If you want to the artistic look of scatter plot then you must have to use the **seaborn scatter plot kwargs** (keyword arguments). The **seaborn sns.scatterplot()** allow all kwargs of [matplotlib plt.scatter()](https://indianaiproduction.com/matplotlib-scatter-plot/) like: - **edgecolor:** Change the edge color of the scatter point. Pass value as a color code, name or hex code. - **facecolor:** Change the face (point) color of the scatter plot. Pass value as a color code, name or hex code. - **linewidth:** Change line width of scatter plot. Pass float or int value - **linestyle:** Change the line style of the scatter plot. Pass line style has given below in the table. **Color Parameter Values** | | | |---|---| | **Character** | **Color** | | **b** | **blue** | | **g** | **green** | | **r** | **red** | | **c** | **cyan** | | **m** | **magenta** | | **y** | **yellow** | | **k** | **black** | | **w** | **white** | **Line Style parameter values** | | | |---|---| | **Character** | **Description** | | **\_** | **solid line style** | | **—** | **dashed line style** | | **\_.** | **dash-dot line style** | | **:** | **dotted line style** | | | | |---|---| | 12345678910 | `plt.figure(figsize``=``(``16``,``9``))` `kwargs ``=` `{``'edgecolor'``:``"r"``,` `             ``'facecolor'``:``"k"``,` `             ``'linewidth'``:``2.7``,` `             ``'linestyle'``:``'--'``,` `            ``}` `sns.scatterplot(x``=` `"age"``, y``=` `"fare"``, data``=` `titanic_df, size``=` `"sex"``, sizes``=` `(``500``,``1000``), alpha``=` `.``7``, ``*``*``kwargs)` | **Or**, you can also pass kwargs as a parameter. Output remain will be the same. | | | |---|---| | 123456789 | `# scatter plot kwrgs (keyword arguments) parameter` `plt.figure(figsize=(16,9)) # figure size in 16:9 ratio` `sns.scatterplot(x = "age", y = "fare", data = titanic_df, size = "sex", sizes = (500, 1000), alpha = .7,` `               ``edgecolor='r',` `                ``facecolor="k",` `                ``linewidth=2.7,` `                ``linestyle='--',` `               ``)` | Output \>\>\> ![seaborn scatter plot kwargs](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/14-seaborn-scatter-plot-kwargs.png?resize=950%2C538&ssl=1) ### 1\. sns Scatter Plot Example | | | |---|---| | 12345678910111213141516171819202122 | `import` `seaborn as sns` `import` `matplotlib.pyplot as plt` `sns.``set``()` `titanic_df``=` `sns.load_dataset(``"titanic"``)` `plt.figure(figsize``=` `(``16``,``9``))` `sns.scatterplot(x``=` `"age"``, y``=` `"fare"``, data``=` `titanic_df, hue``=` `"sex"``, palette``=` `"magma"``,size``=` `"who"``,` `                ``sizes``=` `(``50``,``300``))` `plt.title(``"Scatter Plot of Age and Fare"``, fontsize``=` `25``)` `plt.xlabel(``"Age"``, fontsize``=` `20``)` `plt.ylabel(``"Fare"``, fontsize``=` `20``)` `plt.savefig(``"Scatter Plot of Age and Fare"``)` `plt.show()` | **Output \>\>\>** ![seaborn scatter plot example](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/15-seaborn-scatter-plot-example-1.png?resize=964%2C570&ssl=1) ### 2\. sns Scatter Plot Example | | | |---|---| | 12345678910111213141516171819202122 | `import` `seaborn as sns` `import` `matplotlib.pyplot as plt` `sns.``set``()` `titanic_df``=` `sns.load_dataset(``"titanic"``)` `plt.figure(figsize``=` `(``16``,``9``))` `sns.scatterplot(x``=` `"who"``, y``=` `"fare"``, data``=` `titanic_df, hue``=` `"alive"``, style``=` `"alive"``, palette``=` `"viridis"``,size``=` `"who"``,` `                ``sizes``=` `(``200``,``500``))` `plt.title(``"Scatter Plot of Age and Fare"``, fontsize``=` `25``)` `plt.xlabel(``"Age"``, fontsize``=` `20``)` `plt.ylabel(``"Fare"``, fontsize``=` `20``)` `plt.savefig(``"Scatter Plot of Age and Fare"``)` `plt.show()` | **Output \>\>\>** ![seaborn scatter plot example](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/16-seaborn-scatter-plot-example-2.png?resize=964%2C570&ssl=1) ### 3\. sns Scatter Plot Example | | | |---|---| | 12345678910111213141516171819202122 | `import` `seaborn as sns` `import` `matplotlib.pyplot as plt` `sns.``set``()` `tips_df``=` `sns.load_dataset(``"tips"``)` `plt.figure(figsize``=` `(``16``,``9``))` `sns.scatterplot(x``=` `"tip"``, y``=` `"total_bill"``, data``=` `tips_df, hue``=` `"sex"``, palette``=` `"hot"``,` `                ``size``=` `"day"``,sizes``=` `(``50``,``300``), alpha``=` `0.7``)` `plt.title(``"Scatter Plot of Tip and Total Bill"``, fontsize``=` `25``)` `plt.xlabel(``"Tip"``, fontsize``=` `20``)` `plt.ylabel(``"Total Bill"``, fontsize``=` `20``)` `plt.savefig(``"Scatter Plot of Tip and Total Bill"``)` `plt.show()` | **Output \>\>\>** ![seaborn scatter plot example](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/17-seaborn-scatter-plot-example-3.png?resize=958%2C570&ssl=1) ### 4\. sns Scatter Plot Example | | | |---|---| | 123456789101112131415161718192021222324252627 | `import` `seaborn as sns` `import` `matplotlib.pyplot as plt` `sns.``set``()` `tips_df``=` `sns.load_dataset(``"tips"``)` `plt.figure(figsize``=` `(``16``,``9``))` `kwargs ``=` `{``'edgecolor'``:``"w"``,` `             ``'linewidth'``:``2``,` `             ``'linestyle'``:``':'``,` `            ``}` `sns.scatterplot(x``=` `"tip"``, y``=` `"total_bill"``, data``=` `tips_df, hue``=` `"sex"``, palette``=` `"ocean_r"``,` `                ``size``=` `"day"``,sizes``=` `(``200``,``500``),``*``*``kwargs)` `plt.title(``"Scatter Plot of Tip and Total Bill"``, fontsize``=` `25``)` `plt.xlabel(``"Tip"``, fontsize``=` `20``)` `plt.ylabel(``"Total Bill"``, fontsize``=` `20``)` `plt.savefig(``"Scatter Plot of Tip and Total Bill"``)` `plt.show()` | **Output \>\>\>** ![seaborn scatter plot example](https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/08/18-seaborn-scatter-plot-example-4.png?resize=958%2C570&ssl=1) ### Conclusion In the **seaborn scatter plot tutorial,** we learn how to create a seaborn scatter plot with a real-time example using **sns.barplot()** function. Along with that used different functions, parameter, and keyword arguments(kwargs). We suggest you make your hand dirty with each and every parameter of the above function because This is the best coding practice. Still, you didn’t complete [matplotlib tutorial](https://indianaiproduction.com/python-matplotlib-tutorial/) then I recommend to you, catch it. Download above **seaborn scatter plot source code** in Jupyter NoteBook file formate.
Shard40 (laksa)
Root Hash2015385107932208240
Unparsed URLcom,indianaiproduction!/seaborn-scatter-plot/ s443