Advertisement
UF6

Log10 Based For Violin Plot With Improved Column Finding

UF6
Nov 8th, 2023
931
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.00 KB | Source Code | 0 0
  1.  
  2. import pandas as pd
  3. import seaborn as sns
  4. import matplotlib.pyplot as plt
  5. import numpy as np
  6.  
  7. # Replace 'B5 segmentSummary (1).csv' with the actual CSV file path
  8. file_path = 'B5 segmentSummary (1).csv'
  9.  
  10. # Define the range of column positions you want to analyze (columns 6 through 10)
  11. start_column_position = 6  # Corresponds to column 6
  12. end_column_position = 9    # Corresponds to column 10
  13.  
  14. # Read the CSV file into a Pandas DataFrame
  15. df = pd.read_csv(file_path)
  16.  
  17. # Select columns 6 through 10 for analysis
  18. selected_columns = df.iloc[:, start_column_position:end_column_position + 1]
  19.  
  20. # Apply a log10 transformation to the data
  21. log_selected_columns = np.log10(selected_columns)
  22.  
  23. # Create a violin plot to visualize log10-transformed data
  24. plt.figure(figsize=(10, 6))
  25. sns.violinplot(data=log_selected_columns, inner="stick")
  26. plt.title('Violin Plot for Log10-Transformed Selected Columns')
  27. plt.ylabel('Log10(Values)')
  28. plt.xticks(rotation=45)
  29. plt.tight_layout()
  30.  
  31. # Show the plot
  32. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement