Creating a Scatter Plot in Mathematica: A Helpful Step-by-Step Guide.

Mathematica offers a wide variety of options for creating charts and visualizing data. However, the user interface can be really daunting, especially for new users who are not familiar with the basic functionalities of this tool.

In fact, creating a scatter plot from two different data sets is one of the tasks that beginners usually struggle with. So in this comprehensive article, you will find exactly the steps you need to follow in order to generate your first scatter plot.

I created this guide using Mathematica 10.4, but even if you are using an older version you should be good to go.

Example Problem.

You recently ran an experiment to determine the rate of a given reaction. During this process, you measured the concentration of reactant at different times. The following table contains the results you got:

Time (seconds)Concentration (mol/L)

Now you are required to turn that table into a scatter plot using Mathematica.

Step 1. Separate Your Data Into Two Lists.

First, you’ll need to create two separate lists for your data. The first list will contain the x values, and in the second one, you will store your y values.

By using a list, you are telling Mathematica that you want to save data as an ordered sequence. In this particular example, we’ll create one list called t for our time values, and another one called c for our concentrations.

Lists always begin and end with curly braces, and their items are separated with commas. The code below generates the two lists that will contain our data:

t = {0, 2, 5, 9, 14, 20, 27, 35};
c = {1.34, 0.887, 0.588, 0.406, 0.293, 0.219, 0.17, 0.135};

Feel free to type the code into your editor so you can follow along.

Step 2. Organize Your Values.

When you are creating a scatter plot, Mathematica requires you to organize every value with its corresponding match as shown below:

myData = {{t1, c1}, {t2, c2}, ..., {tn, cn}};

However, we are not willing to waste precious time doing that process manually. So in order to automate this, we will just use the Thread function and get Mathematica to do it for us.

Our updated code would be the following:

t = {0, 2, 5, 9, 14, 20, 27, 35};
c = {1.34, 0.887, 0.588, 0.406, 0.293, 0.219, 0.17, 0.135};

myData = Thread[{t, c}]

The last line I just added creates the pairs of values we need in order to generate our chart. And those pairs are assigned to a new variable called myData.

Step 3. Call the ListPlot Function to Create the Scatter Plot.

Now we are ready to create the scatter plot. To do this, we will simply pass our data through the ListPlot function and the scatter plot will show up on the screen:

t = {0, 2, 5, 9, 14, 20, 27, 35};
c = {1.34, 0.887, 0.588, 0.406, 0.293, 0.219, 0.17, 0.135};

myData = Thread[{t, c}];


Remember not to add a semicolon after calling the ListPlot function. Otherwise, you won’t be able to visualize the graph.

Styling Your Chart (Optional).

Once you have created your scatter plot, you’ll probably want to add some styling to it. So you can modify its attributes to make it look better.

By using the highlighted attributes, you’ll be able to add some labels, make the markers bigger, and set a background color. You can also create a grid just to make the graph easier to read.

t = {0, 2, 5, 9, 14, 20, 27, 35};
c = {1.34, 0.887, 0.588, 0.406, 0.293, 0.219, 0.17, 0.135};

myData = Thread[{t, c}];

ListPlot[myData, PlotMarkers -> {\[FilledSquare], 15}, 
 PlotStyle -> Red, Background -> LightBlue,
 GridLines -> Automatic, 
 PlotLabel -> Style["C vs t", FontSize -> 20], 
 AxesLabel -> {"t", "C"},
 LabelStyle -> Directive[Blue, Bold]]

And this is the final result:

Feel free to copy the highlighted code if you want your scatter plot to look like mine.

Finally, don’t hesitate to visit the Wolfram Language Documentation Center if you need more in-depth information on styling your graphs.