0% found this document useful (0 votes)
2 views3 pages

Python Code CP

Uploaded by

queue tea
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views3 pages

Python Code CP

Uploaded by

queue tea
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

import pandas as pd

import [Link] as plt

import os

# File path

file_path = r"D:\Project PHD\Acousticplastic treated results\Qanita Cu tREATED Samples\Cyclic


Polarization [Link]"

# Check if file exists

if not [Link](file_path):

raise FileNotFoundError(f"The file {file_path} does not exist.")

# Read and clean data

df = pd.read_excel(file_path)

df = [Link](pd.to_numeric, errors='coerce')

# Extract columns

x1, y1 = [Link][:, 0], [Link][:, 1] # T-6 20µm

x2, y2 = [Link][:, 2], [Link][:, 3] # T-30 20µm

x3, y3 = [Link][:, 4], [Link][:, 5] # T-30 40µm

x4, y4 = [Link][:, 6], [Link][:, 7] # T-6 40µm

# Filter valid log data

def valid_log_data(x, y):

x = [Link](x).abs()

y = [Link](y)

mask = (x > 0) & [Link]() & [Link]()

return x[mask], y[mask]

x1f, y1f = valid_log_data(x1, y1)

x2f, y2f = valid_log_data(x2, y2)


x3f, y3f = valid_log_data(x3, y3)

x4f, y4f = valid_log_data(x4, y4)

# Plot settings

[Link](figsize=(10, 6))

[Link]({

"[Link]": "Times New Roman",

"[Link]": 16,

"[Link]": 1.5,

})

# Plot curves (X = current density, Y = potential)

[Link](x1f, y1f, color='red', marker='o', markersize=1, label='T-6 20µm')

[Link](x2f, y2f, color='green', marker='D', markersize=1, label='T-30 20µm')

[Link](x4f, y4f, color='purple', marker='^', markersize=1, label='T-6 40µm')

[Link](x3f, y3f, color='blue', marker='s', markersize=1, label='T-30 40µm')

# Axis labels

[Link]('Current density (A/cm²)', fontsize=18)

[Link]('Potential (V vs. SCE)', fontsize=18)

# Log scale on X-axis

[Link]('log')

[Link]([1e-7, 1e-1])

[Link]([-1, 1.5])

# Frame

ax = [Link]()

for spine in [Link]():

spine.set_visible(True)

# Legend — horizontal, top-left, above plot


[Link](

loc='upper left',

#bbox_to_anchor=(0, 1.18),

frameon=False,

fontsize=16,

ncol=4,

handlelength=1.5,

handletextpad=0.5,

columnspacing=1.3

# Ticks and layout

[Link](fontsize=14)

[Link](fontsize=14)

plt.tight_layout()

[Link]()

You might also like