Skip to content

Instantly share code, notes, and snippets.

@h4k1m0u
Last active October 24, 2019 11:58
Show Gist options
  • Save h4k1m0u/20577e774553b6dec76638c8a66fcf06 to your computer and use it in GitHub Desktop.
Save h4k1m0u/20577e774553b6dec76638c8a66fcf06 to your computer and use it in GitHub Desktop.
Different color for samples (50%) below or above median
# 1000 samples from standard normal dist
x = seq(1, 1000)
y = rnorm(1000)
y_normalized = (y - min(y)) / (max(y) - min(y))
# split in half and with different color
median = median(y_normalized)
print(median)
plot(x, y_normalized, pch=21, bg=ifelse(y_normalized > median, 'red', 'green'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment