Every Data Science problem requires the use of Data Visualization, which is both a necessary and fascinating area of work. The market offers a variety of licensed and open-source data visualization tools, including Tableau, Power BI, DataWrapper, Infogram, etc.
Despite this, Python is far from being behind and offers some incredible libraries for carrying out Data Visualization tasks. In our earlier tutorials on the Python programming language, we established some fundamental ideas, such as Python Data Types and Loops in Python. By creating a histogram, bar plot, scatter plot, box plot, heat map, or line chart, for example, you can visualize data in a variety of ways. We’ll examine how to make a scatter plot in Python using popular libraries like Pandas, Seaborn, Matplotlib, etc. in this article.
Using the head command, we can also view the data frame’s first few rows.
WHAT ARE SCATTER PLOTS?
Graphical representations of continuous quantitative data are called scatter plots, also referred to as XY charts. They can be applied to:
- Draw a picture of the connection between two numerical variables.
- Compare the differences between the various quantities.
Say we have two variables that stand for advertising expenditure and sales revenue, respectively. Using a scatter plot, you can determine the relationship between these two variables and present it in a simple manner.
How to Create a Scatter Plot in Excel: An Example
You can see from the graph that there is initially an increase in sales revenue that follows an increase in each ad dollar spent. However, after a certain point, it plateaus and the marginal revenue for every dollar spent on advertising decreases.
HOW DO I MAKE AN EXCEL SCATTER PLOT?
It’s very simple to create scatter plots in Excel. If you take the steps outlined below, you can actually add them to your reports in just a few seconds:
Step 1: Prepare the Data for the Scatter Plot
The scatter plot, as previously mentioned, shows the relationship between two quantitative variables. As a result, ensure that your data only contains numerical quantities.
List the independent variable in the left column at all times for convenience. The dependent variable should then be listed in the right column. Remember that the Y-axis will represent the dependent variable while the X-axis represents the independent variable when plotting data.
In this case, we are looking at how spending on advertising affects sales revenue. Thus, “advertising dollars spent” and “sales revenue” are the independent and dependent variables, respectively.
How to Create an Excel Scatter Plot - Organize your data
Step 2: Determine whether you want to plot each variable separately.
- The scatter plot offers two ways to visualize the relationship between variables.
- Plotting both variables simultaneously in the X vs. Y graph format is Option 1, and it will appear something like this:
Option 1: Create an X-Y scatter plot with both variables.
Use this option to determine whether two variables have linear relationships. Simply choose the range of the two variables to put this into action.
Option 2: Draw separate series for each of the two variables.
To put this into practice, choose the three variables’ data ranges (categorical, variable 1, variable 2) in that order.
To understand this graph, you might need to plot any one variable on a secondary axis.
If you choose Option 2, plot the second series on a secondary axis.
Step 3: Determine the Sort of Scatter Plot You Require
- Navigate to the Insert tab in the Excel ribbon after selecting the data range containing your variables.
- Select the Charts group and then click the Insert Scatter (X, Y) button.
How to Create an Excel Scatter Plot: Select the Scatter plot type.
- You can choose from 5 different scatter chart templates under this option. Hovering your mouse over those icons will allow you to preview each chart template before selecting one.
- You can always change the chart type by simply clicking on a different option after selecting your chart, so experiment with the various scatter chart types.
To see a preview of the different Scatter plot types, hover over them.
Step 4: Format or Customize the Scatter Plot
When you select a specific Scatter chart type, your worksheet will display it. Your needs might not always be met by the default formatting options.
I’ll go over a few of the crucial elements you need to change in your scatter chart in the section that follows.
Insert Axis Titles
Axis titles might be missing from your default Scatter chart. To include them, select Chart Elements from the menu in the chart’s upper-right corner. Select the appropriate type under it by checking Axis Titles.
For axes titles to be added to your scatter plot, select Axis Titles in the Chart Elements section.
Double-click the chart titles to edit them after that.
For editing, double-click the axis titles.
Insert data labels
- Data labels are vital chart components that give your graph more meaning. To include them, select the Chart Elements option from the chart’s top-right corner. Select More Options and then check Data Labels under that.
- More Options can be selected in the Data labels section.
- By doing this, the Format Data Labels pane will open.
- Determine the Label Position and the Appropriate Label Contents.
- Use the Label contains and Label position options to specify where and which value should be displayed as labels.
- Your chosen data labels will now be present in your scatter plot as necessary.
- Spreadsheet with labels
Place a trendline and its equation there.
You can include a trendline to the scatter plot to add more context if you’re using it to look for any linear or polynomial relationships between the variables.
The best fit line or linear regression line is the name given to this kind of trendline. Simply put, Excel looks for a line or curve that fits the data the best and is close enough to the average of all the data points in your series.
Under Chart Elements’ Trendline section, select More Options.
Select any appropriate type of equation (linear, polynomial, logarithmic, etc.) from the Format Trendline pane at this point. Click on the checkbox next to the option to Display Equation on Chart to make the equation for the trendline visible.
Insert error bars
Error bars, which display the degree of deviation in your scatter plot, can be added to your graph to make it more informative. To accomplish this, select an appropriate Error Bars option from the Chart Elements menu.
Scatter plot in Tableau with Dimensions
The scatter plot depicts data with a large number of points scattered across the Cartesian plane. It is produced by plotting numerical data in the Cartesian plane using the X and Y coordinates.
Drag at least one measure into the Rows shelf and another into the Columns shelf in Tableau to create a plot. The scatter plot can be expanded with dimension fields, which help to distinguish different colors for the scatter graph’s existing points. The Scatter chart option is also available in Tableau’s Show Me card. Basic Scatter Plot Let’s use Tableau Public to make a basic scatter plot:
- Click on Excel and select the appropriate file to connect your Tableau to Excel files.
- A scatter chart option will appear under the Marks card.
- Here we have taken sales, dredge your measure up and place it in rows shelf.
- Taking yet another action, we will now raise it and place it in the column shelf. The scatter plot will appear for the first time. You’ll only notice one point, but it has gathered all of those points into one location.
- We will now drop the dimension into the area of the marker by dragging it down (here we have chosen a month). You’ll see a scatter plot with each dot representing a month’s worth of data.
The color of the scatter plots can be altered by dragging any dimension in the color field beneath the marks card.
Shape Gradient -
Unlike color, you can also change the shape of the scatter plots. The shape can be altered to a circle, diamond, square, cross, etc. Drag the dimension field to the Shape Field under the marks card. You will notice various shapes representing your scatter plots.