質問編集履歴
2
エラーが出るコードを追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -53,7 +53,7 @@
|
|
53
53
|
-0.1442105,-0.220104095,4.73E-02,18
|
54
54
|
-0.1439502,-0.216082524,3.67E-02,18
|
55
55
|
|
56
|
-
##
|
56
|
+
##グラデーションになっていないがグラフはできるソースコード
|
57
57
|
|
58
58
|
```python
|
59
59
|
import pandas as pd
|
@@ -80,7 +80,34 @@
|
|
80
80
|
plt.legend()
|
81
81
|
plt.show()
|
82
82
|
```
|
83
|
+
##グラデーションにしようとしてエラーが出るソースコード
|
84
|
+
```Python
|
85
|
+
import pandas as pd
|
86
|
+
import matplotlib.pyplot as plt
|
87
|
+
from mpl_toolkits.mplot3d import Axes3D
|
88
|
+
import matplotlib.colors as mcolors
|
83
89
|
|
90
|
+
df = pd.read_csv(r"test.csv", delimiter=",", sep='\s+', skipinitialspace=True)
|
91
|
+
|
92
|
+
fig = plt.figure()
|
93
|
+
ax = Axes3D(fig)
|
94
|
+
|
95
|
+
samples = sorted(set(df['sample']))
|
96
|
+
cmapval = df['sample']
|
97
|
+
|
98
|
+
|
99
|
+
# sample毎に描画
|
100
|
+
for idx, sample in enumerate(samples):
|
101
|
+
df2 = df[df['sample'] == sample]
|
102
|
+
X = df2["PC1"]
|
103
|
+
Y = df2["PC2"]
|
104
|
+
Z = df2["PC3"]
|
105
|
+
p=ax.scatter(X, Y, Z, c=cmapval, cmap='hsv', label=sample)
|
106
|
+
|
107
|
+
plt.legend()
|
108
|
+
plt.show()
|
109
|
+
|
110
|
+
```
|
84
111
|
##補足情報(FW/ツールのバージョンなど)
|
85
112
|
python 3.7
|
86
113
|
seaborn 0.10.0
|
1
データをカンマ区切りに修正しました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -4,63 +4,64 @@
|
|
4
4
|
宜しくお願い致します。
|
5
5
|
|
6
6
|
###Data
|
7
|
-
PC1
|
7
|
+
PC1,PC2,PC3,sample
|
8
|
-
-0.1413928
|
8
|
+
-0.1413928,0.02173982,-4.15E-01,1
|
9
|
-
-0.1413101
|
9
|
+
-0.1413101,0.017508996,-4.21E-01,1
|
10
|
-
-0.1417087
|
10
|
+
-0.1417087,0.014979086,-4.08E-01,1
|
11
|
-
-0.1411702
|
11
|
+
-0.1411702,0.008670829,-4.09E-01,1
|
12
|
-
-0.145876
|
12
|
+
-0.145876,0.123370613,-1.03E-01,2
|
13
|
-
-0.1433736
|
13
|
+
-0.1433736,0.124895934,-1.41E-01,2
|
14
|
-
-0.1456516
|
14
|
+
-0.1456516,0.092020696,-1.09E-01,3
|
15
|
-
-0.1461915
|
15
|
+
-0.1461915,0.094471875,-1.18E-01,3
|
16
|
-
-0.1461108
|
16
|
+
-0.1461108,0.090837929,-1.21E-01,3
|
17
|
-
-0.1472447
|
17
|
+
-0.1472447,0.119571378,-4.57E-02,4
|
18
|
-
-0.1472894
|
18
|
+
-0.1472894,0.115520249,-4.68E-02,4
|
19
|
-
-0.1467504
|
19
|
+
-0.1467504,0.121762527,-4.68E-02,4
|
20
|
-
-0.1491286
|
20
|
+
-0.1491286,0.090455109,9.15E-02,5
|
21
|
-
-0.1487338
|
21
|
+
-0.1487338,0.09812073,9.12E-02,5
|
22
|
-
-0.1489169
|
22
|
+
-0.1489169,0.072974728,1.14E-01,6
|
23
|
-
-0.1490467
|
23
|
+
-0.1490467,0.085162278,1.12E-01,6
|
24
|
-
-0.1489641
|
24
|
+
-0.1489641,0.08360632,1.23E-01,7
|
25
|
-
-0.148754
|
25
|
+
-0.148754,0.088689326,1.12E-01,7
|
26
|
-
-0.1487234
|
26
|
+
-0.1487234,0.090154785,1.12E-01,7
|
27
|
-
-0.1490534
|
27
|
+
-0.1490534,0.096598206,9.36E-02,8
|
28
|
-
-0.149099
|
28
|
+
-0.149099,0.096547726,8.85E-02,8
|
29
|
-
-0.1491893
|
29
|
+
-0.1491893,0.096628792,1.14E-01,9
|
30
|
-
-0.1490337
|
30
|
+
-0.1490337,0.10319152,1.07E-01,9
|
31
|
-
-0.1490627
|
31
|
+
-0.1490627,0.102746721,1.06E-01,9
|
32
|
-
-0.1479182
|
32
|
+
-0.1479182,0.114529747,1.13E-01,10
|
33
|
-
-0.1483447
|
33
|
+
-0.1483447,0.106218026,1.26E-01,10
|
34
|
-
-0.1483964
|
34
|
+
-0.1483964,0.106148189,1.23E-01,11
|
35
|
-
-0.1482859
|
35
|
+
-0.1482859,0.103531061,1.23E-01,11
|
36
|
-
-0.1487256
|
36
|
+
-0.1487256,0.110975705,9.76E-02,12
|
37
|
-
-0.1481255
|
37
|
+
-0.1481255,0.126683827,9.22E-02,12
|
38
|
-
-0.1479033
|
38
|
+
-0.1479033,0.130060792,8.73E-02,12
|
39
|
-
-0.1359165
|
39
|
+
-0.1359165,0.061005493,-7.12E-02,13
|
40
|
-
-0.1372293
|
40
|
+
-0.1372293,0.073245259,-4.54E-02,13
|
41
|
-
-0.1464516
|
41
|
+
-0.1464516,-0.153001981,2.27E-03,14
|
42
|
-
-0.1449456
|
42
|
+
-0.1449456,-0.204644258,9.43E-03,14
|
43
|
-
-0.1474867
|
43
|
+
-0.1474867,-0.111179279,-4.29E-05,15
|
44
|
-
-0.1463186
|
44
|
+
-0.1463186,-0.170116339,1.78E-02,15
|
45
|
-
-0.1458789
|
45
|
+
-0.1458789,-0.176175751,2.37E-02,15
|
46
|
-
-0.142477
|
46
|
+
-0.142477,-0.255583393,3.95E-02,16
|
47
|
-
-0.143537
|
47
|
+
-0.143537,-0.25325231,3.06E-02,16
|
48
|
-
-0.1428187
|
48
|
+
-0.1428187,-0.278201657,2.85E-02,16
|
49
|
-
-0.1427046
|
49
|
+
-0.1427046,-0.253661164,3.15E-02,17
|
50
|
-
-0.1432171
|
50
|
+
-0.1432171,-0.270822563,2.90E-02,17
|
51
|
-
-0.1431351
|
51
|
+
-0.1431351,-0.272426721,2.78E-02,17
|
52
|
-
-0.1442404
|
52
|
+
-0.1442404,-0.212473411,5.68E-02,18
|
53
|
-
-0.1442105
|
53
|
+
-0.1442105,-0.220104095,4.73E-02,18
|
54
|
-
-0.1439502
|
54
|
+
-0.1439502,-0.216082524,3.67E-02,18
|
55
55
|
|
56
56
|
##該当のソースコード
|
57
57
|
|
58
|
+
```python
|
58
59
|
import pandas as pd
|
59
60
|
import matplotlib.pyplot as plt
|
60
61
|
from mpl_toolkits.mplot3d import Axes3D
|
61
62
|
import matplotlib.colors as mcolors
|
62
63
|
|
63
|
-
df = pd.read_csv(r"
|
64
|
+
df = pd.read_csv(r"test.csv", delimiter=",", sep='\s+', skipinitialspace=True)
|
64
65
|
|
65
66
|
fig = plt.figure()
|
66
67
|
ax = Axes3D(fig)
|
@@ -68,7 +69,7 @@
|
|
68
69
|
samples = sorted(set(df['sample']))
|
69
70
|
colors = list(mcolors.CSS4_COLORS.keys())
|
70
71
|
|
71
|
-
sample毎に描画
|
72
|
+
# sample毎に描画
|
72
73
|
for idx, sample in enumerate(samples):
|
73
74
|
df2 = df[df['sample'] == sample]
|
74
75
|
X = df2["PC1"]
|
@@ -78,6 +79,7 @@
|
|
78
79
|
|
79
80
|
plt.legend()
|
80
81
|
plt.show()
|
82
|
+
```
|
81
83
|
|
82
84
|
##補足情報(FW/ツールのバージョンなど)
|
83
85
|
python 3.7
|