-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3d_scatterplot_subplots.py
More file actions
100 lines (85 loc) · 2.76 KB
/
Copy path3d_scatterplot_subplots.py
File metadata and controls
100 lines (85 loc) · 2.76 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/usr/bin/env python
# coding: utf-8
"""3D Scatter Plots with Python and Matplotlib
Author: Polina Lemenkova
ORCID: https://orcid.org/0000-0002-5759-1089
Archive: https://doi.org/10.13140/RG.2.2.13107.89124
License: MIT
See README.md for details.
"""
import os
import matplotlib.artist as martist
import matplotlib.cm as cmx
import matplotlib.pylab as pylab
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from matplotlib.colors import ListedColormap
from matplotlib.offsetbox import AnchoredText
from mpl_toolkits.mplot3d import Axes3D
os.chdir(os.path.dirname(os.path.abspath(__file__)))
df = pd.read_csv("Tab-Morph.csv")
params = {'figure.figsize': (10, 8),
'figure.dpi': 300,
'figure.titlesize': 14,
'font.family': 'Palatino',
'axes.labelsize': 8,
'axes.titlesize': 12,
'axes.titlepad': 1,
'axes.labelpad': .5,
}
pylab.rcParams.update(params)
def add_at(ax, t, loc=2):
fp = dict(size=11)
_at = AnchoredText(t, loc=loc, prop=fp)
ax.add_artist(_at)
return _at
fig = plt.figure()
fig.suptitle('3D correlation scatter plot, factors: \n sediment thickness, slope steepness, bathymetry (observation samples)',
x=0.5, y=0.97)
# subplot 1
ax = fig.add_subplot(221, projection='3d')
ax.scatter(df.plate_pacif, df.sedim_thick, df.slope_angle,
c='#ee827c', edgecolors='grey', s=130, alpha=.9)
ax.set_xlabel('Pacific Plate')
ax.set_ylabel('sediment thickness')
ax.set_zlabel('slope angle')
ax.view_init(30, 185)
plt.title('Pacific Plate')
add_at(ax, "A")
# subplot 2
ax = fig.add_subplot(222, projection='3d')
ax.scatter(df.plate_phill, df.sedim_thick, df.slope_angle,
c='#f8b500', edgecolors='grey', s=130, alpha=.6)
ax.set_xlabel('Philippine Plate')
ax.set_ylabel('sediment thickness')
ax.set_zlabel('slope angle')
ax.view_init(30, 185)
plt.title('Phillipine Plate')
add_at(ax, "B")
# subplot 3
ax = fig.add_subplot(223, projection='3d')
ax.scatter(df.plate_carol, df.sedim_thick, df.slope_angle,
c='#aacf53', edgecolors='grey', s=130, alpha=.8)
ax.set_xlabel('Caroline Plate')
ax.set_ylabel('sediment thickness')
ax.set_zlabel('slope angle')
ax.view_init(30, 185)
plt.title('Caroline Plate')
add_at(ax, "C")
# subplot 4
ax = fig.add_subplot(224, projection='3d')
ax.scatter(df.plate_maria, df.sedim_thick, df.slope_angle,
c='#0095d9', edgecolors='grey', s=130, alpha=.7)
ax.set_xlabel('Mariana Plate')
ax.set_ylabel('sediment thickness')
ax.set_zlabel('slope angle')
ax.view_init(30, 185)
plt.title('Mariana Plate')
add_at(ax, "D")
plt.tight_layout()
plt.subplots_adjust(top=0.85, bottom=0.25,
left=0.10, right=0.95,
hspace=0.05, wspace=0.05
)
fig.savefig('plot_3DScat.png')