*! version 1.0.4 8.8.2023

Title

colorscatter -- Draw scatter plots with marker colors varying by a third variable.

Syntax

colorscatter
[if] [in] x y c [if] [in], [legendoff] [scatter_options( ... )] [twoway_options]

Main
keeplegend do not overwrite the legend, the user can then do so manually by adding twoway options.

scatter_options are passed to twoway scatter.

Colors
cmin(#) which value should get the lowest value for color.

cmax(#) which value should get the lowest value for color.

rgb_low(# # #) specify color low values of c. (default: red)

rgb_high(# # #) specify color high values of c. (default: blue)

symbol_opacity(#%) specify opacity. (default: blue)

tw_pre(twoway graph) draw another twoway graph underneath (should be enclosed in parentheses, like "(scatter xy)" ).

tw_post(twoway graph) draw another twoway graph on top (should be enclosed in parentheses).

Description

colorscatter Draws a scatter plot using x and y as coordinates; c is visualized as color gradient.

Example

This example generates a data set of 3 variables and plots a colored scatter plot of these.

`"set obs 1000"'

`"gen x = rnormal()"'

`"gen y = rnormal()"'

`"gen c = min(abs(x),abs(y))"'

`"colorscatter x y c, scatter_options(msymb(Oh)) title("Twowaytitle") rgb_low(255 0 0) rgb_high(0 255 0) tw_pre((lfit x y, lc(gray)))"'

See also

twoway,
twoway scatter,

Acknowledgements

Eric Melse suggested and implemented the symbol_opacity option

Author

Simon Heß, Goethe University Frankfurt.

The latest version of colorscatter can always be obtained from https://github.com/simonheb/colorscatter or http://HessS.org.

I am happy to receive comments and suggestions regarding bugs or ideas for improvements/extensions via https://github.com/simonheb/colorscatter/issues.