How to Create Excel Scatter Plot Color by Group (3 Suitable Ways)

Get FREE Advanced Excel Exercises with Solutions!

In our daily life, we often feel the necessity to create Excel scatter plots in Microsoft Excel. We can do the job in many ways. In this article, we will see 3 suitable ways to create Excel scatter plot color by group.


How to Create Excel Scatter Plot Color by Group: 3 Suitable Ways

We can create Excel scatter plots by group in three suitable ways. These three ways consist of creating an Excel scatter plot color by group without conditions, creating an Excel scatter plot color by group with conditions, and using VBA Code. In this article, we will see these three ways to create an Excel scatter plot by group.


1. Create an Excel Scatter Plot Color by Group without Condition

We can simply create an Excel scatter plot color by group without condition. In order to do so, we will need a dataset like the picture below. We will create three groups (A, B, and C) using the Number of Students and their Obtained Marks. Now we will create an Excel scatter plot.

Create Excel Scatter Plot Color by Group without Condition

Steps:

  • First of all, click on the Insert tab.
  • Then click on the Scatter Plot dropdown option.
  • After that, choose the following Scatter plot option like the picture below.

Create Excel Scatter Plot Color by Group without Condition

  • As a result, it will open an empty plot like the following picture.

Create Excel Scatter Plot Color by Group without Condition

  • Subsequently, right-click on the empty plot.
  • Now, click on the Select Data Source option from the pop-up window.

Create Excel Scatter Plot Color by Group without Condition

  • After that, the Select Data Source window will pop up.
  • Now, click on the Add option like the picture below.

Create Excel Scatter Plot Color by Group without Condition

  • Next, type the Series name as Group A.
  • After that, click on the Select Range from the Series X values option.

Create Excel Scatter Plot Color by Group without Condition

  • Subsequently, select the range of the number of student values from Group A and complete the range.

Create Excel Scatter Plot Color by Group without Condition

  • After that, click on the Select Range in the Series Y values option like the picture below.

  • Furthermore, select the range of obtained marks from Group A and complete the range.

  • After selecting the X and Y values, click OK.

  • As a result, it will create a plot of a particular color for Group A like below.

  • Subsequently, do the same for Group B and Group C values with their range of data.
  • Then click OK.

  • Finally, it will create an Excel scatter plot with different colors for different groups like the picture below.


2. Apply Condition to Make Excel Scatter Plot Color by Group

Sometimes we need to make Excel scatter plot applying conditions. In order to do so, we will see an example. For the example, we will need a dataset like the below image. The dataset contains the Number of Students and their Obtained Marks.

Apply Condition to Make Excel Scatter Plot Color by Group

The Conditions we will use are given in the picture below.

Apply Condition to Make Excel Scatter Plot Color by Group

Now to create Excel scatter plot with conditions, we need to apply the following steps.

Steps:

  • First, create a new column named Group A.
  • Next, click on the D5 cell and type the formula:
=IF(B5>C5,C5,NA())
  • Now press Enter.
  • Then click on the D5 cell and drag the Fill Handle from cell D5 to D14.

Apply Condition to Make Excel Scatter Plot Color by Group

  • Subsequently, create a new column named Group B.
  • Next, click on the E5 cell and type the formula:
=IF(B5<C5,C5,NA())
  • After that, press Enter.
  • Then click on the E5 cell and drag the Fill Handle from cell E5 to E14 cell.

Apply Condition to Make Excel Scatter Plot Color by Group

  • Furthermore, create a new column named Group C.
  • Then click on the F5 cell and type the formula:
=IF(B5=C5,C5,NA())
  • Next, press Enter.
  • Then click on the F5 cell and drag the Fill Handle from F5 to F14 cell.

Apply Condition to Make Excel Scatter Plot Color by Group

  • Now the table is ready to be plotted in the scatter plot.

Apply Condition to Make Excel Scatter Plot Color by Group

  • At first, click on the Insert option.
  • Then, click on the Scatter Plot downfall option.
  • After that, choose the following Scatterplot option like the picture below.

Apply Condition to Make Excel Scatter Plot Color by Group

  • As a result, it will open an empty plot like the following picture.

  • Subsequently, right-click on the empty plot.
  • Now click on the Select Data Source option from the pop-up window.

  • Then Select Data Source window will pop up.
  • After that, click on the Chart Data Range option and select $B$5:$B$14 and $D$5:$F$14 pressing ctrl.
  • Next, click OK.

  • Finally, it will create an Excel scatter plot for the three groups by individual colors like the picture below.


3. Group Scatter Plot by Color Using VBA Code

We can also create Excel scatter plot color by group using VBA Code.  It is helpful for those who prefer coding approaches to solving real-life problems. Now we will see an example of how to create an Excel scatter plot using VBA Code. In order to solve the example, we will need a dataset like the below image.

Group Scatter Plot by Color Using VBA Code

Steps:

  • At first, right-click on the worksheet at the lowermost part of your screen.
  • As a result, It will open a pop-up window and click on the View Code option like the picture.

Group Scatter Plot by Color Using VBA Code

  • Now Microsoft Visual Basic for Applications window will open.
  • Then, type the following code:
Option Explicit
Sub Scatter_Points_Coloring()
Dim crt As Chart
Dim ser As Series
Dim pnt As Point
Dim m As Long
Dim val$, mTrim#, nTrim#
Dim vRange As range, pl As range
Dim pointColor As Long
Set crt = ActiveSheet.ChartObjects(1).Chart
Set ser = crt.SeriesCollection(1)
mTrim = InStrRev(ser.Formula, ",", InStrRev(ser.Formula, ",") - 1, vbBinaryCompare) + 1
nTrim = InStrRev(ser.Formula, ",")
val = Mid(ser.Formula, mTrim, nTrim - mTrim)
Set vRange = range(val)
For m = 1 To ser.Points.Count
Set pnt = ser.Points(m)
Set pl = vRange(m).Offset(0, 1)
With pnt.Format.Fill
.Visible = msoTrue
Select Case LCase(pl)
Case "red"
pointColor = RGB(255, 0, 0)
Case "orange"
pointColor = RGB(255, 192, 0)
Case "green"
pointColor = RGB(0, 255, 0)
End Select
.ForeColor.RGB = pointColor
End With
Next
End Sub
  • Now run the code and close the window to see the results.

Group Scatter Plot by Color Using VBA Code

  • Finally, it will create an Excel scatter plot according to your preference and show an output like the below figure.

Group Scatter Plot by Color Using VBA Code


Things to Remember

  • Excel scatter plot color by group without condition is the simplest way to make an Excel scatter plot color by group.
  • If you want to make an Excel scatter plot using conditions, then the Excel scatter plot color by group with condition is the best way to perform the job.
  • If you prefer coding applications to solve real-life problems, then the VBA Code approach will be a better option for you.

Download Practice Workbook


Conclusion

Hence, follow the above-described methods. Thus, you can easily learn how to create an Excel scatter plot color by group. Hope this will be helpful. Follow the ExcelDemy website for more articles like this. Don’t forget to drop your comments, suggestions, or queries in the comment section below.


Related Articles


<< Go Back To Edit Scatter Chart in Excel | Scatter Chart in Excel | Excel Charts | Learn Excel

What is ExcelDemy?

ExcelDemy - Learn Excel & Get Excel Solutions Center provides online Excel training , Excel consultancy services , free Excel tutorials, free support , and free Excel Templates for Excel professionals and businesses. Feel free to contact us with your Excel problems.
Md. Asaduzzaman
Md. Asaduzzaman

Hello! I am Md. Asaduzzaman. Currently, I am working as an Excel and VBA Content Developer and I will be posting my articles related to this here. I graduated from Bangladesh University of Science and Technology(BUET) in 2022. I completed my BSc in Naval Architecture and Marine Engineering. I like to solve real-life problems in Microsoft Excel and share the solutions through articles. I post here regularly. Hope you find the articles helpful.

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo