This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
To save python objects of any sort, to a file. | |
''' | |
import pickle as pkl | |
pkl.dump( fig, open('FigureObject.pickle', 'wb') ) | |
pkl.dump( fig, open('FigureObject.pickle', 'wb'), fix_imports=True ) # fix_imports makes it py2x compatible - untested | |
''' | |
Load python objects from file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re # regex | |
# This will be used to capture a group () within a larger string, and save that group to a variable | |
# Set regex pattern to match | |
dcpattern = re.compile( r'DC=[-]?(\d*\.?\d*)V?' , flags=(re.IGNORECASE) ) | |
#regex expression within 'raw' python string, to prevent interpretation/escaping (%f etc.). | |
# The Regular Expression | |
# DC=[-]?(\d*\.?\d*)V? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
# Handle mouse clicks on the plot: | |
class LineSlice: | |
'''Allow user to drag a line on a pcolor/pcolormesh plot, and plot the Z values from that line on a separate axis. | |
Example | |
------- | |
fig, (ax1, ax2) = plt.subplots( nrows=2 ) # one figure, two axes |