<jupyter_start><jupyter_text>These examples will use the "tips" dataset, which has a mixture of numeric and categorical variables:<jupyter_code>tips = sns.load_dataset("tips")
tips.head()<jupyter_output><empty_output><jupyter_text>Assign ``x`` and ``y`` to draw a scatter plot between two variables:<jupyter_code>sns.scatterplot(data=tips, x="total_bill", y="tip")<jupyter_output><empty_output><jupyter_text>Assigning a variable to ``hue`` will map its levels to the color of the points:<jupyter_code>sns.scatterplot(data=tips, x="total_bill", y="tip", hue="time")<jupyter_output><empty_output><jupyter_text>Assigning the same variable to ``style`` will also vary the markers and create a more accessible plot:<jupyter_code>sns.scatterplot(data=tips, x="total_bill", y="tip", hue="time", style="time")<jupyter_output><empty_output><jupyter_text>Assigning ``hue`` and ``style`` to different variables will vary colors and markers independently:<jupyter_code>sns.scatterplot(data=tips, x="total_bill", y="tip", hue="day", style="time")<jupyter_output><empty_output><jupyter_text>If the variable assigned to ``hue`` is numeric, the semantic mapping will be quantitative and use a different default palette:<jupyter_code>sns.scatterplot(data=tips, x="total_bill", y="tip", hue="size")<jupyter_output><empty_output><jupyter_text>Pass the name of a categorical palette or explicit colors (as a Python list of dictionary) to force categorical mapping of the ``hue`` variable:<jupyter_code>sns.scatterplot(data=tips, x="total_bill", y="tip", hue="size", palette="deep")<jupyter_output><empty_output><jupyter_text>If there are a large number of unique numeric values, the legend will show a representative, evenly-spaced set:<jupyter_code>tip_rate = tips.eval("tip / total_bill").rename("tip_rate")
sns.scatterplot(data=tips, x="total_bill", y="tip", hue=tip_rate)<jupyter_output><empty_output><jupyter_text>A numeric variable can also be assigned to ``size`` to apply a semantic mapping to the areas of the points:<jupyter_code>sns.scatterplot(data=tips, x="total_bill", y="tip", hue="size", size="size")<jupyter_output><empty_output><jupyter_text>Control the range of marker areas with ``sizes``, and set ``lengend="full"`` to force every unique value to appear in the legend:<jupyter_code>sns.scatterplot(
    data=tips, x="total_bill", y="tip", hue="size", size="size",
    sizes=(20, 200), legend="full"
)<jupyter_output><empty_output><jupyter_text>Pass a tuple of values or a :class:`matplotlib.colors.Normalize` object to ``hue_norm`` to control the quantitative hue mapping:<jupyter_code>sns.scatterplot(
    data=tips, x="total_bill", y="tip", hue="size", size="size",
    sizes=(20, 200), hue_norm=(0, 7), legend="full"
)<jupyter_output><empty_output><jupyter_text>Control the specific markers used to map the ``style`` variable by passing a Python list or dictionary of marker codes:<jupyter_code>markers = {"Lunch": "s", "Dinner": "X"}
sns.scatterplot(data=tips, x="total_bill", y="tip", style="time", markers=markers)<jupyter_output><empty_output><jupyter_text>Additional keyword arguments are passed to :meth:`matplotlib.axes.Axes.scatter`, allowing you to directly set the attributes of the plot that are not semantically mapped:<jupyter_code>sns.scatterplot(data=tips, x="total_bill", y="tip", s=100, color=".2", marker="+")<jupyter_output><empty_output><jupyter_text>The previous examples used a long-form dataset. When working with wide-form data, each column will be plotted against its index using both ``hue`` and ``style`` mapping:<jupyter_code>index = pd.date_range("1 1 2000", periods=100, freq="m", name="date")
data = np.random.randn(100, 4).cumsum(axis=0)
wide_df = pd.DataFrame(data, index, ["a", "b", "c", "d"])
sns.scatterplot(data=wide_df)<jupyter_output><empty_output><jupyter_text>Use :func:`relplot` to combine :func:`scatterplot` and :class:`FacetGrid`. This allows grouping within additional categorical variables. and plotting them across multiple subplots.Using :func:`relplot` is safer than using :class:`FacetGrid` directly, as it ensures synchronization of the semantic mappings across facets.<jupyter_code>sns.relplot(
    data=tips, x="total_bill", y="tip",
    col="time", hue="day", style="day",
    kind="scatter"
)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14175618869687062, 'fraction_numerical': 0.007006071929005138, 'mean_word_length': 8.560267857142858, 'pattern_counts': {'":': 2, '<': 61, '<?xml version=': 0, '>': 61, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '15', 'dir': 'jupyter-structured-clean-dedup', 'id': '12517', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 1509, 'n_tokens_neox': 1424, 'n_words': 375, 'path': 'doc/docstrings/scatterplot.ipynb', 'repo_name': 'Pratik325/seaborn', 'size': '4282'}