imshow在使用自定义刻度时为什么显示不正确?

huangapple go评论98阅读模式
英文:

Why isn't imshow displaying correctly when using custom ticks?

问题

I am trying to plot heatmap with average values with x and y axes denote physical parameters.

  1. import csv
  2. import matplotlib.pyplot as plt
  3. from scipy import stats
  4. import numpy as np
  5. #.......................................................................
  6. # URL for temp.csv https://github.com/paragkan/dyanmic-recrystallization/blob/main/temp.csv
  7. #.......................................................................
  8. def read_csv(xfile):
  9. infile = open(xfile, 'r')
  10. table = []
  11. for row in csv.reader(infile):
  12. table.append(row)
  13. infile.close()
  14. for c in range (0, len(table[0])):
  15. for r in range(0, len(table)):
  16. try:
  17. table[r][c] = float(table[r][c])
  18. except:
  19. pass
  20. return table
  21. #.......................................................................
  22. xfile = 'temp.csv';
  23. table = read_csv(xfile)
  24. x = []
  25. y = []
  26. z = []
  27. for i in range(0, len(table)):
  28. x.append(int(1/table[i][0]))
  29. y.append(table[i][1])
  30. z.append(table[i][2])
  31. extent = [min(x), max(x), min(y), max(y)]
  32. d = stats.binned_statistic_2d(x, y, z, statistic='mean', bins = [5, 5])
  33. fig, ax = plt.subplots()
  34. extent = [min(x), max(x), min(y), max(y)]
  35. im = ax.imshow(d[0].T, cmap='RdBu_r', interpolation='nearest', origin='lower')
  36. print(d[0])
  37. print(d[1])
  38. print(d[2])
  39. cbar = ax.figure.colorbar(im, ax = ax, shrink = 1)
  40. plt.show()
  41. plt.close()

Printed Output

  1. [[0.00658065 0.01352 0.03897 0.09360667 0.15375806]
  2. [ nan nan nan nan nan]
  3. [0.00704516 0.02388 0.11518667 0.37206333 0.69959677]
  4. [ nan nan nan nan nan]
  5. [0.00575484 0.01212 0.05937667 0.22448333 0.46173226]]
  6. [ 923. 962.8 1002.6 1042.4 1082.2 1122. ]
  7. [ 2.83236704 4.58410957 6.33585211 8.08759464 9.83933718 11.59107971]

When I use 'extent' parameter or custom axes ticks using set_xticks, the map is not showing correctly. Without 'extent', everything is fine but then the axes ticks are indexed as 0, 1, 2, 3. Kindly help me resolve this issue. It is also OK if someone suggests another python package to plot heatmap with binned stats, I require saved graphs to be used in a manuscript.

Expected Plot

What I need is, the edges of the bins in the graph should show the actual bin's dimension. If xedges are = [900, 925, 975, ..], the ticks on the x-axis should start with 900, and the next tick should be on the next bin edge showing 925. The same for y-axis.

imshow在使用自定义刻度时为什么显示不正确?

temp.csv

  1. 8.90472E-4,2.8323670382,0.0054
  2. 8.90472E-4,2.8903717579,0.0054
  3. 8.90472E-4,2.9483764776,0.0054
  4. 8.90472E-4,3.0063811973,0.0054
  5. ...
英文:

I am trying to plot heatmap with average values with x and y axes denote physical parameters.

  1. import csv
  2. import matplotlib.pyplot as plt
  3. from scipy import stats
  4. import numpy as np
  5. #.......................................................................
  6. # URL for temp.csv https://github.com/paragkan/dyanmic-recrystallization/blob/main/temp.csv
  7. #.......................................................................
  8. def read_csv(xfile):
  9. infile = open(xfile, 'r')
  10. table = []
  11. for row in csv.reader(infile):
  12. table.append(row)
  13. infile.close() # better leave that file alone.
  14. for c in range (0, len(table[0])):
  15. for r in range(0, len(table)):
  16. try:
  17. table[r][c] = float(table[r][c])
  18. except:
  19. pass
  20. return table
  21. #.......................................................................
  22. xfile = 'temp.csv'
  23. table = read_csv(xfile)
  24. x = []
  25. y = []
  26. z = []
  27. for i in range(0, len(table)):
  28. x.append(int(1/table[i][0]))
  29. y.append(table[i][1])
  30. z.append(table[i][2])
  31. extent = [min(x), max(x), min(y), max(y)]
  32. d = stats.binned_statistic_2d(x, y, z, statistic='mean', bins = [5, 5])
  33. fig, ax = plt.subplots()
  34. extent = [min(x), max(x), min(y), max(y)]
  35. # im = ax.imshow(d[0].T, cmap='RdBu_r', interpolation='nearest', origin='lower', extent=extent)
  36. im = ax.imshow(d[0].T, cmap='RdBu_r', interpolation='nearest', origin='lower')
  37. print(d[0])
  38. print(d[1])
  39. print(d[2])
  40. # ax.set_xticks(d[1])
  41. # ax.set_yticks(d[2])
  42. cbar = ax.figure.colorbar(im, ax = ax, shrink = 1)
  43. # average = d[0].T
  44. # xdist = d[1]
  45. # ydist = d[2]
  46. # for i in range(0, len(d[1])-1):
  47. # for j in range(len(d[2])-1):
  48. # xcord = (xdist[j] + xdist[j+1])/2
  49. # ycord = (ydist[i] + ydist[i+1])/2
  50. # txtext = plt.text(xcord, ycord, round(average[i][j], 2), fontsize = 12, ha="center", va="center", color="w")
  51. plt.show()
  52. plt.close()

Printed Output

  1. [[0.00658065 0.01352 0.03897 0.09360667 0.15375806]
  2. [ nan nan nan nan nan]
  3. [0.00704516 0.02388 0.11518667 0.37206333 0.69959677]
  4. [ nan nan nan nan nan]
  5. [0.00575484 0.01212 0.05937667 0.22448333 0.46173226]]
  6. [ 923. 962.8 1002.6 1042.4 1082.2 1122. ]
  7. [ 2.83236704 4.58410957 6.33585211 8.08759464 9.83933718 11.59107971]

Without extent

imshow在使用自定义刻度时为什么显示不正确?

With extent=extent

imshow在使用自定义刻度时为什么显示不正确?

When I use 'extent' parameter or custom axes ticks using set_xticks, the map is not showing correctly. Without 'extent', everything is fine but then the axes ticks are indexed as 0, 1, 2, 3. Kindly help me resolve this issue. It is also OK if someone suggests another python package to plot heatmap with binned stats, I require saved graphs to be used in a manuscript.

Expected Plot

What I need is, the edges of the bins in the graph should show the actual bin's dimension. If xedges are = [900, 925, 975, ..], the ticks on the x-axis should start with 900, and the next tick should be on the next bin edge showing 925. The same for y-axis.

imshow在使用自定义刻度时为什么显示不正确?

temp.csv

  1. 8.90472E-4,2.8323670382,0.0054
  2. 8.90472E-4,2.8903717579,0.0054
  3. 8.90472E-4,2.9483764776,0.0054
  4. 8.90472E-4,3.0063811973,0.0054
  5. 8.90472E-4,3.064385917,0.0054
  6. 8.90472E-4,3.1223906367,0.0054
  7. 8.90472E-4,3.1803953564,0.0054
  8. 8.90472E-4,3.2384000762,0.0055
  9. 8.90472E-4,3.2964047959,0.0055
  10. 8.90472E-4,3.3544095156,0.0055
  11. 8.90472E-4,3.4124142353,0.0055
  12. 8.90472E-4,3.470418955,0.0055
  13. 8.90472E-4,3.5284236747,0.0055
  14. 8.90472E-4,3.5864283944,0.0056
  15. 8.90472E-4,3.6444331141,0.0056
  16. 8.90472E-4,3.7024378338,0.0056
  17. 8.90472E-4,3.7604425536,0.0057
  18. 8.90472E-4,3.8184472733,0.0057
  19. 8.90472E-4,3.876451993,0.0057
  20. 8.90472E-4,3.9344567127,0.0058
  21. 8.90472E-4,3.9924614324,0.0058
  22. 8.90472E-4,4.0504661521,0.0059
  23. 8.90472E-4,4.1084708718,0.0059
  24. 8.90472E-4,4.1664755915,0.006
  25. 8.90472E-4,4.2244803112,0.0061
  26. 8.90472E-4,4.282485031,0.0061
  27. 8.90472E-4,4.3404897507,0.0062
  28. 8.90472E-4,4.3984944704,0.0063
  29. 8.90472E-4,4.4564991901,0.0064
  30. 8.90472E-4,4.5145039098,0.0065
  31. 8.90472E-4,4.5725086295,0.0067
  32. 8.90472E-4,4.6305133492,0.0068
  33. 8.90472E-4,4.6885180689,0.0069
  34. 8.90472E-4,4.7465227886,0.0071
  35. 8.90472E-4,4.8045275084,0.0073
  36. 8.90472E-4,4.8625322281,0.0075
  37. 8.90472E-4,4.9205369478,0.0077
  38. 8.90472E-4,4.9785416675,0.0079
  39. 8.90472E-4,5.0365463872,0.0082
  40. 8.90472E-4,5.0945511069,0.0084
  41. 8.90472E-4,5.1525558266,0.0087
  42. 8.90472E-4,5.2105605463,0.009
  43. 8.90472E-4,5.268565266,0.0094
  44. 8.90472E-4,5.3265699857,0.0097
  45. 8.90472E-4,5.3845747055,0.0101
  46. 8.90472E-4,5.4425794252,0.0105
  47. 8.90472E-4,5.5005841449,0.011
  48. 8.90472E-4,5.5585888646,0.0115
  49. 8.90472E-4,5.6165935843,0.012
  50. 8.90472E-4,5.674598304,0.0126
  51. 8.90472E-4,5.7326030237,0.0132
  52. 8.90472E-4,5.7906077434,0.0139
  53. 8.90472E-4,5.8486124631,0.0146
  54. 8.90472E-4,5.9066171829,0.0154
  55. 8.90472E-4,5.9646219026,0.0162
  56. 8.90472E-4,6.0226266223,0.0171
  57. 8.90472E-4,6.080631342,0.018
  58. 8.90472E-4,6.1386360617,0.019
  59. 8.90472E-4,6.1966407814,0.0201
  60. 8.90472E-4,6.2546455011,0.0213
  61. 8.90472E-4,6.3126502208,0.0225
  62. 8.90472E-4,6.3706549405,0.0238
  63. 8.90472E-4,6.4286596603,0.0252
  64. 8.90472E-4,6.48666438,0.0266
  65. 8.90472E-4,6.5446690997,0.0282
  66. 8.90472E-4,6.6026738194,0.0298
  67. 8.90472E-4,6.6606785391,0.0316
  68. 8.90472E-4,6.7186832588,0.0334
  69. 8.90472E-4,6.7766879785,0.0354
  70. 8.90472E-4,6.8346926982,0.0375
  71. 8.90472E-4,6.8926974179,0.0397
  72. 8.90472E-4,6.9507021376,0.042
  73. 8.90472E-4,7.0087068574,0.0444
  74. 8.90472E-4,7.0667115771,0.047
  75. 8.90472E-4,7.1247162968,0.0497
  76. 8.90472E-4,7.1827210165,0.0525
  77. 8.90472E-4,7.2407257362,0.0555
  78. 8.90472E-4,7.2987304559,0.0586
  79. 8.90472E-4,7.3567351756,0.0619
  80. 8.90472E-4,7.4147398953,0.0654
  81. 8.90472E-4,7.472744615,0.069
  82. 8.90472E-4,7.5307493348,0.0727
  83. 8.90472E-4,7.5887540545,0.0766
  84. 8.90472E-4,7.6467587742,0.0807
  85. 8.90472E-4,7.7047634939,0.085
  86. 8.90472E-4,7.7627682136,0.0894
  87. 8.90472E-4,7.8207729333,0.094
  88. 8.90472E-4,7.878777653,0.0988
  89. 8.90472E-4,7.9367823727,0.1038
  90. 8.90472E-4,7.9947870924,0.1089
  91. 8.90472E-4,8.0527918122,0.1142
  92. 8.90472E-4,8.1107965319,0.1197
  93. 8.90472E-4,8.1688012516,0.1255
  94. 8.90472E-4,8.2268059713,0.1313
  95. 8.90472E-4,8.284810691,0.1374
  96. 8.90472E-4,8.3428154107,0.1437
  97. 8.90472E-4,8.4008201304,0.1501
  98. 8.90472E-4,8.4588248501,0.1567
  99. 8.90472E-4,8.5168295698,0.1635
  100. 8.90472E-4,8.5748342895,0.1705
  101. 8.90472E-4,8.6328390093,0.1776
  102. 8.90472E-4,8.690843729,0.1849
  103. 8.90472E-4,8.7488484487,0.1924
  104. 8.90472E-4,8.8068531684,0.2
  105. 8.90472E-4,8.8648578881,0.2078
  106. 8.90472E-4,8.9228626078,0.2157
  107. 8.90472E-4,8.9808673275,0.2238
  108. 8.90472E-4,9.0388720472,0.232
  109. 8.90472E-4,9.0968767669,0.2403
  110. 8.90472E-4,9.1548814867,0.2487
  111. 8.90472E-4,9.2128862064,0.2572
  112. 8.90472E-4,9.2708909261,0.2658
  113. 8.90472E-4,9.3288956458,0.2745
  114. 8.90472E-4,9.3869003655,0.2833
  115. 8.90472E-4,9.4449050852,0.2921
  116. 8.90472E-4,9.5029098049,0.301
  117. 8.90472E-4,9.5609145246,0.3099
  118. 8.90472E-4,9.6189192443,0.3189
  119. 8.90472E-4,9.6769239641,0.3278
  120. 8.90472E-4,9.7349286838,0.3367
  121. 8.90472E-4,9.7929334035,0.3457
  122. 8.90472E-4,9.8509381232,0.3545
  123. 8.90472E-4,9.9089428429,0.3634
  124. 8.90472E-4,9.9669475626,0.3721
  125. 8.90472E-4,10.0249522823,0.3808
  126. 8.90472E-4,10.082957002,0.3894
  127. 8.90472E-4,10.1409617217,0.3979
  128. 8.90472E-4,10.1989664414,0.4062
  129. 8.90472E-4,10.2569711612,0.4144
  130. 8.90472E-4,10.3149758809,0.4224
  131. 8.90472E-4,10.3729806006,0.4303
  132. 8.90472E-4,10.4309853203,0.438
  133. 8.90472E-4,10.48899004,0.4454
  134. 8.90472E-4,10.5469947597,0.4526
  135. 8.90472E-4,10.6049994794,0.4596
  136. 8.90472E-4,10.6630041991,0.4664
  137. 8.90472E-4,10.7210089188,0.4728
  138. 8.90472E-4,10.7790136386,0.479
  139. 8.90472E-4,10.8370183583,0.4849
  140. 8.90472E-4,10.895023078,0.4905
  141. 8.90472E-4,10.9530277977,0.4957
  142. 8.90472E-4,11.0110325174,0.5007
  143. 8.90472E-4,11.0690372371,0.5052
  144. 8.90472E-4,11.1270419568,0.5095
  145. 8.90472E-4,11.1850466765,0.5133
  146. 8.90472E-4,11.2430513962,0.5168
  147. 8.90472E-4,11.301056116,0.5199
  148. 8.90472E-4,11.3590608357,0.5226
  149. 8.90472E-4,11.4170655554,0.5249
  150. 8.90472E-4,11.4750702751,0.5268
  151. 8.90472E-4,11.5330749948,0.5283
  152. 8.90472E-4,11.5910797145,0.5294
  153. 9.775171E-4,2.8323670382,0.0056
  154. 9.775171E-4,2.8903717579,0.0057
  155. 9.775171E-4,2.9483764776,0.0057
  156. 9.775171E-4,3.0063811973,0.0057
  157. 9.775171E-4,3.064385917,0.0058
  158. 9.775171E-4,3.1223906367,0.0058
  159. 9.775171E-4,3.1803953564,0.0059
  160. 9.775171E-4,3.2384000762,0.0059
  161. 9.775171E-4,3.2964047959,0.006
  162. 9.775171E-4,3.3544095156,0.0061
  163. 9.775171E-4,3.4124142353,0.0061
  164. 9.775171E-4,3.470418955,0.0062
  165. 9.775171E-4,3.5284236747,0.0063
  166. 9.775171E-4,3.5864283944,0.0064
  167. 9.775171E-4,3.6444331141,0.0065
  168. 9.775171E-4,3.7024378338,0.0066
  169. 9.775171E-4,3.7604425536,0.0067
  170. 9.775171E-4,3.8184472733,0.0069
  171. 9.775171E-4,3.876451993,0.007
  172. 9.775171E-4,3.9344567127,0.0072
  173. 9.775171E-4,3.9924614324,0.0074
  174. 9.775171E-4,4.0504661521,0.0075
  175. 9.775171E-4,4.1084708718,0.0078
  176. 9.775171E-4,4.1664755915,0.008
  177. 9.775171E-4,4.2244803112,0.0082
  178. 9.775171E-4,4.282485031,0.0085
  179. 9.775171E-4,4.3404897507,0.0087
  180. 9.775171E-4,4.3984944704,0.009
  181. 9.775171E-4,4.4564991901,0.0094
  182. 9.775171E-4,4.5145039098,0.0097
  183. 9.775171E-4,4.5725086295,0.0101
  184. 9.775171E-4,4.6305133492,0.0105
  185. 9.775171E-4,4.6885180689,0.011
  186. 9.775171E-4,4.7465227886,0.0114
  187. 9.775171E-4,4.8045275084,0.0119
  188. 9.775171E-4,4.8625322281,0.0125
  189. 9.775171E-4,4.9205369478,0.0131
  190. 9.775171E-4,4.9785416675,0.0137
  191. 9.775171E-4,5.0365463872,0.0144
  192. 9.775171E-4,5.0945511069,0.0151
  193. 9.775171E-4,5.1525558266,0.0159
  194. 9.775171E-4,5.2105605463,0.0167
  195. 9.775171E-4,5.268565266,0.0176
  196. 9.775171E-4,5.3265699857,0.0185
  197. 9.775171E-4,5.3845747055,0.0195
  198. 9.775171E-4,5.4425794252,0.0206
  199. 9.775171E-4,5.5005841449,0.0217
  200. 9.775171E-4,5.5585888646,0.0229
  201. 9.775171E-4,5.6165935843,0.0242
  202. 9.775171E-4,5.674598304,0.0256
  203. 9.775171E-4,5.7326030237,0.0271
  204. 9.775171E-4,5.7906077434,0.0286
  205. 9.775171E-4,5.8486124631,0.0302
  206. 9.775171E-4,5.9066171829,0.032
  207. 9.775171E-4,5.9646219026,0.0338
  208. 9.775171E-4,6.0226266223,0.0358
  209. 9.775171E-4,6.080631342,0.0378
  210. 9.775171E-4,6.1386360617,0.04
  211. 9.775171E-4,6.1966407814,0.0423
  212. 9.775171E-4,6.2546455011,0.0447
  213. 9.775171E-4,6.3126502208,0.0473
  214. 9.775171E-4,6.3706549405,0.05
  215. 9.775171E-4,6.4286596603,0.0528
  216. 9.775171E-4,6.48666438,0.0558
  217. 9.775171E-4,6.5446690997,0.0589
  218. 9.775171E-4,6.6026738194,0.0622
  219. 9.775171E-4,6.6606785391,0.0657
  220. 9.775171E-4,6.7186832588,0.0693
  221. 9.775171E-4,6.7766879785,0.0731
  222. 9.775171E-4,6.8346926982,0.077
  223. 9.775171E-4,6.8926974179,0.0812
  224. 9.775171E-4,6.9507021376,0.0855
  225. 9.775171E-4,7.0087068574,0.09
  226. 9.775171E-4,7.0667115771,0.0947
  227. 9.775171E-4,7.1247162968,0.0997
  228. 9.775171E-4,7.1827210165,0.1048
  229. 9.775171E-4,7.2407257362,0.1101
  230. 9.775171E-4,7.2987304559,0.1156
  231. 9.775171E-4,7.3567351756,0.1214
  232. 9.775171E-4,7.4147398953,0.1274
  233. 9.775171E-4,7.472744615,0.1336
  234. 9.775171E-4,7.5307493348,0.14
  235. 9.775171E-4,7.5887540545,0.1466
  236. 9.775171E-4,7.6467587742,0.1535
  237. 9.775171E-4,7.7047634939,0.1606
  238. 9.775171E-4,7.7627682136,0.168
  239. 9.775171E-4,7.8207729333,0.1755
  240. 9.775171E-4,7.878777653,0.1833
  241. 9.775171E-4,7.9367823727,0.1914
  242. 9.775171E-4,7.9947870924,0.1997
  243. 9.775171E-4,8.0527918122,0.2082
  244. 9.775171E-4,8.1107965319,0.2169
  245. 9.775171E-4,8.1688012516,0.2259
  246. 9.775171E-4,8.2268059713,0.2351
  247. 9.775171E-4,8.284810691,0.2445
  248. 9.775171E-4,8.3428154107,0.2542
  249. 9.775171E-4,8.4008201304,0.264
  250. 9.775171E-4,8.4588248501,0.2741
  251. 9.775171E-4,8.5168295698,0.2844
  252. 9.775171E-4,8.5748342895,0.2948
  253. 9.775171E-4,8.6328390093,0.3055
  254. 9.775171E-4,8.690843729,0.3164
  255. 9.775171E-4,8.7488484487,0.3274
  256. 9.775171E-4,8.8068531684,0.3386
  257. 9.775171E-4,8.8648578881,0.35
  258. 9.775171E-4,8.9228626078,0.3615
  259. 9.775171E-4,8.9808673275,0.3732
  260. 9.775171E-4,9.0388720472,0.3849
  261. 9.775171E-4,9.0968767669,0.3968
  262. 9.775171E-4,9.1548814867,0.4088
  263. 9.775171E-4,9.2128862064,0.4209
  264. 9.775171E-4,9.2708909261,0.4331
  265. 9.775171E-4,9.3288956458,0.4453
  266. 9.775171E-4,9.3869003655,0.4576
  267. 9.775171E-4,9.4449050852,0.4699
  268. 9.775171E-4,9.5029098049,0.4823
  269. 9.775171E-4,9.5609145246,0.4946
  270. 9.775171E-4,9.6189192443,0.5069
  271. 9.775171E-4,9.6769239641,0.5192
  272. 9.775171E-4,9.7349286838,0.5315
  273. 9.775171E-4,9.7929334035,0.5436
  274. 9.775171E-4,9.8509381232,0.5557
  275. 9.775171E-4,9.9089428429,0.5677
  276. 9.775171E-4,9.9669475626,0.5796
  277. 9.775171E-4,10.0249522823,0.5913
  278. 9.775171E-4,10.082957002,0.6028
  279. 9.775171E-4,10.1409617217,0.6142
  280. 9.775171E-4,10.1989664414,0.6254
  281. 9.775171E-4,10.2569711612,0.6364
  282. 9.775171E-4,10.3149758809,0.6471
  283. 9.775171E-4,10.3729806006,0.6576
  284. 9.775171E-4,10.4309853203,0.6678
  285. 9.775171E-4,10.48899004,0.6778
  286. 9.775171E-4,10.5469947597,0.6874
  287. 9.775171E-4,10.6049994794,0.6967
  288. 9.775171E-4,10.6630041991,0.7056
  289. 9.775171E-4,10.7210089188,0.7142
  290. 9.775171E-4,10.7790136386,0.7225
  291. 9.775171E-4,10.8370183583,0.7303
  292. 9.775171E-4,10.895023078,0.7377
  293. 9.775171E-4,10.9530277977,0.7448
  294. 9.775171E-4,11.0110325174,0.7514
  295. 9.775171E-4,11.0690372371,0.7575
  296. 9.775171E-4,11.1270419568,0.7632
  297. 9.775171E-4,11.1850466765,0.7684
  298. 9.775171E-4,11.2430513962,0.7732
  299. 9.775171E-4,11.301056116,0.7774
  300. 9.775171E-4,11.3590608357,0.7812
  301. 9.775171E-4,11.4170655554,0.7845
  302. 9.775171E-4,11.4750702751,0.7873
  303. 9.775171E-4,11.5330749948,0.7895
  304. 9.775171E-4,11.5910797145,0.7913
  305. 0.0010834236,2.8323670382,0.0057
  306. 0.0010834236,2.8903717579,0.0057
  307. 0.0010834236,2.9483764776,0.0057
  308. 0.0010834236,3.0063811973,0.0058
  309. 0.0010834236,3.064385917,0.0058
  310. 0.0010834236,3.1223906367,0.0058
  311. 0.0010834236,3.1803953564,0.0059
  312. 0.0010834236,3.2384000762,0.0059
  313. 0.0010834236,3.2964047959,0.006
  314. 0.0010834236,3.3544095156,0.006
  315. 0.0010834236,3.4124142353,0.0061
  316. 0.0010834236,3.470418955,0.0061
  317. 0.0010834236,3.5284236747,0.0062
  318. 0.0010834236,3.5864283944,0.0062
  319. 0.0010834236,3.6444331141,0.0063
  320. 0.0010834236,3.7024378338,0.0064
  321. 0.0010834236,3.7604425536,0.0065
  322. 0.0010834236,3.8184472733,0.0065
  323. 0.0010834236,3.876451993,0.0066
  324. 0.0010834236,3.9344567127,0.0067
  325. 0.0010834236,3.9924614324,0.0068
  326. 0.0010834236,4.0504661521,0.0069
  327. 0.0010834236,4.1084708718,0.007
  328. 0.0010834236,4.1664755915,0.0072
  329. 0.0010834236,4.2244803112,0.0073
  330. 0.0010834236,4.282485031,0.0074
  331. 0.0010834236,4.3404897507,0.0076
  332. 0.0010834236,4.3984944704,0.0077
  333. 0.0010834236,4.4564991901,0.0079
  334. 0.0010834236,4.5145039098,0.0081
  335. 0.0010834236,4.5725086295,0.0082
  336. 0.0010834236,4.6305133492,0.0084
  337. 0.0010834236,4.6885180689,0.0086
  338. 0.0010834236,4.7465227886,0.0089
  339. 0.0010834236,4.8045275084,0.0091
  340. 0.0010834236,4.8625322281,0.0093
  341. 0.0010834236,4.9205369478,0.0096
  342. 0.0010834236,4.9785416675,0.0098
  343. 0.0010834236,5.0365463872,0.0101
  344. 0.0010834236,5.0945511069,0.0104
  345. 0.0010834236,5.1525558266,0.0107
  346. 0.0010834236,5.2105605463,0.0111
  347. 0.0010834236,5.268565266,0.0114
  348. 0.0010834236,5.3265699857,0.0118
  349. 0.0010834236,5.3845747055,0.0122
  350. 0.0010834236,5.4425794252,0.0126
  351. 0.0010834236,5.5005841449,0.013
  352. 0.0010834236,5.5585888646,0.0134
  353. 0.0010834236,5.6165935843,0.0139
  354. 0.0010834236,5.674598304,0.0144
  355. 0.0010834236,5.7326030237,0.0149
  356. 0.0010834236,5.7906077434,0.0154
  357. 0.0010834236,5.8486124631,0.016
  358. 0.0010834236,5.9066171829,0.0165
  359. 0.0010834236,5.9646219026,0.0171
  360. 0.0010834236,6.0226266223,0.0178
  361. 0.0010834236,6.080631342,0.0184
  362. 0.0010834236,6.1386360617,0.0191
  363. 0.0010834236,6.1966407814,0.0198
  364. 0.0010834236,6.2546455011,0.0206
  365. 0.0010834236,6.3126502208,0.0213
  366. 0.0010834236,6.3706549405,0.0221
  367. 0.0010834236,6.4286596603,0.023
  368. 0.0010834236,6.48666438,0.0238
  369. 0.0010834236,6.5446690997,0.0247
  370. 0.0010834236,6.6026738194,0.0257
  371. 0.0010834236,6.6606785391,0.0266
  372. 0.0010834236,6.7186832588,0.0276
  373. 0.0010834236,6.7766879785,0.0287
  374. 0.0010834236,6.8346926982,0.0297
  375. 0.0010834236,6.8926974179,0.0308
  376. 0.0010834236,6.9507021376,0.032
  377. 0.0010834236,7.0087068574,0.0332
  378. 0.0010834236,7.0667115771,0.0344
  379. 0.0010834236,7.1247162968,0.0356
  380. 0.0010834236,7.1827210165,0.0369
  381. 0.0010834236,7.2407257362,0.0382
  382. 0.0010834236,7.2987304559,0.0396
  383. 0.0010834236,7.3567351756,0.041
  384. 0.0010834236,7.4147398953,0.0425
  385. 0.0010834236,7.472744615,0.0439
  386. 0.0010834236,7.5307493348,0.0455
  387. 0.0010834236,7.5887540545,0.047
  388. 0.0010834236,7.6467587742,0.0486
  389. 0.0010834236,7.7047634939,0.0502
  390. 0.0010834236,7.7627682136,0.0519
  391. 0.0010834236,7.8207729333,0.0536
  392. 0.0010834236,7.878777653,0.0554
  393. 0.0010834236,7.9367823727,0.0571
  394. 0.0010834236,7.9947870924,0.059
  395. 0.0010834236,8.0527918122,0.0608
  396. 0.0010834236,8.1107965319,0.0627
  397. 0.0010834236,8.1688012516,0.0646
  398. 0.0010834236,8.2268059713,0.0666
  399. 0.0010834236,8.284810691,0.0685
  400. 0.0010834236,8.3428154107,0.0705
  401. 0.0010834236,8.4008201304,0.0726
  402. 0.0010834236,8.4588248501,0.0747
  403. 0.0010834236,8.5168295698,0.0768
  404. 0.0010834236,8.5748342895,0.0789
  405. 0.0010834236,8.6328390093,0.081
  406. 0.0010834236,8.690843729,0.0832
  407. 0.0010834236,8.7488484487,0.0854
  408. 0.0010834236,8.8068531684,0.0876
  409. 0.0010834236,8.8648578881,0.0898
  410. 0.0010834236,8.9228626078,0.092
  411. 0.0010834236,8.9808673275,0.0943
  412. 0.0010834236,9.0388720472,0.0966
  413. 0.0010834236,9.0968767669,0.0988
  414. 0.0010834236,9.1548814867,0.1011
  415. 0.0010834236,9.2128862064,0.1034
  416. 0.0010834236,9.2708909261,0.1057
  417. 0.0010834236,9.3288956458,0.108
  418. 0.0010834236,9.3869003655,0.1103
  419. 0.0010834236,9.4449050852,0.1125
  420. 0.0010834236,9.5029098049,0.1148
  421. 0.0010834236,9.5609145246,0.1171
  422. 0.0010834236,9.6189192443,0.1193
  423. 0.0010834236,9.6769239641,0.1216
  424. 0.0010834236,9.7349286838,0.1238
  425. 0.0010834236,9.7929334035,0.126
  426. 0.0010834236,9.8509381232,0.1282
  427. 0.0010834236,9.9089428429,0.1303
  428. 0.0010834236,9.9669475626,0.1324
  429. 0.0010834236,10.0249522823,0.1345
  430. 0.0010834236,10.082957002,0.1366
  431. 0.0010834236,10.1409617217,0.1386
  432. 0.0010834236,10.1989664414,0.1406
  433. 0.0010834236,10.2569711612,0.1425
  434. 0.0010834236,10.3149758809,0.1444
  435. 0.0010834236,10.3729806006,0.1463
  436. 0.0010834236,10.4309853203,0.1481
  437. 0.0010834236,10.48899004,0.1498
  438. 0.0010834236,10.5469947597,0.1515
  439. 0.0010834236,10.6049994794,0.1532
  440. 0.0010834236,10.6630041991,0.1547
  441. 0.0010834236,10.7210089188,0.1563
  442. 0.0010834236,10.7790136386,0.1577
  443. 0.0010834236,10.8370183583,0.1591
  444. 0.0010834236,10.895023078,0.1604
  445. 0.0010834236,10.9530277977,0.1617
  446. 0.0010834236,11.0110325174,0.1629
  447. 0.0010834236,11.0690372371,0.164
  448. 0.0010834236,11.1270419568,0.165
  449. 0.0010834236,11.1850466765,0.166
  450. 0.0010834236,11.2430513962,0.1668
  451. 0.0010834236,11.301056116,0.1676
  452. 0.0010834236,11.3590608357,0.1684
  453. 0.0010834236,11.4170655554,0.169
  454. 0.0010834236,11.4750702751,0.1695
  455. 0.0010834236,11.5330749948,0.17
  456. 0.0010834236,11.5910797145,0.1704

答案1

得分: 1

你可以在imshow中使用"aspect"选项来强制图像返回正确的纵横比。要获得正方形图像,纵横比需要设置为两边长度的倒数。参见:https://stackoverflow.com/questions/13384653/imshow-extent-and-aspect

在你的情况下,你的x长度约为200,y长度约为10,所以你需要设置一个约为20的纵横比。

英文:

You can use the "aspect" option in imshow to force the image to return to the correct aspect ratio. To get a square image, the aspect ratio would need to be the inverse of the ratio of the two side lengths. See also: https://stackoverflow.com/questions/13384653/imshow-extent-and-aspect

In your case your x length is about 200 and your y length is about 10, so you'd want to set an aspect of about 20.

huangapple
  • 本文由 发表于 2023年6月9日 01:18:23
  • 转载请务必保留本文链接:https://go.coder-hub.com/76434269.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定