1

enter image description hereI have an excel file having large no. of experiment data, each experiment data start with time column value 00:00:00., ending time is not same for all. I want plot of all experiment data in same graph

Currently I wrote a Python script, it is plotting well but i am facing with one issue that is, End point of first experiment is connected through a line with first point of second experiment which i do not want.

also when i was tried to plot every 5th experiment then color not changes of each experiment

I tried this code but it is not capable to resolve the issue

file_path = os.path.join(source_folder, file_name)

        df = pd.read_excel(file_path, sheet_name='record')  

        filtered_df = df[df.iloc[:, 3] == 'CC DChg']

        selected_columns = ['Time', 'Current(A)', 'Voltage(V)', 'Capacity(Ah)', 'Energy(Wh)']
        
        filtered_selected_df = filtered_df[selected_columns]
        
        start_indices = filtered_selected_df[filtered_selected_df['Time'] == '00:00:00'].index
        plt.figure(figsize=(8, 6))
        
        num_experiments = len(start_indices) 
        #colors = plt.cm.viridis(np.linspace(0, 1, num_experiments))
              
        for i in range(0, num_experiments):
            start_idx = start_indices[i]
            
            if i + 1 < num_experiments:
                end_idx = start_indices[i + 1]
            else:
                end_idx = len(filtered_selected_df)
                
            experiment_data = filtered_selected_df.iloc[start_idx:end_idx]
            
            if i != 0:
                experiment_data = pd.concat([pd.DataFrame({'Capacity(Ah)': [float('nan')], 'Voltage(V)': [float('nan')]}),
                                             experiment_data])
            
            plt.plot(experiment_data['Capacity(Ah)'], experiment_data['Voltage(V)'],marker='o', linestyle='-', 
                     label=f'cycle {i + 1}')
            plt.legend()
            
        plt.title(f'Voltage vs Capacity for {file_name}')
        plt.xlabel('Capacity(Ah)')
        plt.ylabel('Voltage(V)')
        plt.grid(True)
        plt.show()

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.