<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Microsoft Emotion API Data
Images were placed into the API by hand since there were so few. This step was automated using the API for the Baseline data
Step1:  Plotting sentiment for each image.
Step2:  Plotting sentiment for each image
<ASSISTANT_TASK:>
Python Code:
def read_jsons(f, candidate):
   
    tmp_dict = {}
    with open(f) as json_file:    
        data = json.load(json_file)
        for i in data[0]['scores']:
            if data[0]['scores'][i] > 0.55:   # confidence score threshold. 
                tmp_dict[i] = data[0]['scores'][i]
            else: tmp_dict[i] = np.nan
                
        tmp_dict['image_file'] = f.split('/')[-1]    
        
        return tmp_dict
basefilepath = './MicrosoftEmotionAPI/'
def get_json(path, candidate):
    
    for f in glob.glob(path + '*.json'):
        #print(f)
        if candidate in f:
            row_list.append(read_jsons(f, candidate))
row_list = []
get_json(basefilepath, 'hillary_clinton')
HCDF = pd.DataFrame(row_list)  
HCDF.head(11)
Explanation: Microsoft Emotion API Data
Images were placed into the API by hand since there were so few. This step was automated using the API for the Baseline data
End of explanation
HCDF.plot(kind='bar', ylim=(0,1))
plt.legend(bbox_to_anchor=(1.1, 1))
row_list = []
get_json(basefilepath, 'donald_trump')
DTDF = pd.DataFrame(row_list)  
DTDF.head(12)
Explanation: Plotting sentiment for each image.
End of explanation
DTDF.plot(kind='bar',ylim=(0,1))
plt.legend(bbox_to_anchor=(1.12, 1))
Explanation: Plotting sentiment for each image
End of explanation
<END_TASK>