-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_final.py
More file actions
34 lines (26 loc) · 845 Bytes
/
plot_final.py
File metadata and controls
34 lines (26 loc) · 845 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from numpy.polynomial.polynomial import polyfit
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
import mplcursors
import os
path = os.getcwd() + '/result.csv'
results = pd.read_csv(path, sep='\s+')
x, y = results['Area'].astype(float), results['N_relax'].astype(float)
text = results['Cluster_Name']
b, m = polyfit(x, y, 1)
fig, ax = plt.subplots(figsize=(14, 8))
rline = ax.plot(x, b+m*x, 'b-')
splot = ax.scatter(x, y, c='r')
crs = mplcursors.cursor(splot, multiple=True)
@crs.connect("add")
def _(sel):
sel.annotation.get_bbox_patch().set(fc="white")
sel.annotation.arrow_patch.set(arrowstyle=None, fc="white", alpha=.5)
crs.connect(
"add", lambda sel: sel.annotation.set_text(
text[sel.target.index].replace('_', ' ')
))
plt.xlabel('Area between tracks')
plt.ylabel('N_relax')
plt.show()