Course Content

# Ultimate Visualization with Python

1. Matplotlib Introduction

2. Creating Commonly Used Plots

5. Plotting with Seaborn

Ultimate Visualization with Python

## Scatter Plot

You did a great job learning about line plots, so now it will be much easier for you to dive into scatter plots.

A **scatter plot** is simply a plot which represents a relationship between two variables (**x** and **y**) using dots or other markers. Creating a scatter plot is perhaps the simplest way to check if two variables are correlated (not the most precise, but still can give some insight).

It is similar to a **line plot**, except for the fact that it has no lines, only markers. In order to create a scatter plot, all you have to do is to use a `scatter()`

function of the `pyplot`

, passing first values for x-axis, then values for y-axis. Let’s have a look at an example:

The `scatter()`

function's syntax resembles that of `plot()`

. However, unlike `plot()`

, you must always provide values for both `x`

and `y`

parameters.

In our case, the y values are determined linearly by the formula `y = 2x + 5`

. Our scatter plot visually illustrates the **positive linear relationship** between these two variables: `y`

increases with increasing `x`

and decreases with decreasing `x`

.

It is also possible to set other markers instead of dots and set their size using `marker`

and `s`

parameters respectively:

Here we used `'x'`

as markers instead of `'o'`

(dots) by default and set their size to 100. Feel free to experiment with the `s`

(size) parameter. We will focus more on plot customization in the next section, but, as for now, you can use `scatter()`

function documentation to explore more.

Plotting **multiple scatter plots** can be accomplished simply by calling the `scatter()`

function twice with different `x`

and `y`

arguments (similarly to line plots).

# Task

Now you will display a quadratic relationship between two variables using a scatter plot:

- Replace the underscores, so that
`y`

array contains squared elements of the`x`

array. - Use the correct function to create a scatter plot.
- Pass
`x`

and`y`

in this function in the correct order. - Set the size of the markers to 70.

Everything was clear?