Issue with loading text file using numpy loadtxt - python-3.x

I am trying to load a text file which contains a set of arrays which looks like:
[ 90 91 92 93 94 95 96 97 100 101 102 103 157 158 159 160]
[ 58 59 60 61 62 63 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 102 103 104 105 108
109 110 111 127 128 129 130 131 132 133 134 135 137 138 139 140 145 146
147 148 171 172 173]
[ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
18 23 24 25 26 27 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 165 166 167 168 169
170 171 172 173]
I have tried using test = np.loadtxt('filename.txt') to load the text file but I keep getting this issue: could not convert string to float: [. The file does not contain any headers. Any help would be much appreciated. Thank you.

The following code will return a list of lists containing integers. This assumes that the data you have is all integers. If not, you can change the map call to convert to float instead:
import os.path as path
# Path to file.
path_to_data = path.join(path.dirname(path.realpath(__file__)),
'data.txt')
print(path_to_data)
# Read file contents.
with open(path_to_data) as file:
data = file.read()
print(data)
# Now we need to parse it for square braces.
data = data.replace("\n", " ").replace(" ", " ").replace(" ", " ")
data = data.replace("[ ", "[").replace(" ]", "]")
print(data)
# Now we loop through the string looking for [ symbols.
data_list = []
start_index = 0
end_index = 0
while 0 <= data.find('[', start_index):
start_index = data.find('[', start_index)
if 0 <= start_index <= data.find(']', start_index):
end_index = data.find(']', start_index)
# Don't include the braces, actually: grab what's in-between.
temp_str = data[start_index+1:end_index]
# Now split into a list based on spaces.
data_list.append(list(map(int, list(temp_str.split(" ")))))
start_index = end_index
print(data_list)

Related

Python-3 - get values from list by frequency and then by the values with equal counts in descending order

I have list of integers, from which I would first like to get unique numbers, first ordered by their occurrences and then the numbers with equal counts should be ordered in descending order.
example 1:
input1 = [1,2,2,1,6,2,1,7]
expected output = [2,1,7,6]
explanation: both 2 and 1 appear thrice while 6 and 7 appear once. so, the numbers occurring thrice will be placed first and in descending order; and same for the set that appears once.
another example case:
input_2 = list(map(int, '40 29 2 44 30 79 46 85 118 66 113 52 55 63 48 99 123 51 110 66 40 115 107 46 6 114 36 99 13 108 85 39 14 121 42 37 56 11 104 28 24 123 63 51 118 52 120 28 64 43 44 86 42 71 101 78 93 1 6 14 42 33 88 107 35 70 74 30 54 76 27 91 115 71 63 103 94 109 39 4 16 108 97 83 29 57 86 121 53 94 28 7 5 31 123 21 2 17 112 104 75 124 88 30 108 14 65 118 28 81 80 14 14 107 21 60 47 97 50 53 19 112 43 46'.split()))
output_2 = list(map(int, '14 28 123 118 108 107 63 46 42 30 121 115 112 104 99 97 94 88 86 85 71 66 53 52 51 44 43 40 39 29 21 6 2 124 120 114 113 110 109 103 101 93 91 83 81 80 79 78 76 75 74 70 65 64 60 57 56 55 54 50 48 47 37 36 35 33 31 27 24 19 17 16 13 11 7 5 4 1'.split()))
This was from a coding test I took. This must be solved without using functions from imports like collections, itertools etc,. and using functions already available in python's namespace like dict, sorted is allowed. How do I do this as efficiently as possible?
def sort_sort(input1):
a = {i:input1.count(i) for i in set(input1)}
b ={i:[] for i in set(a.values())}
for k,v in a.items():
b[v].append(k)
for v in b.values():
v.sort(reverse=True)
output=[]
quays =list(b.keys())
quays.sort(reverse=True)
for q in quays:
output +=b[q]
print(output)

Stacking XRD plot using multiplot : Discussion on random texts appearing in eps terminal

I wish to plot XRD patterns in a multiplot environment. The XRD patterns are plotted separately and they seem to be fine but the stacked plot shows random texts, symbols at various multiplots. Data file is given below.
# XRD
15 117 182 176 189
15.05 129 207 186 166
15.1 129 213 158 144
15.15 137 156 159 167
15.2 148 191 179 150
15.25 116 202 176 142
15.3 162 206 153 139
15.35 125 184 129 147
15.4 130 180 146 150
15.45 145 212 134 137
15.5 119 193 166 127
15.55 118 195 152 161
15.6 148 201 150 131
15.65 122 188 152 154
15.7 121 172 142 155
15.75 125 163 129 141
15.8 121 180 123 151
15.85 124 170 134 135
15.9 118 197 126 147
15.95 135 185 153 142
16 127 161 154 162
16.05 126 196 155 151
16.1 105 184 146 157
16.15 123 191 133 128
16.2 115 185 128 130
16.25 143 184 140 126
16.3 112 164 178 135
16.35 119 174 123 136
16.4 113 168 130 133
16.45 111 188 123 143
16.5 120 179 109 165
16.55 113 156 131 128
16.6 105 175 153 136
16.65 119 170 114 143
16.7 117 155 151 143
16.75 112 144 141 130
16.8 116 153 142 148
16.85 128 166 121 137
16.9 119 136 124 152
16.95 91 160 111 124
17 95 153 123 125
17.05 119 140 133 133
17.1 112 140 134 127
17.15 114 152 118 129
17.2 123 164 113 139
17.25 106 155 134 120
17.3 114 153 121 120
17.35 100 151 118 142
17.4 105 152 119 152
17.45 86 127 117 133
17.5 105 156 118 129
17.55 90 150 117 143
17.6 94 137 116 117
17.65 104 150 95 118
17.7 102 140 89 129
17.75 99 146 114 128
17.8 123 142 115 126
17.85 93 146 149 128
17.9 90 147 125 135
17.95 86 121 102 136
18 91 123 110 124
18.05 99 117 103 140
18.1 106 125 88 138
18.15 93 124 91 118
18.2 94 138 100 133
18.25 108 108 115 110
18.3 97 122 111 118
18.35 92 132 90 124
18.4 88 130 101 129
18.45 94 120 112 118
18.5 108 124 94 150
18.55 100 118 105 110
18.6 87 136 134 112
18.65 121 107 85 130
18.7 94 131 101 124
18.75 86 134 104 117
18.8 108 138 107 122
18.85 101 133 112 113
18.9 83 112 88 126
18.95 94 107 123 123
19 83 137 110 123
19.05 85 136 102 137
19.1 107 110 82 122
19.15 82 121 92 118
19.2 84 128 114 141
19.25 94 109 103 108
19.3 81 119 102 105
19.35 96 119 95 112
19.4 84 82 86 120
19.45 88 105 97 106
19.5 119 114 91 134
19.55 77 91 102 125
19.6 84 124 108 133
19.65 73 117 92 121
19.7 86 119 104 134
19.75 75 125 84 135
19.8 108 122 80 121
19.85 89 91 91 104
19.9 80 90 105 132
19.95 85 108 78 131
20 88 114 93 129
20.05 92 97 78 142
20.1 96 111 105 120
20.15 88 114 94 115
20.2 84 100 86 121
20.25 100 100 80 132
20.3 94 84 88 147
20.35 84 101 78 111
20.4 78 105 89 112
20.45 81 86 98 129
20.5 86 111 89 127
20.55 92 92 83 120
20.6 85 90 86 121
20.65 74 90 89 141
20.7 83 103 71 141
20.75 74 98 99 114
20.8 87 75 83 149
20.85 67 96 82 154
20.9 85 93 80 174
20.95 83 109 95 157
21 90 97 83 211
21.05 81 105 66 277
21.1 87 94 86 446
21.15 84 97 92 443
21.2 83 101 90 446
21.25 84 100 88 421
21.3 86 107 90 357
21.35 92 97 101 297
21.4 92 112 89 352
21.45 73 108 91 321
21.5 97 130 94 346
21.55 96 128 90 480
21.6 88 121 88 663
21.65 95 107 74 941
21.7 93 95 75 1106
21.75 83 83 67 1078
21.8 91 101 70 966
21.85 91 108 78 815
21.9 76 95 87 792
21.95 85 74 94 629
22 89 86 70 593
22.05 87 81 88 402
22.1 72 73 81 289
22.15 85 90 69 240
22.2 71 94 76 188
22.25 68 74 70 160
22.3 75 96 72 146
22.35 63 82 64 156
22.4 64 77 61 145
22.45 76 84 73 140
22.5 72 98 64 128
22.55 78 73 91 126
22.6 62 95 64 113
22.65 80 74 80 119
22.7 80 85 72 132
22.75 78 80 79 98
22.8 85 72 78 140
22.85 62 88 69 115
22.9 74 94 71 126
22.95 84 91 78 131
23 73 69 79 106
23.05 76 78 66 133
23.1 83 84 79 115
23.15 48 84 77 97
23.2 74 91 62 111
23.25 79 99 58 116
23.3 75 77 53 126
23.35 70 94 67 163
23.4 94 84 70 161
23.45 80 74 69 175
23.5 79 74 65 213
23.55 69 75 67 206
23.6 73 91 72 225
23.65 55 78 81 191
23.7 72 99 68 180
23.75 59 87 81 191
23.8 87 100 69 183
23.85 76 95 76 172
23.9 70 97 74 207
23.95 76 90 75 281
24 74 87 69 359
24.05 76 81 67 443
24.1 89 74 68 472
24.15 79 72 53 429
24.2 84 73 72 345
24.25 72 82 59 313
24.3 69 71 71 300
24.35 74 92 85 283
24.4 72 94 65 245
24.45 85 89 69 186
24.5 65 90 80 156
24.55 85 100 69 102
24.6 68 77 69 116
24.65 71 74 76 121
24.7 70 77 61 119
24.75 70 75 70 118
24.8 75 65 70 115
24.85 73 73 80 124
24.9 79 93 62 98
24.95 76 76 78 104
25 78 75 55 95
25.05 68 77 66 107
25.1 67 82 71 83
25.15 62 73 74 106
25.2 72 88 56 113
25.25 65 86 65 108
25.3 78 70 71 103
25.35 74 73 63 93
25.4 67 62 90 110
25.45 77 98 74 88
25.5 70 78 60 101
25.55 82 81 54 107
25.6 80 62 65 97
25.65 64 91 64 95
25.7 71 74 71 91
25.75 67 75 58 81
25.8 70 78 74 76
25.85 73 95 62 94
25.9 80 78 67 96
25.95 69 86 66 88
26 61 71 71 102
26.05 82 72 63 95
26.1 86 75 57 106
26.15 83 80 62 84
26.2 88 74 65 85
26.25 68 76 60 104
26.3 78 70 58 92
26.35 66 74 70 107
26.4 71 68 60 93
26.45 69 81 77 105
26.5 61 74 79 81
26.55 73 81 60 82
26.6 74 79 56 84
26.65 83 97 81 97
26.7 72 78 64 92
26.75 82 79 66 104
26.8 84 77 49 85
26.85 72 79 58 95
26.9 68 77 70 89
26.95 72 82 62 82
27 63 75 68 83
27.05 66 74 66 82
27.1 68 78 48 102
27.15 65 85 52 93
27.2 75 71 64 78
27.25 72 80 83 79
27.3 66 84 57 92
27.35 58 83 56 82
27.4 67 67 51 82
27.45 73 91 54 83
27.5 74 82 67 89
27.55 84 87 68 79
27.6 80 79 73 101
27.65 82 58 70 100
27.7 70 85 62 96
27.75 71 65 76 85
27.8 70 73 68 71
27.85 76 81 55 89
27.9 73 65 58 91
27.95 85 75 65 95
28 82 77 64 79
28.05 75 89 64 74
28.1 70 85 60 88
28.15 85 73 55 96
28.2 80 94 71 86
28.25 96 84 94 114
28.3 126 101 99 130
28.35 173 172 136 133
28.4 219 257 164 189
28.45 270 213 188 258
28.5 214 230 153 232
28.55 158 139 127 192
28.6 105 110 80 171
28.65 78 84 75 122
28.7 75 72 56 112
28.75 82 79 66 97
28.8 83 69 66 97
28.85 74 63 79 81
28.9 79 65 64 93
28.95 77 80 71 77
29 61 55 62 89
29.05 75 71 64 93
29.1 75 81 69 91
29.15 65 93 78 90
29.2 69 75 63 80
29.25 79 86 60 74
29.3 68 89 64 80
29.35 78 73 78 83
29.4 74 73 66 78
29.45 57 88 72 92
29.5 75 63 79 99
29.55 65 70 79 73
29.6 69 87 69 103
29.65 83 75 48 86
29.7 72 72 59 92
29.75 69 60 68 77
29.8 65 66 58 93
29.85 68 82 74 89
29.9 89 76 75 78
29.95 79 69 73 100
30 84 76 73 108
30.05 110 86 84 101
30.1 129 129 102 124
30.15 146 140 114 154
30.2 150 159 127 186
30.25 136 152 124 157
30.3 117 101 88 169
30.35 81 94 77 125
30.4 72 76 77 120
30.45 85 86 69 116
30.5 75 96 78 91
30.55 71 66 61 64
30.6 70 76 61 92
30.65 72 65 74 97
30.7 87 78 53 84
30.75 67 59 64 92
30.8 71 71 81 82
30.85 75 74 72 79
30.9 80 89 81 56
30.95 76 68 67 87
31 78 68 62 80
31.05 72 72 69 65
31.1 66 69 61 82
31.15 85 72 64 80
31.2 61 67 72 75
31.25 62 73 70 79
31.3 69 60 64 73
31.35 75 74 59 77
31.4 51 69 58 76
31.45 48 59 58 75
31.5 55 73 71 76
31.55 77 77 67 64
31.6 66 66 64 90
31.65 84 74 74 81
31.7 64 71 78 88
31.75 69 79 64 85
31.8 74 79 56 65
31.85 53 67 72 72
31.9 77 57 55 68
31.95 68 66 72 89
32 74 74 80 80
32.05 53 82 61 77
32.1 67 63 66 74
32.15 61 72 67 77
32.2 68 56 66 75
32.25 77 74 48 87
32.3 62 71 60 75
32.35 57 38 63 79
32.4 62 62 78 72
32.45 62 59 70 73
32.5 62 69 63 70
32.55 66 71 56 75
32.6 56 66 65 70
32.65 55 71 52 80
32.7 62 69 62 79
32.75 61 75 68 75
32.8 67 76 66 66
32.85 74 66 63 71
32.9 49 87 78 83
32.95 66 64 71 65
33 82 75 74 86
33.05 57 50 74 88
33.1 59 68 60 77
33.15 61 73 66 77
33.2 62 62 82 70
33.25 74 67 62 85
33.3 60 71 76 72
33.35 72 63 52 70
33.4 66 56 66 77
33.45 71 64 55 74
33.5 58 61 42 66
33.55 66 58 52 79
33.6 59 53 52 69
33.65 66 60 46 76
33.7 53 73 51 84
33.75 70 65 66 71
33.8 52 52 49 73
33.85 66 66 86 74
33.9 58 78 62 82
33.95 65 65 63 87
34 47 53 62 75
34.05 51 63 60 80
34.1 56 77 53 74
34.15 55 53 64 69
34.2 77 49 53 63
34.25 70 82 61 86
34.3 64 69 52 52
34.35 59 67 51 73
34.4 62 77 70 71
34.45 51 58 73 65
34.5 62 78 65 55
34.55 48 69 66 74
34.6 45 70 52 66
34.65 59 72 68 77
34.7 65 62 56 69
34.75 64 68 58 64
34.8 83 73 78 75
34.85 75 112 74 88
34.9 125 136 92 95
34.95 149 139 104 120
35 152 129 103 125
35.05 120 142 97 140
35.1 84 104 80 104
35.15 76 66 76 94
35.2 70 84 70 99
35.25 63 67 60 74
35.3 68 60 62 88
35.35 51 70 52 78
35.4 64 57 62 63
35.45 62 56 43 66
35.5 58 71 63 62
35.55 63 66 57 80
35.6 67 53 57 63
35.65 68 56 59 61
35.7 62 49 46 67
35.75 58 55 66 82
35.8 59 49 49 63
35.85 48 70 57 73
35.9 53 45 47 58
35.95 55 64 43 72
36 54 52 46 71
36.05 56 68 51 74
36.1 49 59 62 96
36.15 53 56 49 93
36.2 66 57 59 92
36.25 60 60 49 99
36.3 63 62 52 113
36.35 61 59 57 102
36.4 48 61 51 107
36.45 67 53 45 81
36.5 61 59 65 84
36.55 50 62 42 101
36.6 48 57 51 72
36.65 46 67 59 66
36.7 70 63 54 86
36.75 54 61 55 61
36.8 62 63 40 61
36.85 62 52 60 51
36.9 45 69 43 77
36.95 56 59 45 71
37 44 73 50 72
37.05 59 58 53 64
37.1 58 42 42 48
37.15 53 52 53 57
37.2 49 64 51 52
37.25 49 54 45 54
37.3 54 56 56 62
37.35 51 50 64 64
37.4 48 68 44 67
37.45 49 58 46 61
37.5 56 45 63 64
37.55 47 51 37 55
37.6 53 60 51 79
37.65 50 46 45 69
37.7 47 45 44 60
37.75 48 45 53 68
37.8 64 60 46 65
37.85 61 45 41 71
37.9 56 57 45 66
37.95 44 54 55 70
38 44 43 51 72
38.05 43 52 48 73
38.1 45 52 46 48
38.15 51 57 34 66
38.2 61 59 50 70
38.25 48 57 53 65
38.3 39 51 46 62
38.35 58 48 43 58
38.4 50 57 45 71
38.45 56 57 55 70
38.5 49 54 45 59
38.55 54 49 65 85
38.6 47 47 48 60
38.65 47 49 65 78
38.7 46 45 54 73
38.75 49 55 56 78
38.8 43 50 51 64
38.85 50 51 46 79
38.9 51 51 45 75
38.95 60 44 50 56
39 69 51 64 60
39.05 46 49 46 61
39.1 68 47 42 78
39.15 44 61 44 79
39.2 42 39 46 66
39.25 46 48 45 72
39.3 52 55 48 75
39.35 43 62 44 65
39.4 46 55 47 60
39.45 52 55 48 78
39.5 57 49 50 68
39.55 46 58 54 68
39.6 48 51 41 80
39.65 47 53 53 81
39.7 51 48 43 78
39.75 61 57 51 78
39.8 48 55 45 83
39.85 53 43 64 80
39.9 59 52 55 77
39.95 46 47 46 69
40 53 57 38 83
40.05 51 48 51 79
40.1 49 50 47 66
40.15 56 40 48 71
40.2 49 62 51 91
40.25 50 65 52 91
40.3 52 72 56 87
40.35 58 61 64 109
40.4 62 63 95 83
40.45 99 89 84 105
40.5 119 127 112 112
40.55 161 160 161 185
40.6 135 183 185 206
40.65 163 176 168 220
40.7 130 158 136 213
40.75 105 119 107 190
40.8 80 80 57 168
40.85 68 67 66 125
40.9 53 71 42 110
40.95 55 65 48 100
41 53 48 58 91
41.05 54 53 52 83
41.1 59 50 53 73
41.15 56 56 59 71
41.2 53 57 56 72
41.25 52 49 50 69
41.3 46 51 46 65
41.35 47 56 45 73
41.4 44 46 60 75
41.45 57 56 55 69
41.5 49 47 31 72
41.55 48 45 50 74
41.6 42 54 50 83
41.65 45 59 56 76
41.7 46 44 39 76
41.75 48 53 47 69
41.8 44 62 51 56
41.85 51 51 44 74
41.9 45 57 38 85
41.95 54 44 39 81
42 44 61 46 72
42.05 46 52 41 72
42.1 43 53 35 90
42.15 53 50 50 73
42.2 50 49 58 88
42.25 38 41 55 82
42.3 42 51 46 61
42.35 51 33 42 77
42.4 51 51 59 59
42.45 42 35 46 80
42.5 36 45 44 80
42.55 36 39 47 76
42.6 53 46 66 76
42.65 44 45 50 79
42.7 38 41 43 76
42.75 45 34 31 63
42.8 55 58 50 84
42.85 33 46 42 78
42.9 50 46 43 70
42.95 58 55 58 66
43 48 48 52 72
43.05 46 61 65 81
43.1 51 47 41 77
43.15 44 57 40 74
43.2 58 63 41 80
43.25 47 47 45 73
43.3 47 38 47 79
43.35 59 43 49 70
43.4 42 53 33 78
43.45 50 43 43 59
43.5 50 51 67 62
43.55 45 45 52 89
43.6 48 48 57 74
43.65 51 57 38 62
43.7 38 37 42 84
43.75 51 63 47 80
43.8 57 44 50 93
43.85 49 50 45 93
43.9 59 54 37 93
43.95 40 48 34 77
44 41 63 39 87
44.05 39 50 56 75
44.1 37 49 53 90
44.15 43 49 48 59
44.2 43 59 52 60
44.25 52 60 41 78
44.3 50 44 52 71
44.35 46 47 49 70
44.4 41 44 37 65
44.45 48 45 47 55
44.5 44 46 44 78
44.55 40 42 33 76
44.6 47 58 40 64
44.65 39 49 51 64
44.7 49 48 42 74
44.75 49 62 47 65
44.8 44 48 49 61
44.85 38 53 46 73
44.9 44 41 37 59
44.95 53 47 32 60
45 46 39 44 62
45.05 51 52 32 62
45.1 31 42 49 63
45.15 38 49 41 66
45.2 51 57 46 63
45.25 42 46 38 60
45.3 47 53 46 59
45.35 46 49 45 64
45.4 37 59 45 61
45.45 66 40 46 62
45.5 53 53 45 67
45.55 40 52 36 63
45.6 45 56 48 62
45.65 39 49 42 62
45.7 47 39 45 71
45.75 39 41 54 58
45.8 45 52 42 66
45.85 38 50 38 57
45.9 48 55 43 56
45.95 42 55 45 52
46 35 49 30 59
46.05 46 57 53 58
46.1 45 41 37 60
46.15 34 39 44 55
46.2 55 45 44 65
46.25 39 53 39 63
46.3 35 52 53 61
46.35 50 38 43 55
46.4 32 47 27 67
46.45 49 45 53 49
46.5 50 49 50 59
46.55 36 56 42 70
46.6 46 44 49 54
46.65 51 56 42 64
46.7 41 50 37 63
46.75 41 54 45 55
46.8 53 43 49 51
46.85 54 51 55 54
46.9 50 55 22 64
46.95 43 51 35 58
47 44 47 39 57
47.05 61 57 31 60
47.1 36 43 35 61
47.15 43 42 49 77
47.2 48 49 48 59
47.25 38 41 47 71
47.3 46 49 39 70
47.35 48 59 36 66
47.4 51 40 30 47
47.45 42 42 39 72
47.5 51 55 43 65
47.55 37 36 44 64
47.6 40 49 51 64
47.65 49 41 40 48
47.7 33 41 50 60
47.75 36 46 44 60
47.8 41 51 50 64
47.85 49 48 54 76
47.9 39 39 45 64
47.95 42 53 50 52
48 58 58 38 41
48.05 51 37 51 60
48.1 43 40 51 76
48.15 48 46 50 51
48.2 46 49 42 55
48.25 34 58 37 45
48.3 44 49 26 66
48.35 39 63 54 68
48.4 44 48 47 61
48.45 46 48 46 61
48.5 35 49 36 63
48.55 35 46 39 61
48.6 51 48 44 55
48.65 43 61 53 52
48.7 45 61 50 51
48.75 54 38 45 53
48.8 48 59 52 69
48.85 41 60 50 68
48.9 49 50 41 54
48.95 52 52 49 62
49 36 51 42 59
49.05 42 58 48 57
49.1 38 43 41 44
49.15 44 57 51 56
49.2 44 46 45 71
49.25 38 57 41 58
49.3 49 57 28 69
49.35 54 39 44 63
49.4 52 54 52 50
49.45 39 56 45 59
49.5 41 51 58 58
49.55 66 58 63 57
49.6 51 44 58 76
49.65 38 51 50 54
49.7 34 60 52 55
49.75 52 51 51 47
49.8 46 51 53 53
49.85 60 55 52 51
49.9 47 47 55 54
49.95 45 54 39 57
50 68 73 58 55
50.05 66 86 50 70
50.1 68 87 79 78
50.15 89 98 114 75
50.2 133 156 143 105
50.25 137 152 160 169
50.3 125 162 185 162
50.35 124 141 121 132
50.4 103 113 105 127
50.45 88 78 77 118
50.5 72 74 66 72
50.55 59 65 54 60
50.6 56 57 55 62
50.65 46 46 56 58
50.7 39 53 45 57
50.75 51 57 57 53
50.8 27 58 41 52
50.85 45 53 34 62
50.9 41 54 60 50
50.95 43 55 40 47
51 51 49 52 68
51.05 49 51 47 51
51.1 45 64 54 51
51.15 38 48 52 51
51.2 48 43 48 50
51.25 43 57 37 59
51.3 42 40 54 55
51.35 44 39 63 57
51.4 45 50 41 46
51.45 49 44 58 52
51.5 40 51 56 57
51.55 43 40 56 59
51.6 37 42 42 72
51.65 50 47 53 47
51.7 47 43 48 61
51.75 37 57 44 60
51.8 39 59 46 65
51.85 43 62 42 70
51.9 42 47 41 60
51.95 40 51 41 65
52 45 45 64 56
52.05 34 44 58 61
52.1 32 43 70 62
52.15 43 49 58 62
52.2 37 50 47 66
52.25 47 52 43 82
52.3 62 42 58 62
52.35 36 49 54 62
52.4 45 44 41 67
52.45 36 48 37 68
52.5 37 48 52 65
52.55 38 46 50 63
52.6 37 47 59 62
52.65 35 43 45 56
52.7 38 52 49 69
52.75 47 47 47 66
52.8 40 38 47 67
52.85 50 54 47 62
52.9 50 50 38 56
52.95 44 40 54 59
53 44 58 30 63
53.05 35 56 54 53
53.1 46 43 48 43
53.15 43 49 52 57
53.2 40 40 40 56
53.25 57 47 47 63
53.3 29 45 38 57
53.35 39 49 56 63
53.4 39 38 50 66
53.45 43 44 48 64
53.5 51 52 43 65
53.55 44 61 42 51
53.6 53 59 45 63
53.65 40 57 50 62
53.7 41 56 47 50
53.75 59 23 47 66
53.8 46 47 35 57
53.85 46 42 47 67
53.9 57 60 42 53
53.95 52 43 50 62
54 48 52 44 60
54.05 50 50 31 57
54.1 40 50 54 55
54.15 42 45 43 38
54.2 46 52 47 59
54.25 48 45 40 54
54.3 47 42 44 49
54.35 42 45 47 53
54.4 49 48 47 55
54.45 43 42 48 54
54.5 43 50 49 54
54.55 54 45 41 57
54.6 44 53 42 59
54.65 40 47 41 45
54.7 45 35 49 58
54.75 34 37 47 52
54.8 42 53 45 48
54.85 40 58 41 56
54.9 34 50 47 51
54.95 43 42 37 53
55 51 51 59 63
55.05 56 55 48 55
55.1 42 37 42 39
55.15 37 48 39 67
55.2 41 52 41 61
55.25 49 52 47 61
55.3 53 39 40 71
55.35 46 51 40 61
55.4 47 51 44 53
55.45 39 43 34 57
55.5 43 49 54 57
55.55 43 40 40 58
55.6 41 37 56 57
55.65 38 50 41 56
55.7 36 51 35 56
55.75 55 47 43 62
55.8 45 51 45 59
55.85 37 56 40 45
55.9 47 47 45 54
55.95 50 36 44 44
56 46 44 54 52
56.05 51 47 43 58
56.1 51 48 45 53
56.15 56 42 32 65
56.2 31 43 46 63
56.25 44 53 47 47
56.3 41 35 35 54
56.35 45 49 43 55
56.4 45 47 34 54
56.45 49 44 40 56
56.5 45 45 49 59
56.55 60 61 59 65
56.6 30 52 53 50
56.65 38 51 46 57
56.7 51 54 53 39
56.75 54 54 46 36
56.8 45 39 51 63
56.85 38 55 45 57
56.9 40 57 43 56
56.95 41 38 45 58
57 36 42 37 69
57.05 35 60 45 49
57.1 45 47 38 48
57.15 41 39 46 47
57.2 49 51 42 67
57.25 36 42 29 51
57.3 38 40 29 52
57.35 43 47 45 53
57.4 43 62 32 57
57.45 41 41 45 69
57.5 42 54 39 53
57.55 42 52 30 65
57.6 41 40 47 71
57.65 39 42 45 49
57.7 37 52 53 56
57.75 48 58 38 44
57.8 42 54 51 53
57.85 56 47 35 47
57.9 45 41 30 46
57.95 39 44 54 59
58 51 32 40 53
58.05 40 39 41 60
58.1 47 47 33 41
58.15 39 46 40 59
58.2 46 51 51 41
58.25 37 52 48 58
58.3 41 37 45 49
58.35 36 48 43 44
58.4 50 44 45 54
58.45 42 45 44 41
58.5 58 56 47 58
58.55 36 51 48 52
58.6 59 54 57 74
58.65 57 63 60 72
58.7 57 75 65 68
58.75 68 74 81 79
58.8 61 60 53 77
58.85 68 74 62 94
58.9 58 67 53 67
58.95 54 44 42 67
59 53 39 42 71
59.05 59 47 39 63
59.1 48 38 45 55
59.15 49 48 57 49
59.2 42 52 49 46
59.25 49 41 45 54
59.3 45 52 41 46
59.35 38 48 50 47
59.4 44 50 38 51
59.45 54 55 61 57
59.5 37 49 54 59
59.55 52 66 62 61
59.6 62 65 54 57
59.65 70 87 82 79
59.7 73 97 82 74
59.75 88 87 79 84
59.8 69 97 61 83
59.85 62 71 67 67
59.9 60 55 72 78
59.95 51 56 44 60
60 59 59 52 51
60.05 51 48 57 48
60.1 45 54 48 55
60.15 45 49 38 53
60.2 39 45 45 50
60.25 55 43 39 60
60.3 48 40 38 52
60.35 45 40 55 51
60.4 34 44 35 59
60.45 47 38 39 49
60.5 32 48 53 44
60.55 40 41 51 36
60.6 40 44 36 55
60.65 54 44 55 55
60.7 35 46 29 49
60.75 50 47 37 46
60.8 40 45 40 68
60.85 34 51 54 48
60.9 39 40 63 50
60.95 31 58 39 46
61 27 46 37 43
61.05 45 55 47 46
61.1 47 42 52 48
61.15 41 45 42 60
61.2 34 43 49 47
61.25 46 40 47 57
61.3 42 43 35 51
61.35 33 46 37 62
61.4 45 39 54 50
61.45 41 54 58 56
61.5 31 48 57 49
61.55 42 44 47 49
61.6 40 52 37 52
61.65 32 48 42 76
61.7 35 36 48 59
61.75 33 51 28 46
61.8 45 47 42 50
61.85 48 48 40 55
61.9 50 37 40 41
61.95 44 50 39 41
62 36 31 48 51
62.05 34 51 38 28
62.1 44 48 40 48
62.15 47 43 43 52
62.2 40 45 40 58
62.25 42 40 47 60
62.3 50 35 44 51
62.35 51 57 41 56
62.4 43 58 52 70
62.45 46 51 55 38
62.5 59 64 58 65
62.55 50 52 47 53
62.6 56 72 62 61
62.65 63 57 57 68
62.7 67 68 55 83
62.75 54 72 60 61
62.8 61 57 54 67
62.85 54 53 53 55
62.9 43 50 49 66
62.95 44 55 50 49
63 36 55 45 63
63.05 49 53 46 47
63.1 41 40 42 51
63.15 46 41 47 40
63.2 44 33 51 58
63.25 36 45 43 46
63.3 34 49 46 58
63.35 36 42 40 46
63.4 58 62 37 57
63.45 42 51 40 58
63.5 40 54 36 40
63.55 48 52 51 46
63.6 43 39 41 46
63.65 35 50 51 46
63.7 36 39 42 47
63.75 42 51 36 52
63.8 41 43 54 52
63.85 40 53 42 37
63.9 39 51 51 63
63.95 40 59 42 66
64 32 44 32 43
64.05 46 57 39 53
64.1 44 42 38 68
64.15 41 44 57 51
64.2 44 41 41 50
64.25 35 40 30 61
64.3 45 51 36 41
64.35 46 52 44 42
64.4 37 47 44 51
64.45 43 52 46 41
64.5 36 35 47 63
64.55 40 61 41 59
64.6 36 40 40 49
64.65 45 38 53 58
64.7 38 41 44 50
64.75 42 49 44 43
64.8 37 53 42 41
64.85 39 47 42 55
64.9 50 42 35 53
64.95 40 41 43 45
65 28 43 48 46
65.05 34 38 39 42
65.1 41 44 44 45
65.15 42 54 43 49
65.2 40 38 46 33
65.25 45 45 44 54
65.3 34 46 33 48
65.35 44 41 29 32
65.4 49 41 55 46
65.45 49 45 43 58
65.5 46 40 38 56
65.55 36 44 51 50
65.6 40 48 44 45
65.65 51 32 44 38
65.7 30 35 29 42
65.75 48 60 42 64
65.8 34 55 38 44
65.85 52 43 48 56
65.9 32 47 46 56
65.95 43 60 47 50
66 41 44 40 47
66.05 42 51 34 56
66.1 61 49 44 53
66.15 57 57 45 42
66.2 55 52 50 59
66.25 44 50 42 53
66.3 63 83 63 62
66.35 78 75 85 89
66.4 80 103 120 69
66.45 77 103 96 81
66.5 98 112 114 111
66.55 86 76 85 103
66.6 81 99 80 80
66.65 61 95 64 78
66.7 62 69 65 87
66.75 59 66 50 70
66.8 54 51 44 62
66.85 50 56 38 70
66.9 52 61 45 60
66.95 32 42 46 60
67 35 46 51 57
67.05 39 47 40 46
67.1 47 45 45 52
67.15 39 40 39 53
67.2 51 43 37 46
67.25 53 46 44 53
67.3 35 52 45 48
67.35 41 44 42 50
67.4 38 55 25 49
67.45 25 46 40 45
67.5 48 51 45 54
67.55 41 47 41 46
67.6 37 50 38 44
67.65 45 48 45 53
67.7 37 44 39 51
67.75 29 42 61 66
67.8 32 52 45 51
67.85 28 52 46 48
67.9 31 54 35 58
67.95 41 48 46 45
68 33 37 39 45
68.05 44 36 35 52
68.1 48 41 46 52
68.15 39 55 41 64
68.2 46 51 46 47
68.25 49 31 49 50
68.3 39 53 36 47
68.35 40 41 38 48
68.4 50 61 60 44
68.45 40 31 39 55
68.5 54 37 41 33
68.55 44 43 46 51
68.6 35 48 51 54
68.65 31 51 37 55
68.7 46 40 47 52
68.75 28 58 40 44
68.8 38 52 41 56
68.85 29 50 37 50
68.9 34 47 44 46
68.95 43 45 45 53
69 49 42 42 50
69.05 37 51 61 35
69.1 43 41 54 42
69.15 44 40 48 59
69.2 31 35 41 49
69.25 33 49 35 56
69.3 43 52 49 46
69.35 47 56 44 34
69.4 42 47 29 51
69.45 39 51 46 41
69.5 37 36 30 51
69.55 35 42 50 35
69.6 42 47 40 43
69.65 44 45 40 46
69.7 37 48 31 41
69.75 53 47 34 50
69.8 24 49 41 41
69.85 35 33 49 40
69.9 41 32 34 53
69.95 34 37 33 49
70 42 31 29 39
70.05 37 35 35 38
70.1 22 47 31 49
70.15 47 47 37 40
70.2 35 47 42 50
70.25 31 31 34 39
70.3 52 38 35 46
70.35 37 54 38 49
70.4 41 45 41 43
70.45 40 34 37 49
70.5 47 42 41 48
70.55 44 49 42 41
70.6 39 49 50 46
70.65 47 39 35 54
70.7 30 49 34 51
70.75 39 52 40 43
70.8 41 40 32 41
70.85 36 37 32 40
70.9 25 52 45 44
70.95 41 30 47 40
71 33 38 33 58
71.05 35 53 34 34
71.1 32 36 36 53
71.15 35 57 54 45
71.2 38 47 32 39
71.25 45 52 32 59
71.3 45 45 39 43
71.35 57 37 38 42
71.4 41 43 34 49
71.45 30 48 44 48
71.5 28 41 34 45
71.55 34 47 45 42
71.6 42 39 41 43
71.65 41 52 44 57
71.7 32 46 43 51
71.75 25 44 36 48
71.8 43 49 39 45
71.85 45 61 42 41
71.9 33 40 43 57
71.95 34 39 34 42
72 44 42 37 53
72.05 43 44 40 47
72.1 45 38 43 48
72.15 42 37 37 48
72.2 42 41 43 46
72.25 30 36 39 41
72.3 44 40 37 47
72.35 47 34 45 49
72.4 36 54 33 52
72.45 45 42 42 37
72.5 40 38 36 37
72.55 45 54 45 56
72.6 33 55 37 57
72.65 39 47 27 41
72.7 47 39 40 52
72.75 39 30 45 41
72.8 40 39 30 45
72.85 34 56 46 52
72.9 39 39 43 42
72.95 30 48 32 55
73 31 39 27 49
73.05 37 42 40 39
73.1 35 39 42 42
73.15 39 41 45 53
73.2 37 46 36 55
73.25 34 44 46 51
73.3 38 48 32 51
73.35 41 38 48 44
73.4 34 44 36 38
73.45 50 50 45 63
73.5 46 48 49 63
73.55 44 55 54 63
73.6 54 79 45 60
73.65 57 71 77 66
73.7 81 95 79 66
73.75 71 104 103 102
73.8 83 89 78 84
73.85 80 96 77 99
73.9 70 72 64 83
73.95 50 85 66 89
74 61 71 59 78
74.05 39 76 62 79
74.1 58 58 50 71
74.15 46 52 39 66
74.2 33 48 42 72
74.25 40 55 46 59
74.3 41 41 42 47
74.35 38 46 40 44
74.4 48 40 38 39
74.45 49 48 51 44
74.5 46 44 45 52
74.55 39 44 44 61
74.6 46 42 40 48
74.65 43 39 48 44
74.7 31 44 37 52
74.75 37 53 36 56
74.8 32 49 38 58
74.85 32 42 33 39
74.9 44 43 43 39
74.95 34 49 40 46
75 29 45 37 55
75.05 31 43 35 39
75.1 33 46 36 42
75.15 52 28 43 44
75.2 32 49 41 54
75.25 29 38 41 43
75.3 29 39 41 51
75.35 36 44 34 48
75.4 28 49 40 43
75.45 28 43 42 45
75.5 45 40 38 49
75.55 25 53 35 49
75.6 30 51 35 42
75.65 26 47 45 46
75.7 32 46 44 47
75.75 32 44 33 49
75.8 44 50 35 63
75.85 40 44 39 42
75.9 30 41 44 45
75.95 34 48 34 58
76 44 49 36 60
76.05 41 57 37 50
76.1 46 41 39 49
76.15 30 39 32 49
76.2 39 34 34 70
76.25 38 49 34 43
76.3 43 33 33 42
76.35 30 50 39 55
76.4 47 55 33 44
76.45 31 33 37 46
76.5 34 40 37 35
76.55 36 47 34 51
76.6 45 38 50 51
76.65 36 41 34 41
76.7 32 40 36 46
76.75 30 41 44 38
76.8 34 52 43 43
76.85 37 37 36 51
76.9 37 51 43 48
76.95 41 46 40 52
77 37 54 33 54
77.05 30 44 55 44
77.1 40 46 42 49
77.15 47 40 41 40
77.2 34 44 30 60
77.25 44 52 45 49
77.3 35 48 36 36
77.35 41 35 33 47
77.4 33 43 34 51
77.45 36 42 48 56
77.5 29 36 37 53
77.55 38 47 36 51
77.6 32 37 48 41
77.65 45 49 33 56
77.7 34 42 39 43
77.75 29 45 51 51
77.8 36 43 36 41
77.85 33 43 35 46
77.9 35 46 37 50
77.95 34 39 46 40
78 40 35 36 43
78.05 43 37 44 54
78.1 33 55 43 49
78.15 35 42 27 41
78.2 40 51 46 38
78.25 43 47 41 36
78.3 38 32 37 31
78.35 38 44 44 56
78.4 43 33 41 50
78.45 40 45 37 41
78.5 42 35 32 36
78.55 38 39 38 43
78.6 34 48 43 39
78.65 34 33 36 58
78.7 40 28 36 43
78.75 37 59 41 60
78.8 37 47 51 46
78.85 39 30 39 47
78.9 47 46 41 42
78.95 40 42 34 52
79 35 35 40 33
79.05 34 40 42 42
79.1 40 40 49 49
79.15 39 48 39 52
79.2 33 30 41 43
79.25 38 40 50 60
79.3 32 44 34 46
79.35 48 48 26 47
79.4 39 34 45 48
79.45 35 51 39 51
79.5 37 39 32 36
79.55 32 45 38 46
79.6 40 57 37 51
79.65 36 45 44 46
79.7 40 30 53 50
79.75 40 46 33 45
79.8 26 37 44 54
79.85 39 38 30 58
79.9 49 37 35 47
79.95 36 30 31 43
80 43 38 41 45
My code is as given below
set terminal postscript eps enhanced colour font 'Times-Roman,12' size 5in,8in
set output "XRD_P3.eps"
##
set style line 1 lt 1 lw 1 lc rgb "black"
set xtics out scale 1.5
set ytics out scale 1.5
set format y ''
set tics font ",16"
set xlabel "2{/Symbol \161} (deg.)" font ",16"
set ylabel "Intensity (a.u.)" font ",16"
set key inside right top
set multiplot layout 4,1 rowsfirst
##
set yrange [0:1500]
set key title "LiCl-KCl + 6 wt.% H_{2}O" font ",14"
##
set label 1 '(111)' font ",12" at 24.10, 482 point pt 7 ps 1.75 lt rgb "red" offset -0.50, 0.50 rotate by 90
set label 2 '(200)' font ",12" at 28.45, 268 point pt 7 ps 1.75 lt rgb "red" offset -0.50,0.50 rotate by 90
set label 3 '(220)' font ",12" at 40.65, 230 point pt 7 ps 1.75 lt rgb "red" offset -0.50,0.50 rotate by 90
set label 4 '(400)' font ",12" at 58.85, 104 point pt 7 ps 1.75 lt rgb "red" offset -1.00,0.50 rotate by 90
set label 5 '(420)' font ",12" at 66.50, 121 point pt 7 ps 1.75 lt rgb "red" offset -0.50,0.50 rotate by 90
##
set label 6 '(111)' font ",12" at 30.20, 196 point pt 7 ps 1.75 lt rgb "blue" offset -0.50,0.50 rotate by 90
set label 7 '(200)' font ",12" at 35.05, 150 point pt 7 ps 1.75 lt rgb "blue" offset -0.50,0.50 rotate by 90
set label 8 '(220)' font ",12" at 50.25, 179 point pt 7 ps 1.75 lt rgb "blue" offset -0.50,0.50 rotate by 90
set label 9 '(311)' font ",12" at 59.75, 94 point pt 7 ps 1.75 lt rgb "blue" offset -0.50,0.50 rotate by 90
set label 11 '(400)' font ",12" at 73.75, 112 point pt 7 ps 1.75 lt rgb "blue" offset -0.50,0.50 rotate by 90
##
set label 12 '(101)' font ",12" at 21.70, 1116 point pt 7 ps 1.75 lt rgb "#006400" offset -0.50,0.50 rotate by 90
##
set label 13 'LiCl' font ",14" at 72, 1200 point pt 7 ps 1.75 lt rgb "blue" offset 2,-0.10
set label 14 'KCl' font ",14" at 72, 1100 point pt 7 ps 1.75 lt rgb "red" offset 2,-0.10
set label 15 'LiClO_{4}' font ",14" at 72, 1000 point pt 7 ps 1.75 lt rgb "#006400" offset 2,-0.10
##
plot [10:80] 'XRD_P3.dat' u 1:5 w l ls 1 notitle
##
##
set yrange [0:300]
set key title "LiCl-KCl (Vacuum dried)" font ",14"
##
set label 1 '(222)' font ",12" at 50.30, 195 point pt 7 ps 1.75 lt rgb "red" offset -0.50, 0.50 rotate by 90
set label 2 '(200)' font ",12" at 28.45, 198 point pt 7 ps 1.75 lt rgb "red" offset -0.50,0.50 rotate by 90
set label 3 '(220)' font ",12" at 40.60, 195 point pt 7 ps 1.75 lt rgb "red" offset -0.50,0.50 rotate by 90
set label 4 '(400)' font ",12" at 58.75, 91 point pt 7 ps 1.75 lt rgb "red" offset -1.00,0.50 rotate by 90
set label 5 '(420)' font ",12" at 66.40, 130 point pt 7 ps 1.75 lt rgb "red" offset -0.50,0.50 rotate by 90
##
set label 6 '(111)' font ",12" at 30.20, 137 point pt 7 ps 1.75 lt rgb "blue" offset -0.50,0.50 rotate by 90
set label 7 '(200)' font ",12" at 34.95, 114 point pt 7 ps 1.75 lt rgb "blue" offset -0.50,0.50 rotate by 90
set label 9 '(311)' font ",12" at 59.65, 92 point pt 7 ps 1.75 lt rgb "blue" offset -0.50,0.50 rotate by 90
set label 10 '(222)' font ",12" at 62.75, 70 point pt 7 ps 1.75 lt rgb "blue" offset -0.50,0.50 rotate by 90
set label 11 '(400)' font ",12" at 73.75, 113 point pt 7 ps 1.75 lt rgb "blue" offset -0.50,0.50 rotate by 90
##
set label 12 'LiCl' font ",14" at 72, 250 point pt 7 ps 1.75 lt rgb "blue" offset 2,-0.10
set label 13 'KCl' font ",14" at 72, 220 point pt 7 ps 1.75 lt rgb "red" offset 2,-0.10
##
plot [10:80] 'XRD_P3.dat' u 1:4 w l ls 1 notitle
##
##
set yrange [0:350]
set key title "LiCl-KCl (Chlorinated)" font ",14"
##
set label 2 '(200)' font ",12" at 28.40, 267 point pt 7 ps 1.75 lt rgb "red" offset -0.50,0.50 rotate by 90
set label 3 '(220)' font ",12" at 40.60, 193 point pt 7 ps 1.75 lt rgb "red" offset -0.50,0.50 rotate by 90
set label 4 '(400)' font ",12" at 58.70, 85 point pt 7 ps 1.75 lt rgb "red" offset -1.00,0.50 rotate by 90
set label 5 '(420)' font ",12" at 66.50, 122 point pt 7 ps 1.75 lt rgb "red" offset -0.50,0.50 rotate by 90
##
set label 6 '(111)' font ",12" at 30.20, 169 point pt 7 ps 1.75 lt rgb "blue" offset -0.50,0.50 rotate by 90
set label 7 '(200)' font ",12" at 35.05, 152 point pt 7 ps 1.75 lt rgb "blue" offset -0.50,0.50 rotate by 90
set label 8 '(220)' font ",12" at 50.30, 172 point pt 7 ps 1.75 lt rgb "blue" offset -0.50,0.50 rotate by 90
set label 9 '(311)' font ",12" at 59.80, 107 point pt 7 ps 1.75 lt rgb "blue" offset -0.50,0.50 rotate by 90
set label 10 '(222)' font ",12" at 62.60, 82 point pt 7 ps 1.75 lt rgb "blue" offset -0.50,0.50 rotate by 90
set label 11 '(400)' font ",12" at 73.75, 114 point pt 7 ps 1.75 lt rgb "blue" offset -0.50,0.50 rotate by 90
##
set label 12 'LiCl' font ",14" at 72, 300 point pt 7 ps 1.75 lt rgb "blue" offset 2,-0.10
set label 13 'KCl' font ",14" at 72, 270 point pt 7 ps 1.75 lt rgb "red" offset 2,-0.10
##
plot [10:80] 'XRD_P3.dat' u 1:3 w l ls 1 notitle
##
##
unset multiplot
In the plot, there are random texts appearing outside the XRD patterns, and in some cases the labels are rotated. PNG version of the plot is attached.
The definition of labels persists in a multiplot environment. It's somewhere in the documentation but I haven't found it right away in help label.
Here is some code to illustrate your "problem".
In the second plot label 4 and label 5 are not defined explicitely, but the definition still exists in memory from the first plot. Hence, label 4 and label 5 will be drawn at the second plot's coordinates 4,4 and 5,5 which are located somewhere in the first plot.
So, either you explicitly unset them unset label 4 and unset label 5 or you unset all labels unset label and newly define all desired labels.
Code:
### setting/unsetting of labels
reset session
set xrange [0:8]
set multiplot layout 2,1
set label 1 at 1,1 "Label1a"
set label 2 at 2,2 "Label2a"
set label 3 at 3,3 "Label3a"
set label 4 at 4,4 "Label4a"
set label 5 at 5,5 "Label5a"
plot x
# unset label # uncomment this line to reset all labels
set label 1 at 1,-1 "Label1b"
set label 2 at 2,-2 "Label2b"
set label 3 at 3,-3 "Label3b"
plot -x
unset multiplot
### end of code
Result:

python truncating inputs from shell to specific number

When I am trying to provide a large input, it is truncating to a specific number.
eg. If I input around 50k-100k inputs(156 repeated number of times), its truncates to 1023. But when I provide input around 200k(shown below), it truncates to 1187.
if __name__ == '__main__':
iplist = list(map(int, input().rstrip().split()))
print("len of exp: ",len(iplist))
1) provide very large input:
eg. below is 1686 numbers input , but if you run the above code, it says length is : 1187:
Seems there is some character limit in shell as if I change a few numbers from 3 digit to 2 digit, or 1 digit, this length increases
0 82 180 55 168 41 179 59 139 71 6 12 135 139 73 157 4 74 195 60 45 28 67 136 58 55 22 60 33 84 48 185 118 29 41 86 22 172 145 114 43 103 126 130 43 152 87 199 26 34 59 24 63 79 160 73 86 134 133 71 18 182 57 89 163 98 175 137 70 73 3 113 176 130 43 19 34 83 170 12 117 30 36 132 61 197 5 99 131 91 171 102 25 28 143 188 126 118 77 148 143 81 61 120 163 56 91 149 91 62 161 161 44 198 93 57 195 51 156 78 142 127 132 119 107 75 59 33 146 136 133 89 169 146 161 84 3 5 33 46 67 195 7 63 193 53 120 140 56 28 170 150 156 103 69 63 178 128 49 124 64 182 166 186 129 79 70 84 84 104 82 103 51 42 166 44 95 38 136 103 67 106 53 175 161 122 190 140 50 39 16 66 174 134 52 55 14 123 91 98 179 173 2 30 15 120 26 62 159 114 165 178 172 18 153 134 140 143 26 142 135 42 9 61 129 61 68 143 136 159 193 67 132 195 49 100 68 27 114 27 141 80 157 66 50 110 0 191 5 26 133 92 20 142 105 149 156 173 44 44 84 38 112 169 185 113 69 53 141 183 32 34 15 189 100 66 51 52 9 57 78 94 101 51 37 159 152 145 132 197 189 17 187 53 138 172 167 159 26 108 142 58 94 110 48 195 176 51 47 137 108 78 31 162 129 20 121 33 165 5 182 107 174 169 112 112 142 79 71 120 139 166 178 34 76 178 181 4 30 28 93 90 58 124 4 139 145 125 173 62 131 155 121 57 125 34 170 19 65 41 139 5 159 69 191 187 0 172 143 182 152 36 24 163 161 29 102 58 154 27 120 37 183 194 95 60 28 17 79 93 10 170 50 170 39 193 157 191 117 101 173 22 89 198 185 50 27 87 108 133 115 181 123 50 175 170 62 155 187 141 0 197 63 3 119 102 196 29 46 66 82 19 88 171 169 73 22 196 112 82 82 179 15 157 181 142 127 43 97 66 136 50 15 199 53 135 54 1 116 100 67 198 119 155 121 89 180 95 37 93 178 71 24 145 28 6 88 107 1 137 173 138 139 141 137 192 28 191 146 144 43 13 94 163 169 15 4 101 111 193 146 41 17 171 138 197 129 178 105 130 116 30 68 7 171 158 152 151 149 98 95 193 111 141 108 32 157 64 134 20 57 80 61 26 3 199 24 132 178 129 63 46 111 83 53 35 41 5 186 143 55 34 88 119 175 148 151 132 12 37 104 21 70 165 48 25 117 72 158 47 153 173 93 16 56 98 51 50 56 38 193 63 24 81 182 199 29 134 84 193 123 188 166 145 106 14 171 23 38 129 22 143 54 67 160 62 165 11 112 173 1 105 37 25 138 19 25 119 105 61 64 181 49 31 126 155 45 97 130 36 178 152 179 32 19 139 47 137 151 159 62 152 17 51 130 107 23 155 27 128 168 91 109 17 74 188 125 120 85 7 108 16 160 87 48 131 27 95 20 130 7 35 34 24 86 164 131 109 71 110 190 39 154 99 9 28 39 134 100 125 93 8 141 5 96 141 137 75 189 109 157 196 144 143 172 31 60 103 92 83 166 82 75 120 134 84 148 173 170 1 98 63 9 191 69 57 133 158 84 74 19 41 70 164 137 42 147 197 97 39 80 63 122 155 135 56 191 36 29 113 37 80 129 46 71 150 56 156 108 140 30 127 134 100 43 71 94 190 68 144 182 100 159 104 8 95 112 151 131 141 65 168 21 146 166 45 96 22 1 156 163 184 35 97 36 79 120 131 21 140 27 3 192 186 59 0 81 171 152 12 113 169 132 86 115 99 83 163 121 37 119 36 21 154 85 57 185 157 140 7 97 167 162 90 154 22 42 35 193 146 0 58 115 84 97 182 183 180 145 57 17 64 45 190 171 83 48 156 40 188 163 138 156 78 180 62 100 22 49 45 169 49 104 36 134 153 171 69 133 116 78 103 133 124 93 104 7 93 12 199 82 128 137 190 6 69 52 106 92 101 151 13 103 7 1 189 160 172 10 46 89 89 101 174 165 194 30 124 40 42 123 74 170 13 64 176 82 68 34 126 169 186 139 24 193 141 13 106 113 24 152 154 65 53 128 182 199 158 106 39 1 181 113 123 194 129 100 29 197 134 155 119 72 95 143 18 188 109 124 101 85 76 8 102 81 136 84 32 47 142 72 0 123 137 123 70 67 175 99 16 110 6 135 134 101 31 152 89 92 76 143 129 104 151 31 185 39 115 170 38 57 42 190 132 131 114 154 150 41 53 167 103 60 54 38 113 37 190 155 81 19 98 10 123 1 41 61 192 108 31 31 117 25 21 50 108 87 4 59 129 10 178 184 22 32 22 135 22 165 42 103 184 92 66 59 93 107 72 86 168 55 69 85 80 42 87 189 130 92 0 11 54 178 195 76 162 170 163 184 135 6 40 119 98 106 130 192 165 3 30 133 58 51 171 91 93 58 32 175 150 32 138 4 162 86 32 124 56 196 61 191 2 53 62 52 111 192 44 76 147 26 162 6 29 133 49 75 191 81 50 94 65 141 50 179 27 83 103 83 31 116 26 185 121 88 37 32 32 34 61 180 12 175 138 42 108 139 117 51 172 119 97 37 12 148 168 39 183 23 74 14 140 100 151 61 140 188 46 125 22 107 57 35 34 147 29 142 86 98 145 58 17 43 47 30 143 15 21 126 38 96 92 130 148 43 144 41 183 190 118 158 49 127 145 83 74 174 177 160 72 74 170 41 117 17 23 60 32 45 138 22 93 182 153 193 177 97 186 161 39 104 119 40 183 64 123 57 38 52 17 62 126 187 103 196 156 79 8 140 76 147 163 169 81 68 114 59 117 101 20 156 157 139 196 141 155 71 150 145 123 168 7 1 107 62 197 16 141 158 156 17 105 119 138 138 187 53 197 56 106 17 12 15 108 160 108 63 31 59 8 106 179 167 60 38 182 9 54 75 167 11 45 24 82 183 163 22 188 160 78 46 178 43 14 38 3 122 54 187 181 14 45 112 182 105 151 116 115 5 191 34 168 36 59 51 172 22 25 112 182 103 111 112 146 125 151 102 199 157 89 133 171 134 45 153 192 196 21 59 154 13 93 74 1 152 125 125 126 150 190 61 6 101 173 104 178 76 6 177 33 95 110 5 182 156 110 174 104 132 185 10 97 78 85 50 183 162 176 109 65 166 170 71 19 96 127 197 124 134 126 110 29 37 67 163 145 129 137 1 61 122 164 110 153 1 161 136 163 89 197 180 7 120 51 26 16 131 175 92 65 101 2 46 90 69 10 187 199 99 141 12 174 57 75 127 58 36 15 21 125 164 2 84 84 5 110 52 136 37 145 153 90 99 0 181 121 10 120 72 61 13 36 35 70 111 114 128 99 81 102 176 46 104 60 130 61 122 135 150 159 32 103 50 83 55 183 4 65 103 28 79 69 65 114 139 128 181 20 28 62 122 4 108 178 17 191 191 139 78 141 99 110 197 149 193 52 132 150 70 187 178 149 56 43 63 148 172 44 168 152 59 42 108 167 172 125 110 163 65 188 105 164 50 54 65 44 106 149 146 176 88 124 125 145 120 141 45 44 137 165 196 196 159 56 116 131 182 178 94 47 167 151 163 169 5 180 165 112 129 111 40 17 36 166 114 108 59 111 152 196 76 100 145 35 156 61 166 90 39 13 89 158 164 4 128 170 184 45 34 65 157 74 35 145 192 149 53 51 13 157 0 41 9 145 29 117 6 195 8 197 160 97 108 125 102 188
Could you please explain this? If this is python/shell issue and how can I overcome it ? I am trying to run a hackerrank test case which is having very large input around 200000. But I am not able to run that testcase in my terminal due to this limitation.
This is indeed a limitation specific to the shell, rather than Python. Just to bring your attention to some things, here is what you can do in the future:
Initial hint - if you paste this and attempt to add characters in a modern shell you see you can't!
paste your input into a file, preferably with one item on a line.
Add a few debug lines
if __name__ == '__main__':
iplist = list(map(int, input().rstrip().split()))
with open('test.dat','w') as fd:
fd.write('\n'.join(str(x) for x in iplist))
print("len of exp: ",len(iplist),iplist[0],iplist[-1])
So now you have a quick reference to the first and last read items in the list, and a file containing the entire read list. Immediately you see the last item is 188 - suspicious.
If you pasted your input into a file in (1) you can easily check line 1187 is indeed 188.
Using the test file above you can count characters in the input actually read using a tool such as wc -c test.dat.
I get 4095, which is suspiciously close to 4096 = 4 KiB (often written as kB)
This is a clear hint for a "system" level limitation, likely your shell, limiting the amount of characters you are allowed to put in a single line. This specific limitation is pretty standard, and you can probably find somewhere the documentation for the limit.
Jack's answer is the way to go here - this is no way to read large input.
You are correct that there is a character limit in shell commands which it looks like you are hitting with that much of data on the command line.
I would refer you to the man page for that but you will not need to know it precisely hopefully ever.
The reason for that is you'll never want to put yourself in this position and to avoid that, all you need to do is save your input to a file, and change your python to open that file and read it line by line. Many examples on SO how to do something like that.
I hope that helps.

Aligning lines in python

I have written a code to print a snake and ladder grid.
I want the numbers to be aligned such that they are in a straight vertical line.
My code is:
for i in range(100,0,-1):
if i%20 == 0:
for i in range(i,i-10,-1):
print(i, end = " ")
print()
elif i%10 == 0:
for i in range(i-9,i+1):
print(i, end = " ")
print()
The present output is:
100 99 98 97 96 95 94 93 92 91
81 82 83 84 85 86 87 88 89 90
80 79 78 77 76 75 74 73 72 71
61 62 63 64 65 66 67 68 69 70
60 59 58 57 56 55 54 53 52 51
41 42 43 44 45 46 47 48 49 50
40 39 38 37 36 35 34 33 32 31
21 22 23 24 25 26 27 28 29 30
20 19 18 17 16 15 14 13 12 11
1 2 3 4 5 6 7 8 9 10
If you're using Python3, try replacing your:
print(i, end = " ")
lines with:
print(format(i, '6d'), end='')
If you must have the numbers left-justified, try this instead:
print('{:<6d}'.format(i), end='')
These will account for the fact that not every number has the same amount of digits, yet you want every number to take up the same amount of space.

Can I format n numbers in Python

How can I print all numbers in a given range to given number of columns, where every colums is of width 6 character and there is a space between colums? I tried to use format:
for i in range(0,nolines):
for j in range(0,nocolums):
print("{0:6}{1:6}".format(number1,number2))
but found that this approach won't work as I need more general code to format n, where n is given by user input, numbers instead of two. So can I print n numbers by using format?
For example, if input is
min = 20, max = 104, numbers on one line = 10
the program should print
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 101 102 103 104
def print_range(start, stop, ncolumns, width=6):
for i in range(start, stop, ncolumns):
print(' '.join(['{:{}d}'.format(j, width)
for j in range(i, min(i + ncolumns, stop))]))
Example:
>>> print_range(20, 105, ncolumns=10)
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 101 102 103 104
You could use the str.rjust method:
lines = [
[1, 2, 3],
[111, 222, 333],
]
for line in lines:
for n in line:
print(str(n).rjust(6), end='')
print()

Resources