Skip to content

Instantly share code, notes, and snippets.

View lzkelley's full-sized avatar

Luke Zoltan Kelley lzkelley

View GitHub Profile
@tillahoffmann
tillahoffmann / weighted_kde.ipynb
Last active June 24, 2023 07:39
Weighted kernel density estimation based on `scipy.stats.gaussian_kde`.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@thomasaarholt
thomasaarholt / autoscale.py
Last active January 23, 2023 15:52
Matplotlib autoscale
def autoscale(ax=None, axis='y', margin=0.1):
'''Autoscales the x or y axis of a given matplotlib ax object
to fit the margins set by manually limits of the other axis,
with margins in fraction of the width of the plot
Defaults to current axes object if not specified.
'''
import matplotlib.pyplot as plt
import numpy as np
if ax is None: