123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- # -*- coding: utf-8 -*-
- """
- Created on Wed Mar 13 13:53:26 2024
- @author: arefks
- """
- import os
- import pandas as pd
- import seaborn as sns
- import matplotlib.pyplot as plt
- # Get the directory where the code file is located
- code_dir = os.path.dirname(os.path.abspath(__file__))
- # Get the parent directory of the code directory
- parent_dir = os.path.dirname(code_dir)
- # Specify the input file path relative to the code file
- input_file_path = os.path.join(parent_dir, 'output', 'Normalized_behaviour_data.csv')
- # Read the CSV file into a Pandas DataFrame
- df = pd.read_csv(input_file_path)
- # Setting the theme for the plots
- sns.set_theme(style="ticks")
- # Define the clusters
- clusters = ["Group"]
- cm = 1/2.54
- # Adjust the size and DPI for all plots
- plt.figure(figsize=(78/3*cm, 11.86/3*cm), dpi=300)
- # Define custom palette with colors for each category
- custom_palette = {"Sham": "grey", "Stroke": "red"}
- # Loop through each cluster and create a catplot
- for cluster in clusters:
- g = sns.catplot(
- data=df, x="TimePointMerged", y="Z_C_PawDragPercent", hue=cluster,
- palette=custom_palette, kind="point", height=5, aspect=2.75,
- estimator="mean", errorbar=('ci', 95), legend=False,linestyles=["-", "--"]
- )
- g.despine(left=True)
- plt.title(f'Boxplot for {cluster}', fontsize=38.9, fontweight='bold', fontname='Calibri')
- # Set x and y labels
- plt.xlabel("Time Point", fontsize=38.9, fontweight='bold', fontname='Calibri')
- plt.ylabel("Number of hindlimb drops", fontsize=38.9, fontweight='bold', fontname='Calibri')
- # Set x and y tick parameters
- plt.xticks(fontsize=38.9, fontweight='bold', fontname='Calibri')
- plt.yticks(fontsize=38.9, fontweight='bold', fontname='Calibri')
- # Access the current axes
- ax = plt.gca()
- # Set visibility, color, and thickness of axes
- ax.spines['top'].set_visible(True)
- ax.spines['right'].set_visible(True)
- ax.spines['bottom'].set_visible(True)
- ax.spines['left'].set_visible(True)
- ax.spines['top'].set_color('black')
- ax.spines['right'].set_color('black')
- ax.spines['bottom'].set_color('black')
- ax.spines['left'].set_color('black')
- ax.spines['top'].set_linewidth(0) # Set thickness of top spine
- ax.spines['right'].set_linewidth(0) # Set thickness of right spine
- ax.spines['bottom'].set_linewidth(4) # Set thickness of bottom spine
- ax.spines['left'].set_linewidth(4) # Set thickness of left spine
- #g.set(ylim=(0, 0))
- # Set thickness of ticks
- plt.tick_params(axis='both', which='major', width=4, length=11)
- # Adjust the thickness of the lines
- for line in ax.lines:
- line.set_linewidth(5) # Set the desired linewidth
- plt.show()
|