Skip to content

Commit 6049ea9

Browse files
committed
last comments
1 parent f8c62df commit 6049ea9

File tree

10 files changed

+221
-191
lines changed

10 files changed

+221
-191
lines changed

TODO.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ For v3.0 (to be submitted):
3030

3131
- [x] Fig. or Figure? → Fig. ;-)
3232
- [x] PACS code, MSC code? → not relevant, also PACS is discontinued
33-
- [ ] tries to move labels as much as possible in graphs
33+
- [x] tries to move labels as much as possible in graphs
3434
- [x] pack the geometries
3535
- [x] Description of the SI? → Nope
3636
- [x] Mat → Matsui
3737
- [x] Data availability
3838
- [x] Update SI (!!)
39-
- [ ] Address last comments
39+
- [x] Address last comments

analyses/plot_pot_er.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def plot_corr_Er(ax, data: pandas.DataFrame, column: str):
6161

6262
x = numpy.array([(f * subdata['Er']).min(), (f * subdata['Er']).max()])
6363
ax.plot(x, result.slope*x + result.intercept, 'k--')
64-
ax.text(0, result.intercept + .1, '$R^2$={:.2f}'.format(result.rvalue **2))
64+
ax.text(3 * f, result.intercept - .05, '$R^2$={:.2f}'.format(result.rvalue **2), size=12)
6565

6666
def make_table(f, data: pandas.DataFrame, solvent: str):
6767
subdata = data[(data['solvent'] == solvent) & data['px'].notnull()]

analyses/plot_pot_hammet.py

Lines changed: 62 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -9,40 +9,46 @@
99
from scipy.spatial import distance_matrix
1010
from nitroxides.commons import dG_DH, AU_TO_M, LabelPositioner, AU_TO_EV
1111

12-
LABELS = {'E_ox': [], 'E_red': []}
13-
POINTS_POSITION ={'E_ox': [], 'E_red': []}
14-
LABELS_KWARGS = {'E_ox': [], 'E_red': []}
15-
LABELS_PATH = {'E_ox': pathlib.Path('pot_hammet_ox.pos'), 'E_red': pathlib.Path('pot_hammet_red.pos')}
16-
17-
def plot_hammet(ax, data: pandas.DataFrame, column: str, family: str, color: str):
18-
subdata = data[(data['solvent'] == 'water') & (data['family'] == family) & data['hammet'].notnull()]
12+
LABELS = {'E_ox_hammet': [], 'E_red_hammet': [], 'E_ox_inductive': [], 'E_red_inductive': []}
13+
POINTS_POSITION = {'E_ox_hammet': [], 'E_red_hammet': [], 'E_ox_inductive': [], 'E_red_inductive': []}
14+
LABELS_KWARGS = {'E_ox_hammet': [], 'E_red_hammet': [], 'E_ox_inductive': [], 'E_red_inductive': []}
15+
LABELS_PATH = {
16+
'E_ox_hammet': pathlib.Path('pot_hammet_ox.pos'),
17+
'E_red_hammet': pathlib.Path('pot_hammet_red.pos'),
18+
'E_ox_inductive': pathlib.Path('pot_hammet_ox_inductive.pos'),
19+
'E_red_inductive': pathlib.Path('pot_hammet_red_inductive.pos')
20+
}
21+
22+
def plot_hammet(ax, data: pandas.DataFrame, column: str, family: str, color: str, const: str = 'hammet'):
23+
subdata = data[(data['solvent'] == 'water') & (data['family'] == family) & data[const].notnull()]
1924

2025
if column == 'E_ox':
2126
dG_DH_ = dG_DH(subdata['z'] + 1, subdata['z'], subdata['r_ox'] / AU_TO_M * 1e-10, subdata['r_rad'] / AU_TO_M * 1e-10, 80, 0) * AU_TO_EV
2227
else:
2328
dG_DH_ = dG_DH(subdata['z'], subdata['z'] - 1, subdata['r_rad'] / AU_TO_M * 1e-10, subdata['r_red'] / AU_TO_M * 1e-10, 80, 0) * AU_TO_EV
2429

25-
ax.plot(subdata['hammet'], subdata[column] - dG_DH_, 'o', color=color, label=family.replace('Family.', ''))
30+
ax.plot(subdata[const], subdata[column] - dG_DH_, 'o', color=color, label=family.replace('Family.', ''))
2631

27-
for name, hammet, e in zip(subdata['name'], subdata['hammet'], subdata[column] - dG_DH_):
32+
for name, hammet, e in zip(subdata['name'], subdata[const], subdata[column] - dG_DH_):
2833
name = name.replace('mol_', '')
29-
LABELS[column].append(name)
30-
POINTS_POSITION[column].append((hammet, e))
31-
LABELS_KWARGS[column].append(dict(color=color, ha='center', va='center'))
34+
n = '{}_{}'.format(column, const)
35+
LABELS[n].append(name)
36+
POINTS_POSITION[n].append((hammet, e))
37+
LABELS_KWARGS[n].append(dict(color=color, ha='center', va='center'))
3238

33-
def plot_corr_hammet(ax, data: pandas.DataFrame, column: str):
34-
subdata = data[(data['solvent'] == 'water') & data['hammet'].notnull()]
39+
def plot_corr_hammet(ax, data: pandas.DataFrame, column: str, family: str, color: str, const: str = 'hammet'):
40+
subdata = data[(data['solvent'] == 'water') & (data['family'] == family) & data[const].notnull()]
3541

3642
if column == 'E_ox':
3743
dG_DH_ = dG_DH(subdata['z'] + 1, subdata['z'], subdata['r_ox'] / AU_TO_M * 1e-10, subdata['r_rad'] / AU_TO_M * 1e-10, 80, 0) * AU_TO_EV
3844
else:
3945
dG_DH_ = dG_DH(subdata['z'], subdata['z'] - 1, subdata['r_rad'] / AU_TO_M * 1e-10, subdata['r_red'] / AU_TO_M * 1e-10, 80, 0) * AU_TO_EV
4046

41-
result = scipy.stats.linregress(subdata['hammet'], subdata[column] - dG_DH_)
47+
result = scipy.stats.linregress(subdata[const], subdata[column] - dG_DH_)
4248

4349
x = numpy.array([-1., 1.])
44-
ax.plot(x, result.slope*x + result.intercept, 'k--')
45-
ax.text(-.7, -result.slope + result.intercept, '$R^2$={:.3f}'.format(result.rvalue **2))
50+
ax.plot(x, result.slope*x + result.intercept, '--', color=color)
51+
ax.text(-.9, -result.slope + result.intercept + .1, '$R^2$={:.2f}'.format(result.rvalue **2), color=color)
4652

4753
parser = argparse.ArgumentParser()
4854
parser.add_argument('-i', '--input', default='../data/Data_pot.csv')
@@ -53,46 +59,53 @@ def plot_corr_hammet(ax, data: pandas.DataFrame, column: str):
5359

5460
data = pandas.read_csv(args.input)
5561

56-
figure = plt.figure(figsize=(9, 5))
57-
ax1, ax2 = figure.subplots(1, 2)
58-
59-
plot_hammet(ax1, data, 'E_ox', 'Family.P6O', 'tab:blue')
60-
plot_hammet(ax1, data, 'E_ox', 'Family.P5O', 'black')
61-
plot_corr_hammet(ax1, data, 'E_ox')
62+
figure = plt.figure(figsize=(8, 8))
63+
(ax1, ax2), (ax3, ax4) = figure.subplots(2, 2)
6264

63-
positioner = LabelPositioner.from_file(
64-
LABELS_PATH['E_ox'],
65-
numpy.array(POINTS_POSITION['E_ox']),
66-
LABELS['E_ox'],
67-
labels_kwargs=LABELS_KWARGS['E_ox']
68-
)
65+
for axes, const in [((ax1, ax2), 'hammet'), ((ax3, ax4), 'inductive'),]:
66+
67+
for family, color in [('Family.P6O', 'tab:blue'), ('Family.P5O', 'black')]:
68+
plot_hammet(axes[0], data, 'E_ox', family, color, const=const)
69+
plot_corr_hammet(axes[0], data, 'E_ox', family, color, const=const)
70+
71+
n = 'E_ox_{}'.format(const)
6972

70-
if args.reposition_labels:
71-
positioner.optimize(dx=1e-4, beta=1e5, krep=1, kspring=1000, c=0.03, b0=0.01, scale=(.15, 1))
72-
positioner.save(LABELS_PATH['E_ox'])
73+
positioner = LabelPositioner.from_file(
74+
LABELS_PATH[n],
75+
numpy.array(POINTS_POSITION[n]),
76+
LABELS[n],
77+
labels_kwargs=LABELS_KWARGS[n]
78+
)
7379

74-
positioner.add_labels(ax1)
80+
if args.reposition_labels:
81+
positioner.optimize(dx=1e-3, beta=1e4, krep=1, kspring=1000, c=0.03, b0=0.02, scale=(.2, 1))
82+
positioner.save(LABELS_PATH[n])
7583

76-
plot_hammet(ax2, data, 'E_red', 'Family.P6O', 'tab:blue')
77-
plot_hammet(ax2, data, 'E_red', 'Family.P5O', 'black')
78-
plot_corr_hammet(ax2, data, 'E_red')
84+
positioner.add_labels(axes[0])
85+
86+
for family, color in [('Family.P6O', 'tab:blue'), ('Family.P5O', 'black')]:
87+
plot_hammet(axes[1], data, 'E_red', family, color, const=const)
88+
plot_corr_hammet(axes[1], data, 'E_red', family, color, const=const)
89+
90+
n = 'E_red_{}'.format(const)
7991

80-
positioner = LabelPositioner.from_file(
81-
LABELS_PATH['E_red'],
82-
numpy.array(POINTS_POSITION['E_red']),
83-
LABELS['E_red'],
84-
labels_kwargs=LABELS_KWARGS['E_red']
85-
)
92+
positioner = LabelPositioner.from_file(
93+
LABELS_PATH[n],
94+
numpy.array(POINTS_POSITION[n]),
95+
LABELS[n],
96+
labels_kwargs=LABELS_KWARGS[n]
97+
)
8698

87-
if args.reposition_labels:
88-
positioner.optimize(dx=1e-3, beta=1e4, krep=1, kspring=1000, c=0.03, b0=0.015, scale=(.2, 1))
89-
positioner.save(LABELS_PATH['E_red'])
99+
if args.reposition_labels:
100+
positioner.optimize(dx=1e-3, beta=1e4, krep=1, kspring=1000, c=0.04, b0=0.03, scale=(.3, 1))
101+
positioner.save(LABELS_PATH[n])
90102

91-
positioner.add_labels(ax2)
103+
positioner.add_labels(axes[1])
92104

93-
[ax.set_xlabel('Hammet constant $\\sigma$') for ax in [ax1, ax2]]
94-
ax1.set_ylabel('$E^0_{abs}(N^+|N^\\bullet)$ (V)')
95-
ax2.set_ylabel('$E^0_{abs}(N^\\bullet|N^-)$ (V)')
105+
[ax.set_xlabel('Hammet constant $\\sigma_m$ or $\\sigma_p$') for ax in [ax1, ax2]]
106+
[ax.set_xlabel('Inductive constante $\\sigma_I$') for ax in [ax3, ax4]]
107+
[ax.set_ylabel('$E^0_{abs}(N^+|N^\\bullet)$ (V)') for ax in [ax1, ax3]]
108+
[ax.set_ylabel('$E^0_{abs}(N^\\bullet|N^-)$ (V)') for ax in [ax2, ax4]]
96109

97110
plt.tight_layout()
98111
figure.savefig(args.output)

analyses/pot_hammet_ox.pos

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
,label,x,y
2-
0,3,0.4576194551447756,5.176347775489531
3-
1,4,-0.6606786893389066,5.139446733924163
4-
2,5,-0.25112430538905217,5.18815546245546
5-
3,6,-0.3782332015637821,5.19469803681695
6-
4,7,0.46619835666638804,5.099563815532129
7-
5,8,0.44919503190560184,5.203110932341964
8-
6,11,0.6170431239177386,5.296202705937092
9-
7,12,0.48980260023399724,5.289174666471553
10-
8,61,0.2303611942347875,5.205943433790021
11-
9,15,0.3680648088282664,5.265534837088523
12-
10,16,-0.15985673167674225,5.139990050271139
13-
11,17,0.12053743319824385,5.115172161265339
14-
12,18,0.12139334660940311,5.141368819654295
15-
13,19,0.35324034156647377,5.105653807241818
16-
14,21,0.8598592769349482,5.2878534135542585
17-
15,56,0.2811774868724122,5.174688084155005
18-
16,57,0.0986909467164238,5.080575907276883
19-
17,58,0.2804138275758015,5.317279899002262
20-
18,59,0.10218132248457962,5.186546152052083
2+
0,3,0.4656610520531984,5.152417704564987
3+
1,4,-0.6619049175699073,5.109509642795776
4+
2,5,-0.30489980001724165,5.157673432648357
5+
3,6,-0.3744511249944037,5.204534527734516
6+
4,7,0.5207049024291663,5.105300510656678
7+
5,8,0.4685449719711929,5.212333685706411
8+
6,11,0.5942757421805165,5.26690499872594
9+
7,12,0.4984461760139272,5.319452721428102
10+
8,61,0.24888752994444552,5.2151799022595835
11+
9,15,0.36656076386291225,5.235372653308749
12+
10,16,-0.14388278834627607,5.16959473689317
13+
11,17,0.15830518394163073,5.107061371120523
14+
12,18,0.1523359552800044,5.168807658996612
15+
13,19,0.3463333522455231,5.133962895633457
16+
14,21,0.8604157136013464,5.297784710475765
17+
15,56,0.3025314332598707,5.1651932328748265
18+
16,57,0.044855782742234424,5.087187385609759
19+
17,58,0.28479378295988245,5.327166770378123
20+
18,59,0.08530681495166542,5.216335927032842
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
,label,x,y
2+
0,4,0.08186001529337986,5.109669262795919
3+
1,5,0.1216877781083697,5.179951223916893
4+
2,6,0.26614123810058693,5.204223136232075
5+
3,61,0.441928789072139,5.175859953858624
6+
4,16,0.004853312884317348,5.154778148621946
7+
5,17,0.23000928203322155,5.104671984782734
8+
6,18,0.29008216968548856,5.132189953182486

analyses/pot_hammet_red.pos

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
,label,x,y
2-
0,3,0.4352083462440204,3.0116800415883263
3-
1,4,-0.6562121090433323,3.010440101492028
4-
2,5,-0.2629680933188102,2.9840132731138604
5-
3,6,-0.364194688738776,3.033507401135774
6-
4,7,0.47792258351026057,2.7875626965663995
7-
5,8,0.4597628155273639,3.05596282690366
8-
6,11,0.6023137066881413,3.1164431657135685
9-
7,12,0.48234002806695414,3.152896507213074
10-
8,61,0.22535150910342203,3.046064622432041
11-
9,15,0.37101496454175054,2.966578215473745
12-
10,16,-0.16097137025307323,2.8710966481003237
13-
11,17,0.2190092710125824,2.9142559067618317
14-
12,18,0.10141105589034936,2.960508715566389
15-
13,19,0.44540862803096176,2.7574447522759185
16-
14,21,0.8736394854908002,3.155250845339613
17-
15,56,0.2872158227717198,2.7398726716995943
18-
16,57,0.11705461837728477,2.8728723482933916
19-
17,58,0.2608371158535701,2.7696985017581195
20-
18,59,0.04649924626357542,2.900332165360863
2+
0,3,0.4990244640551145,3.0010280141011356
3+
1,4,-0.6718668547338792,3.0252138283592562
4+
2,5,-0.29158488492932827,2.969758016682694
5+
3,6,-0.352321062073168,3.0485186701559117
6+
4,7,0.45988533990197816,2.8026866051653823
7+
5,8,0.44756264752176833,3.0715122621198025
8+
6,11,0.6315731980255984,3.1290609603411412
9+
7,12,0.4947782009410651,3.1690258292053675
10+
8,61,0.22946429763164528,3.030994075545434
11+
9,15,0.36830563739852423,2.981910200761413
12+
10,16,-0.16512102424067154,2.8559740904299598
13+
11,17,0.23289805487069487,2.9147097503643757
14+
12,18,0.11536504251354196,2.976286041717534
15+
13,19,0.4435114839990776,2.736719935243295
16+
14,21,0.868802064446903,3.1399317469845727
17+
15,56,0.2759952972892173,2.725164954506571
18+
16,57,0.11450125028242476,2.8575151098804445
19+
17,58,0.26719533093094594,2.814114857132419
20+
18,59,0.03245426200475297,2.8891308161561295
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
,label,x,y
2+
0,4,0.035337376581764765,2.972832641983517
3+
1,5,0.17303030526137994,2.9745066545200234
4+
2,6,0.256138337583797,3.048211819297735
5+
3,61,0.4624777991554793,3.0908431851705114
6+
4,16,0.11658116035635802,2.8564251098759574
7+
5,17,0.22672574154336922,2.8821160103296757
8+
6,18,0.3084960903721986,2.9185944209147814

0 commit comments

Comments
 (0)