Skip to content

Instantly share code, notes, and snippets.

@MilesCranmer
Created November 13, 2018 16:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MilesCranmer/f67c8feffb20e6b6c0e713e4127e1cbf to your computer and use it in GitHub Desktop.
Save MilesCranmer/f67c8feffb20e6b6c0e713e4127e1cbf to your computer and use it in GitHub Desktop.
Plot only 99th percentile of data with pandas.
def plotdf(df, x, y, sample=10000):
df = df[[x, y]].sample(sample).copy()
for col in [x, y]:
df = df[(df[col] > df[col].quantile(0.01)) & (df[col] < df[col].quantile(0.99))]
df.plot(
x, y,
linestyle='', marker='.',
markersize=0.1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment