# Function for graphing temperature dependent data def graphTmpData( keyProp, jsonfilename ): # Import required modules from matplotlib import pyplot as plt import json # Open the mks json data file with open(jsonfilename, 'rt') as mksfile: # Load json data from file mksdata = json.load(mksfile) # Initialize values axes = plt.gca() vunits = "" tunits = "" edx = 0 # Compile property data for entity in mksdata['Entities']: for property in entity['Properties']: if( property['Property'] == keyProp ): # Initialize data lists xvalues = [] yvalues = [] # Retrieve property data for datum in property['Data']: # Compile datum values xvalues.append(datum['Temperature']) yvalues.append(datum['Value']) # Assign property units from first datum if( len(property['Data']) > 0 ): datum = property['Data'][0] if( vunits == "" ): vunits = datum['ValueUnits'] if( tunits == "" ): tunits = datum['TempUnits'] # Plot xy values as scatter plot axes.scatter(xvalues, yvalues, label=entity['Identifier']) # Increment entity index edx = edx + 1 # Finalize graph attributes axes.grid(True, linestyle='--', color='0.80') axes.set_ylabel('Property Value, ' + vunits) axes.set_xlabel('Temperature, ' + tunits) axes.set_title(keyProp) plt.legend(loc=0) # Show graph plt.show() # End graphTmpData return