Plot the fitting line with statistics on Scatter plot


Updated 9 Jan 2018

View License

Created by Ankur Kumar Wednesday; January 03, 2018
Version: 1.0
National Institute of Techonology, Rourkela
Rourkela, Odisa - 769008, India
Department of Earth and Atmospheric Sciences

One can draw the Scatter Plot with the figure handling options
along with the polynomial fitting of degree 1. This function
gives the basis statistics i.e. BIAS, Correlation Coefficient,
Standard Deviation of both variables, Root Mean Square Error
and write on the graph too. If you dont want statistics on the
plot, then you can change the format in the function itself.


First and second input should be the datas of scatter plot,
which you want to plot. First variable will plot on the X axis
and second variable will plot on the Y axis.
If you want to specify the size of marker size, write its size
as in the third argument.
Use LineWidth, MarkerFaceColor, MarkerFaceAlpha, LineWidth,
TextColor and Format to modify the Scatter Plots.
If you don't want the Statistics to print on your Scatter,
then write 0 as the Format argument.
There are 2 formats available presently, 1 and 2. Format 1 is
for the supressed statistics and Format 2 is the detail

For format 1, the equation of the fitting line is written on
the first line. Standard Deviation of X and Y is on the second.
SD of Y is in bracket. Correlation is also on the second line
seperated by slant. Bias and RMSE is on the third line.

You can store the output in variables to set the properties of
these lines later in the program.

[a b]=Scatter([2,3,6,4,7],[1,2,5,10,89],20,'Format',1)

Cite As

ANKUR KUMAR (2023). Scatter(varargin) (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2015b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Find more on Scatter Plots in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes