With the default settings, the r.scatterplot output allows measuring and querying of the values in the scatter plot. Settings such as xscale or position option change the coordinates and make some of the measurements wrong.
A 3D scatter plot can be generated when the z_raster option is provided. A third variable is added to each scatter plot and each point has Z coordinate which represents this third variable.
Each point can also have a color based on an additional variable based on the values from color_raster. Values from a raster are stored as categories, i.e. floating point values are truncated to integers, and a color table based on the input raster color table is assigned to the vector map.
The z_raster and color_raster can be the same. This can help with understanding the 3D scatter plot and makes the third variable visible in 2D as well. When z_raster and color_raster are the same, total of four variables are associated with one point.
Figure: One scatter plot of two variables (left), the same scatter plot but with color showing third variable (middle), again the same scatter plot in 3D where Z represents a third variable (right).
Figure: One scatter plot in with one variable as Z coordinate and another variable as color (two rotated views).
Figure: Three overlapping scatter plots of three variables A, B, and C. Individual scatter plots are distinguished by color. The colors can be obtained using d.vect layer=-1 -c.
If visualization is more important than preserving the actual values, the -s flag can be used. This will place the scatter plots next to each other separated by values provided using spacing option.
The layout options can be still combined with additional variables represented as Z coordinate or color. In that case, Z coordinate or color is same for all the scatter plots.
Figure: Three scatter plots of three variables A, B, and C. First one is A and B, second A and C, and third B and C.
Figure: Three scatter plots of three variables A, B, and C with color showing a fourth variable D in all scatter plots.
The resulting vector will have as many points as there is 3D raster cells in the current computational region. It might be appropriate to use coarser resolution for the scatter plot than for the other computations. However, note that the some values will be skipped which may lead, e.g. to missing some outliers.
The color_raster input is expected to be categorical raster or have values which won't loose anything when converted from floating point to integer. This is because vector categories are used to store the color_raster values and carry association with the color.
The visualization of the output vector map has potentially the same issue as visualization of any vector with many points. The points cover each other and above certain density of points, it is not possible to compare relative density in the scatter plot. Furthermore, if colors are associated with the points, the colors of points rendered last are those which are visible, not actually showing the prevailing color (value). The modules v.mkgrid and v.vect.stats can be used to overcome this issue.
g.region raster=lsat7_2002_30
r.scatterplot input=lsat7_2002_30,lsat7_2002_40 output=scatterplot color_raster=landclass96
Figure: Scatter plot showing red and near infrared Landsat bands colored using land cover classes
g.region raster=lsat7_2002_30 -p r.scatterplot input=lsat7_2002_30,lsat7_2002_40 output=scatterplot_full_res
g.region raster=lsat7_2002_30 res=120 -p r.scatterplot input=lsat7_2002_30,lsat7_2002_40 output=scatterplot_res_120
Figure: Scatter plots computed with different computational region resolutions; first one is with full raster resolution (~30 m) second with resolution 120 m, and third with 240 m
g.region raster=lsat7_2002_30 -p r.scatterplot input=lsat7_2002_30,lsat7_2002_40 output=scatterplot
g.region vector=scatterplot res=5 -p
v.mkgrid map=scatterplot_grid v.vect.stats points=scatterplot areas=scatterplot_grid count_column=count v.colors map=scatterplot_grid use=attr column=count color=viridis
d.vect map=scatterplot_grid where="count > 0" icon=basic/point
v.mkgrid -h map=scatterplot_grid
g.region vector=scatterplot res=1 w=w-0.5 e=e+0.5 s=s-0.5 n=n+0.5
Figure: High density scatter plot visualized using binning into rectangular grid, hexagonal grid, and dense rectangular grid