Advertisement
Poopoopeepe

Graphing csv file with matplotlib

Oct 29th, 2023 (edited)
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.50 KB | Source Code | 0 0
  1. import matplotlib.pyplot as plt
  2. import pandas as pd
  3.  
  4. # Load the CSV data into a DataFrame
  5. df = pd.read_csv('draft2.csv')
  6.  
  7. # Remove duplicates
  8. df = df.drop_duplicates()
  9.  
  10. # Sort the DataFrame by the columns of your choice (e.g., X, Y)
  11. df = df.sort_values(by=['X', 'Y'])
  12.  
  13. # Extract X and Y data
  14. x = df['X']
  15. y = df['Y']
  16.  
  17. # Create a scatter plot
  18. plt.scatter(x, y)
  19. plt.xlabel('X')
  20. plt.ylabel('Y')
  21. plt.title('Scatter Plot of Cleaned X and Y Data')
  22. plt.grid(True)
  23.  
  24. # Display the plot
  25. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement