Skip to content

Instantly share code, notes, and snippets.

import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot([1, 2, 3])
ax.set_title('hi mom')
ax.grid(True)
ax.set_xlabel('time')
ax.set_ylabel('volts')
@carlodri
carlodri / gsf_read.py
Last active July 16, 2024 11:13
Simple Python I/O functions for the Gwyddion Simple Field (.gsf) format
def gsf_read(file_name):
'''Read a Gwyddion Simple Field 1.0 file format
http://gwyddion.net/documentation/user-guide-en/gsf.html
Args:
file_name (string): the name of the output (any extension will be replaced)
Returns:
metadata (dict): additional metadata to be included in the file
data (2darray): an arbitrary sized 2D array of arbitrary numeric type
'''
@carlodri
carlodri / ipython movie previewer
Created March 16, 2015 16:24
View movie preview in ipython
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
from IPython.html.widgets import interact
def browse_images(data):
num_frames = data.shape[0]
def view_image(i):
plt.imshow(data[i], cmap=plt.cm.hot, interpolation='none')
plt.title('Frame %s' % i)