Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pandas as pd
- import matplotlib.pyplot as plt
- # Replace 'Line Plot.csv' with the actual CSV file path
- df = pd.read_csv('Line Plot.csv')
- # Extract data from the DataFrame
- values1 = df['Raw Reads']
- values2 = df['Trimmed Reads']
- values3 = df['Aligned Reads']
- values4 = df['Deduplicated Reads']
- values5 = df['Stitched Reads']
- # Calculate the total sum of values for each read type
- total_values1 = values1.sum()
- total_values2 = values2.sum()
- total_values3 = values3.sum()
- total_values4 = values4.sum()
- total_values5 = values5.sum()
- # Data for the pie chart
- data = [total_values1, total_values2, total_values3, total_values4, total_values5]
- labels = ['Raw Reads', 'Trimmed Reads', 'Aligned Reads', 'Deduplicated Reads', 'Stitched Reads']
- colors = ['#ff9999', '#66b3ff', '#99ff99', '#ffcc99', '#c2c2f0']
- explode = (0.05, 0.05, 0.05, 0.05, 0.05) # To explode a slice
- # Create a pie chart with improved aesthetics
- plt.figure(figsize=(8, 8))
- plt.pie(data, labels=labels, autopct='%1.1f%%', startangle=140, colors=colors, pctdistance=0.85, explode=explode)
- # Draw a circle in the center to make it a donut chart (optional)
- center_circle = plt.Circle((0, 0), 0.70, fc='white')
- fig = plt.gcf()
- fig.gca().add_artist(center_circle)
- # Customize the plot
- plt.title('Distribution of Reads', fontsize=16, fontweight='bold')
- plt.axis('equal') # Equal aspect ratio ensures that the pie chart is circular
- plt.legend(labels, loc='upper right', bbox_to_anchor=(0.85, 1))
- # Move the legend to the left-hand side
- plt.legend(labels, loc='upper left', bbox_to_anchor=(-0.25, 0.9))
- # Show the plot
- plt.tight_layout()
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement