GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||
GeezerVison is showing www.geeksforgeeks.org — Scatterplot using Seaborn in Python - GeeksforGeeks Scatterplot using Seaborn in PythonLast Updated : 27 May, 2025 Seaborn is an amazing visualization library for statistical graphics plotting in Python. It provides beautiful default styles and color palettes to make statistical plots more attractive. It is built on the top of matplotlib library and also closely integrated into the data structures from pandas. What is a scatterplot?A scatter plot displays points on a two-dimensional axis to show the relationship between two variables. Each dot represents an observation from your dataset. With Seaborn’s scatterplot() function, you can easily:
Syntax
Parameters:
Returns: This method returns the Axes object with the plot drawn onto it. ExamplesExample 1: In this example, we are creating a basic scatter plot with the FMRI dataset. We plot the timepoint on the x-axis and the signal on the y-axis to observe how the signal changes over time.
Output ![]() Explanation: sns.set(style='whitegrid') sets a clean plot style with gridlines. sns.load_dataset("fmri") loads brain signal data over time. sns.scatterplot(x="timepoint", y="signal", data=fmri) creates a scatter plot showing how FMRI signals vary with time. Example 2: In this example, we extend the basic FMRI scatter plot by adding color (hue) based on the region and different markers (style) based on the event.
Output ![]() Explanation: sns.scatterplot(x="timepoint", y="signal", hue="region", style="event", data=fmri) creates a scatter plot of FMRI signals over time, using different colors for regions and marker styles for events. Example 3: In this example, we use the Tips dataset to create a scatter plot showing how tips vary across different days of the week. The day is plotted on the x-axis and the tip amount on the y-axis.
Output ![]() Explanation: sns.load_dataset("tips") loads a dataset containing restaurant tipping data. sns.scatterplot(x="day", y="tip", data=tips) creates a scatter plot showing tip amounts given on different days. Grouping variables in Seaborn Scatter Plot with different attributes1. Adding the marker attributes: The circle is used to represent the data point and the default marker here is a blue circle. In the above output, we are seeing the default output for the marker, but we can customize this blue circle with marker attributes.
Output 2. Adding the hue attributes: It will produce data points with different colors. Hue can be used to group to multiple data variable and show the dependency of the passed data values are to be plotted.
Output In the above example, we can see how the tip and day bill is related to whether it was lunchtime or dinner time. The blue color has represented the Dinner and the orange color represents the Lunch. Let's check for a hue = " day "
3. Adding the style attributes: Grouping variable that will produce points with different markers. Using style we can generate the scatter grouping variable that will produce points with different markers.
Output 4. Adding the palette attributes: Using the palette we can generate the point with different colors. In this below example we can see the palette can be responsible for a generate the scatter plot with different colormap values.
Output 5. Adding size attributes: Using size we can generate the point and we can produce points with different sizes.
Output 6. Adding legend attributes: We can control the legend display using the legend parameter: legend='full' shows all groups, legend='brief' shows a sample for numeric variables, and legend=False hides the legend completely.
Output 7. Adding alpha attributes: Using alpha we can control proportional opacity of the points. We can decrease and increase the opacity.
Output Comment Explore | ||||||||||||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |