Skip to content

Instantly share code, notes, and snippets.

@sliminality
Last active August 5, 2019 21:00
Show Gist options
  • Save sliminality/6e9775982317b336bb2ba513d62406e8 to your computer and use it in GitHub Desktop.
Save sliminality/6e9775982317b336bb2ba513d62406e8 to your computer and use it in GitHub Desktop.
jupyter stuff
def hide_code():
from IPython.display import HTML
from IPython.display import display
# Taken from https://stackoverflow.com/questions/31517194/how-to-hide-one-specific-cell-input-or-output-in-ipython-notebook
tag = HTML('''<script>
code_show=true;
function code_toggle() {
if (code_show){
$('div.cell.code_cell.rendered.selected div.input').hide();
} else {
$('div.cell.code_cell.rendered.selected div.input').show();
}
code_show = !code_show
}
$( document ).ready(code_toggle);
</script>
Toggle code <a href="javascript:code_toggle()">here</a>.''')
display(tag)
def subplots(plots, num_cols = 2):
n = len(plots)
num_rows = math.ceil(n / num_cols)
plt.figure(figsize=(6.4 * num_cols, 4.8 * num_rows)) # Scale default proportions
for i, plot in enumerate(plots):
plt.subplot(num_rows, num_cols, i+1)
plot()
subplots([
lambda: sns.pointplot(df.index, np.log2(df.lastEditedTime), kde=False)
.set_title("lastEditedTime"),
lambda: sns.pointplot(df.index, np.log2(df.lastEditedTime), kde=False)
.set_title("lastEditedTime"),
lambda: sns.pointplot(df.index, df._score, color="green", kde=False)
.set_title("_score")
])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment