• Inline Pylab. Add this block to move to the directory of your choice and plot images inline.
%cd C:\Users\Tasif\Dropbox\lab\dektak\2015_07_10_electrodes_paper
%pylab inline
  • Open File with File Dialog on Top. Usually, file dialog box stays behind open applications. Use this to get it at the front.
# open file
import Tkinter, tkFileDialog
root = Tkinter.Tk() # make a top-level instance and hide since it is ugly and big.
root.overrideredirect(True) # make it almost invisible - no decorations, 0 size, top left corner.
root.deiconify() # show window again and lift it to top so it can get focus,
root.lift() # otherwise dialogs will end up behind the terminal.

fname1 = tkFileDialog.askopenfilename(parent=root)
fname1_blank1 = str(fname1).replace(".txt", "")
fname1_blank2 = fname1_blank1.replace(".csv", "")

root.destroy() # get rid of the top-level instance once to make it actually invisible.
  • Load Data from CSV File
data = np.genfromtxt(fname1, delimiter=',', skip_header=37,skip_footer=5)
scan_length = data[:,0];
height = data[:,1]/1000;
  • Save Figure
fig = plt.figure()
fig.savefig(fname1_blank2+'_plot.png', dpi=600, facecolor='w', edgecolor='w',
        orientation='portrait', papertype=None, format=None,
        transparent=False, bbox_inches='tight', pad_inches=0.25,
  • To change the home directory for ipython in Ubuntu. This can be used in the desktop launcher file - ipython.desktop located at /usr/share/applications. Usually, the default directory is /home.
    ipython notebook '--NotebookManager.notebook_dir=/home/yasser/Dropbox/ipython'
  • It took me a while to figure out how to install mayavi for IPython in Windows. If you’re using Anaconda distribution life will be easy.
    1. Open Anaconda Command Prompt from the start menu.
    2. Move to the Scripts directory under Anaconda. cd Scripts
    3. Update conda conda.exe update conda
    4. Install mayavi conda.exe install mayavi
    5. Enable qt console by putting this at the beginning of your ipython notebook file %gui qt
    6. Try out one of the examples provided here: http://docs.enthought.com/mayavi/mayavi/auto/examples.html#mlab-functions-gallery

Last modified: 2017-12-31