Advertisement
UF6

Raincloud Plots

UF6
Nov 14th, 2023
463
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.22 KB | Source Code | 0 0
  1. import pandas as pd
  2. import matplotlib.pyplot as plt
  3. import ptitprince as pt  # Import ptitprince for raincloud plots
  4. import seaborn as sns  # Import Seaborn for color palettes
  5.  
  6. # Replace 'B5 segmentSummary (1).csv' with the actual CSV file path
  7. file_path = 'B5 segmentSummary (1).csv'
  8.  
  9. # Define the range of column positions you want to analyze (columns 6 through 10)
  10. start_column_position = 6  # Corresponds to column 6
  11. end_column_position = 9  # Corresponds to column 10
  12.  
  13. # Read the CSV file into a Pandas DataFrame
  14. df = pd.read_csv(file_path)
  15.  
  16. # Create a Seaborn color palette for differentiation
  17. colors = sns.color_palette('husl', n_colors=end_column_position - start_column_position + 1)
  18.  
  19. # Create a figure with subplots for Raincloud plots
  20. plt.figure(figsize=(12, 12))
  21.  
  22. # Iterate through the selected columns and create Raincloud plots with different colors
  23. for i, col in enumerate(df.columns[start_column_position:end_column_position + 1]):
  24.     plt.subplot(2, 2, i + 1)  # Create subplots for Raincloud plot
  25.     pt.RainCloud(data=df, x=col, orient='h', width_viol=0.6, width_box=0.4, palette=[colors[i]])
  26.  
  27.     plt.title(f'Raincloud Plot for {col}')
  28.  
  29. # Adjust layout
  30. plt.tight_layout()
  31.  
  32. # Show the plots
  33. plt.show()
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement