0

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

import csv
import matplotlib.pyplot as plt
from scipy import stats
import numpy as np

#.......................................................................
# URL for temp.csv https://github.com/paragkan/dyanmic-recrystallization/blob/main/temp.csv
#.......................................................................
def read_csv(xfile):
    infile = open(xfile, 'r')
    table = []
    for row in csv.reader(infile):
        table.append(row)
    infile.close() # better leave that file alone.
    for c in range (0, len(table[0])):
        for r in range(0, len(table)):
            try:
                table[r][c] = float(table[r][c])
            except:
                pass
    return table
#.......................................................................

xfile = 'temp.csv'

table = read_csv(xfile)

x = []
y = []
z = []

for i in range(0, len(table)):
    x.append(int(1/table[i][0]))
    y.append(table[i][1])
    z.append(table[i][2])

extent = [min(x), max(x), min(y), max(y)]
d = stats.binned_statistic_2d(x, y, z, statistic='mean', bins = [5, 5])

fig, ax = plt.subplots()
extent = [min(x), max(x), min(y), max(y)]
# im = ax.imshow(d[0].T, cmap='RdBu_r',  interpolation='nearest', origin='lower', extent=extent)
im = ax.imshow(d[0].T, cmap='RdBu_r',  interpolation='nearest', origin='lower')

print(d[0])
print(d[1])
print(d[2])

# ax.set_xticks(d[1])
# ax.set_yticks(d[2])

cbar = ax.figure.colorbar(im, ax = ax, shrink = 1)
# average = d[0].T
# xdist = d[1]
# ydist = d[2]
# for i in range(0, len(d[1])-1):
#     for j in range(len(d[2])-1):
#         xcord = (xdist[j] + xdist[j+1])/2
#         ycord = (ydist[i] + ydist[i+1])/2
#         txtext = plt.text(xcord, ycord, round(average[i][j], 2),  fontsize = 12, ha="center", va="center", color="w")
plt.show()
plt.close()

Printed Output

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

Without extent

enter image description here

With extent=extent

enter image description here

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.

enter image description here

temp.csv

8.90472E-4,2.8323670382,0.0054
8.90472E-4,2.8903717579,0.0054
8.90472E-4,2.9483764776,0.0054
8.90472E-4,3.0063811973,0.0054
8.90472E-4,3.064385917,0.0054
8.90472E-4,3.1223906367,0.0054
8.90472E-4,3.1803953564,0.0054
8.90472E-4,3.2384000762,0.0055
8.90472E-4,3.2964047959,0.0055
8.90472E-4,3.3544095156,0.0055
8.90472E-4,3.4124142353,0.0055
8.90472E-4,3.470418955,0.0055
8.90472E-4,3.5284236747,0.0055
8.90472E-4,3.5864283944,0.0056
8.90472E-4,3.6444331141,0.0056
8.90472E-4,3.7024378338,0.0056
8.90472E-4,3.7604425536,0.0057
8.90472E-4,3.8184472733,0.0057
8.90472E-4,3.876451993,0.0057
8.90472E-4,3.9344567127,0.0058
8.90472E-4,3.9924614324,0.0058
8.90472E-4,4.0504661521,0.0059
8.90472E-4,4.1084708718,0.0059
8.90472E-4,4.1664755915,0.006
8.90472E-4,4.2244803112,0.0061
8.90472E-4,4.282485031,0.0061
8.90472E-4,4.3404897507,0.0062
8.90472E-4,4.3984944704,0.0063
8.90472E-4,4.4564991901,0.0064
8.90472E-4,4.5145039098,0.0065
8.90472E-4,4.5725086295,0.0067
8.90472E-4,4.6305133492,0.0068
8.90472E-4,4.6885180689,0.0069
8.90472E-4,4.7465227886,0.0071
8.90472E-4,4.8045275084,0.0073
8.90472E-4,4.8625322281,0.0075
8.90472E-4,4.9205369478,0.0077
8.90472E-4,4.9785416675,0.0079
8.90472E-4,5.0365463872,0.0082
8.90472E-4,5.0945511069,0.0084
8.90472E-4,5.1525558266,0.0087
8.90472E-4,5.2105605463,0.009
8.90472E-4,5.268565266,0.0094
8.90472E-4,5.3265699857,0.0097
8.90472E-4,5.3845747055,0.0101
8.90472E-4,5.4425794252,0.0105
8.90472E-4,5.5005841449,0.011
8.90472E-4,5.5585888646,0.0115
8.90472E-4,5.6165935843,0.012
8.90472E-4,5.674598304,0.0126
8.90472E-4,5.7326030237,0.0132
8.90472E-4,5.7906077434,0.0139
8.90472E-4,5.8486124631,0.0146
8.90472E-4,5.9066171829,0.0154
8.90472E-4,5.9646219026,0.0162
8.90472E-4,6.0226266223,0.0171
8.90472E-4,6.080631342,0.018
8.90472E-4,6.1386360617,0.019
8.90472E-4,6.1966407814,0.0201
8.90472E-4,6.2546455011,0.0213
8.90472E-4,6.3126502208,0.0225
8.90472E-4,6.3706549405,0.0238
8.90472E-4,6.4286596603,0.0252
8.90472E-4,6.48666438,0.0266
8.90472E-4,6.5446690997,0.0282
8.90472E-4,6.6026738194,0.0298
8.90472E-4,6.6606785391,0.0316
8.90472E-4,6.7186832588,0.0334
8.90472E-4,6.7766879785,0.0354
8.90472E-4,6.8346926982,0.0375
8.90472E-4,6.8926974179,0.0397
8.90472E-4,6.9507021376,0.042
8.90472E-4,7.0087068574,0.0444
8.90472E-4,7.0667115771,0.047
8.90472E-4,7.1247162968,0.0497
8.90472E-4,7.1827210165,0.0525
8.90472E-4,7.2407257362,0.0555
8.90472E-4,7.2987304559,0.0586
8.90472E-4,7.3567351756,0.0619
8.90472E-4,7.4147398953,0.0654
8.90472E-4,7.472744615,0.069
8.90472E-4,7.5307493348,0.0727
8.90472E-4,7.5887540545,0.0766
8.90472E-4,7.6467587742,0.0807
8.90472E-4,7.7047634939,0.085
8.90472E-4,7.7627682136,0.0894
8.90472E-4,7.8207729333,0.094
8.90472E-4,7.878777653,0.0988
8.90472E-4,7.9367823727,0.1038
8.90472E-4,7.9947870924,0.1089
8.90472E-4,8.0527918122,0.1142
8.90472E-4,8.1107965319,0.1197
8.90472E-4,8.1688012516,0.1255
8.90472E-4,8.2268059713,0.1313
8.90472E-4,8.284810691,0.1374
8.90472E-4,8.3428154107,0.1437
8.90472E-4,8.4008201304,0.1501
8.90472E-4,8.4588248501,0.1567
8.90472E-4,8.5168295698,0.1635
8.90472E-4,8.5748342895,0.1705
8.90472E-4,8.6328390093,0.1776
8.90472E-4,8.690843729,0.1849
8.90472E-4,8.7488484487,0.1924
8.90472E-4,8.8068531684,0.2
8.90472E-4,8.8648578881,0.2078
8.90472E-4,8.9228626078,0.2157
8.90472E-4,8.9808673275,0.2238
8.90472E-4,9.0388720472,0.232
8.90472E-4,9.0968767669,0.2403
8.90472E-4,9.1548814867,0.2487
8.90472E-4,9.2128862064,0.2572
8.90472E-4,9.2708909261,0.2658
8.90472E-4,9.3288956458,0.2745
8.90472E-4,9.3869003655,0.2833
8.90472E-4,9.4449050852,0.2921
8.90472E-4,9.5029098049,0.301
8.90472E-4,9.5609145246,0.3099
8.90472E-4,9.6189192443,0.3189
8.90472E-4,9.6769239641,0.3278
8.90472E-4,9.7349286838,0.3367
8.90472E-4,9.7929334035,0.3457
8.90472E-4,9.8509381232,0.3545
8.90472E-4,9.9089428429,0.3634
8.90472E-4,9.9669475626,0.3721
8.90472E-4,10.0249522823,0.3808
8.90472E-4,10.082957002,0.3894
8.90472E-4,10.1409617217,0.3979
8.90472E-4,10.1989664414,0.4062
8.90472E-4,10.2569711612,0.4144
8.90472E-4,10.3149758809,0.4224
8.90472E-4,10.3729806006,0.4303
8.90472E-4,10.4309853203,0.438
8.90472E-4,10.48899004,0.4454
8.90472E-4,10.5469947597,0.4526
8.90472E-4,10.6049994794,0.4596
8.90472E-4,10.6630041991,0.4664
8.90472E-4,10.7210089188,0.4728
8.90472E-4,10.7790136386,0.479
8.90472E-4,10.8370183583,0.4849
8.90472E-4,10.895023078,0.4905
8.90472E-4,10.9530277977,0.4957
8.90472E-4,11.0110325174,0.5007
8.90472E-4,11.0690372371,0.5052
8.90472E-4,11.1270419568,0.5095
8.90472E-4,11.1850466765,0.5133
8.90472E-4,11.2430513962,0.5168
8.90472E-4,11.301056116,0.5199
8.90472E-4,11.3590608357,0.5226
8.90472E-4,11.4170655554,0.5249
8.90472E-4,11.4750702751,0.5268
8.90472E-4,11.5330749948,0.5283
8.90472E-4,11.5910797145,0.5294
9.775171E-4,2.8323670382,0.0056
9.775171E-4,2.8903717579,0.0057
9.775171E-4,2.9483764776,0.0057
9.775171E-4,3.0063811973,0.0057
9.775171E-4,3.064385917,0.0058
9.775171E-4,3.1223906367,0.0058
9.775171E-4,3.1803953564,0.0059
9.775171E-4,3.2384000762,0.0059
9.775171E-4,3.2964047959,0.006
9.775171E-4,3.3544095156,0.0061
9.775171E-4,3.4124142353,0.0061
9.775171E-4,3.470418955,0.0062
9.775171E-4,3.5284236747,0.0063
9.775171E-4,3.5864283944,0.0064
9.775171E-4,3.6444331141,0.0065
9.775171E-4,3.7024378338,0.0066
9.775171E-4,3.7604425536,0.0067
9.775171E-4,3.8184472733,0.0069
9.775171E-4,3.876451993,0.007
9.775171E-4,3.9344567127,0.0072
9.775171E-4,3.9924614324,0.0074
9.775171E-4,4.0504661521,0.0075
9.775171E-4,4.1084708718,0.0078
9.775171E-4,4.1664755915,0.008
9.775171E-4,4.2244803112,0.0082
9.775171E-4,4.282485031,0.0085
9.775171E-4,4.3404897507,0.0087
9.775171E-4,4.3984944704,0.009
9.775171E-4,4.4564991901,0.0094
9.775171E-4,4.5145039098,0.0097
9.775171E-4,4.5725086295,0.0101
9.775171E-4,4.6305133492,0.0105
9.775171E-4,4.6885180689,0.011
9.775171E-4,4.7465227886,0.0114
9.775171E-4,4.8045275084,0.0119
9.775171E-4,4.8625322281,0.0125
9.775171E-4,4.9205369478,0.0131
9.775171E-4,4.9785416675,0.0137
9.775171E-4,5.0365463872,0.0144
9.775171E-4,5.0945511069,0.0151
9.775171E-4,5.1525558266,0.0159
9.775171E-4,5.2105605463,0.0167
9.775171E-4,5.268565266,0.0176
9.775171E-4,5.3265699857,0.0185
9.775171E-4,5.3845747055,0.0195
9.775171E-4,5.4425794252,0.0206
9.775171E-4,5.5005841449,0.0217
9.775171E-4,5.5585888646,0.0229
9.775171E-4,5.6165935843,0.0242
9.775171E-4,5.674598304,0.0256
9.775171E-4,5.7326030237,0.0271
9.775171E-4,5.7906077434,0.0286
9.775171E-4,5.8486124631,0.0302
9.775171E-4,5.9066171829,0.032
9.775171E-4,5.9646219026,0.0338
9.775171E-4,6.0226266223,0.0358
9.775171E-4,6.080631342,0.0378
9.775171E-4,6.1386360617,0.04
9.775171E-4,6.1966407814,0.0423
9.775171E-4,6.2546455011,0.0447
9.775171E-4,6.3126502208,0.0473
9.775171E-4,6.3706549405,0.05
9.775171E-4,6.4286596603,0.0528
9.775171E-4,6.48666438,0.0558
9.775171E-4,6.5446690997,0.0589
9.775171E-4,6.6026738194,0.0622
9.775171E-4,6.6606785391,0.0657
9.775171E-4,6.7186832588,0.0693
9.775171E-4,6.7766879785,0.0731
9.775171E-4,6.8346926982,0.077
9.775171E-4,6.8926974179,0.0812
9.775171E-4,6.9507021376,0.0855
9.775171E-4,7.0087068574,0.09
9.775171E-4,7.0667115771,0.0947
9.775171E-4,7.1247162968,0.0997
9.775171E-4,7.1827210165,0.1048
9.775171E-4,7.2407257362,0.1101
9.775171E-4,7.2987304559,0.1156
9.775171E-4,7.3567351756,0.1214
9.775171E-4,7.4147398953,0.1274
9.775171E-4,7.472744615,0.1336
9.775171E-4,7.5307493348,0.14
9.775171E-4,7.5887540545,0.1466
9.775171E-4,7.6467587742,0.1535
9.775171E-4,7.7047634939,0.1606
9.775171E-4,7.7627682136,0.168
9.775171E-4,7.8207729333,0.1755
9.775171E-4,7.878777653,0.1833
9.775171E-4,7.9367823727,0.1914
9.775171E-4,7.9947870924,0.1997
9.775171E-4,8.0527918122,0.2082
9.775171E-4,8.1107965319,0.2169
9.775171E-4,8.1688012516,0.2259
9.775171E-4,8.2268059713,0.2351
9.775171E-4,8.284810691,0.2445
9.775171E-4,8.3428154107,0.2542
9.775171E-4,8.4008201304,0.264
9.775171E-4,8.4588248501,0.2741
9.775171E-4,8.5168295698,0.2844
9.775171E-4,8.5748342895,0.2948
9.775171E-4,8.6328390093,0.3055
9.775171E-4,8.690843729,0.3164
9.775171E-4,8.7488484487,0.3274
9.775171E-4,8.8068531684,0.3386
9.775171E-4,8.8648578881,0.35
9.775171E-4,8.9228626078,0.3615
9.775171E-4,8.9808673275,0.3732
9.775171E-4,9.0388720472,0.3849
9.775171E-4,9.0968767669,0.3968
9.775171E-4,9.1548814867,0.4088
9.775171E-4,9.2128862064,0.4209
9.775171E-4,9.2708909261,0.4331
9.775171E-4,9.3288956458,0.4453
9.775171E-4,9.3869003655,0.4576
9.775171E-4,9.4449050852,0.4699
9.775171E-4,9.5029098049,0.4823
9.775171E-4,9.5609145246,0.4946
9.775171E-4,9.6189192443,0.5069
9.775171E-4,9.6769239641,0.5192
9.775171E-4,9.7349286838,0.5315
9.775171E-4,9.7929334035,0.5436
9.775171E-4,9.8509381232,0.5557
9.775171E-4,9.9089428429,0.5677
9.775171E-4,9.9669475626,0.5796
9.775171E-4,10.0249522823,0.5913
9.775171E-4,10.082957002,0.6028
9.775171E-4,10.1409617217,0.6142
9.775171E-4,10.1989664414,0.6254
9.775171E-4,10.2569711612,0.6364
9.775171E-4,10.3149758809,0.6471
9.775171E-4,10.3729806006,0.6576
9.775171E-4,10.4309853203,0.6678
9.775171E-4,10.48899004,0.6778
9.775171E-4,10.5469947597,0.6874
9.775171E-4,10.6049994794,0.6967
9.775171E-4,10.6630041991,0.7056
9.775171E-4,10.7210089188,0.7142
9.775171E-4,10.7790136386,0.7225
9.775171E-4,10.8370183583,0.7303
9.775171E-4,10.895023078,0.7377
9.775171E-4,10.9530277977,0.7448
9.775171E-4,11.0110325174,0.7514
9.775171E-4,11.0690372371,0.7575
9.775171E-4,11.1270419568,0.7632
9.775171E-4,11.1850466765,0.7684
9.775171E-4,11.2430513962,0.7732
9.775171E-4,11.301056116,0.7774
9.775171E-4,11.3590608357,0.7812
9.775171E-4,11.4170655554,0.7845
9.775171E-4,11.4750702751,0.7873
9.775171E-4,11.5330749948,0.7895
9.775171E-4,11.5910797145,0.7913
0.0010834236,2.8323670382,0.0057
0.0010834236,2.8903717579,0.0057
0.0010834236,2.9483764776,0.0057
0.0010834236,3.0063811973,0.0058
0.0010834236,3.064385917,0.0058
0.0010834236,3.1223906367,0.0058
0.0010834236,3.1803953564,0.0059
0.0010834236,3.2384000762,0.0059
0.0010834236,3.2964047959,0.006
0.0010834236,3.3544095156,0.006
0.0010834236,3.4124142353,0.0061
0.0010834236,3.470418955,0.0061
0.0010834236,3.5284236747,0.0062
0.0010834236,3.5864283944,0.0062
0.0010834236,3.6444331141,0.0063
0.0010834236,3.7024378338,0.0064
0.0010834236,3.7604425536,0.0065
0.0010834236,3.8184472733,0.0065
0.0010834236,3.876451993,0.0066
0.0010834236,3.9344567127,0.0067
0.0010834236,3.9924614324,0.0068
0.0010834236,4.0504661521,0.0069
0.0010834236,4.1084708718,0.007
0.0010834236,4.1664755915,0.0072
0.0010834236,4.2244803112,0.0073
0.0010834236,4.282485031,0.0074
0.0010834236,4.3404897507,0.0076
0.0010834236,4.3984944704,0.0077
0.0010834236,4.4564991901,0.0079
0.0010834236,4.5145039098,0.0081
0.0010834236,4.5725086295,0.0082
0.0010834236,4.6305133492,0.0084
0.0010834236,4.6885180689,0.0086
0.0010834236,4.7465227886,0.0089
0.0010834236,4.8045275084,0.0091
0.0010834236,4.8625322281,0.0093
0.0010834236,4.9205369478,0.0096
0.0010834236,4.9785416675,0.0098
0.0010834236,5.0365463872,0.0101
0.0010834236,5.0945511069,0.0104
0.0010834236,5.1525558266,0.0107
0.0010834236,5.2105605463,0.0111
0.0010834236,5.268565266,0.0114
0.0010834236,5.3265699857,0.0118
0.0010834236,5.3845747055,0.0122
0.0010834236,5.4425794252,0.0126
0.0010834236,5.5005841449,0.013
0.0010834236,5.5585888646,0.0134
0.0010834236,5.6165935843,0.0139
0.0010834236,5.674598304,0.0144
0.0010834236,5.7326030237,0.0149
0.0010834236,5.7906077434,0.0154
0.0010834236,5.8486124631,0.016
0.0010834236,5.9066171829,0.0165
0.0010834236,5.9646219026,0.0171
0.0010834236,6.0226266223,0.0178
0.0010834236,6.080631342,0.0184
0.0010834236,6.1386360617,0.0191
0.0010834236,6.1966407814,0.0198
0.0010834236,6.2546455011,0.0206
0.0010834236,6.3126502208,0.0213
0.0010834236,6.3706549405,0.0221
0.0010834236,6.4286596603,0.023
0.0010834236,6.48666438,0.0238
0.0010834236,6.5446690997,0.0247
0.0010834236,6.6026738194,0.0257
0.0010834236,6.6606785391,0.0266
0.0010834236,6.7186832588,0.0276
0.0010834236,6.7766879785,0.0287
0.0010834236,6.8346926982,0.0297
0.0010834236,6.8926974179,0.0308
0.0010834236,6.9507021376,0.032
0.0010834236,7.0087068574,0.0332
0.0010834236,7.0667115771,0.0344
0.0010834236,7.1247162968,0.0356
0.0010834236,7.1827210165,0.0369
0.0010834236,7.2407257362,0.0382
0.0010834236,7.2987304559,0.0396
0.0010834236,7.3567351756,0.041
0.0010834236,7.4147398953,0.0425
0.0010834236,7.472744615,0.0439
0.0010834236,7.5307493348,0.0455
0.0010834236,7.5887540545,0.047
0.0010834236,7.6467587742,0.0486
0.0010834236,7.7047634939,0.0502
0.0010834236,7.7627682136,0.0519
0.0010834236,7.8207729333,0.0536
0.0010834236,7.878777653,0.0554
0.0010834236,7.9367823727,0.0571
0.0010834236,7.9947870924,0.059
0.0010834236,8.0527918122,0.0608
0.0010834236,8.1107965319,0.0627
0.0010834236,8.1688012516,0.0646
0.0010834236,8.2268059713,0.0666
0.0010834236,8.284810691,0.0685
0.0010834236,8.3428154107,0.0705
0.0010834236,8.4008201304,0.0726
0.0010834236,8.4588248501,0.0747
0.0010834236,8.5168295698,0.0768
0.0010834236,8.5748342895,0.0789
0.0010834236,8.6328390093,0.081
0.0010834236,8.690843729,0.0832
0.0010834236,8.7488484487,0.0854
0.0010834236,8.8068531684,0.0876
0.0010834236,8.8648578881,0.0898
0.0010834236,8.9228626078,0.092
0.0010834236,8.9808673275,0.0943
0.0010834236,9.0388720472,0.0966
0.0010834236,9.0968767669,0.0988
0.0010834236,9.1548814867,0.1011
0.0010834236,9.2128862064,0.1034
0.0010834236,9.2708909261,0.1057
0.0010834236,9.3288956458,0.108
0.0010834236,9.3869003655,0.1103
0.0010834236,9.4449050852,0.1125
0.0010834236,9.5029098049,0.1148
0.0010834236,9.5609145246,0.1171
0.0010834236,9.6189192443,0.1193
0.0010834236,9.6769239641,0.1216
0.0010834236,9.7349286838,0.1238
0.0010834236,9.7929334035,0.126
0.0010834236,9.8509381232,0.1282
0.0010834236,9.9089428429,0.1303
0.0010834236,9.9669475626,0.1324
0.0010834236,10.0249522823,0.1345
0.0010834236,10.082957002,0.1366
0.0010834236,10.1409617217,0.1386
0.0010834236,10.1989664414,0.1406
0.0010834236,10.2569711612,0.1425
0.0010834236,10.3149758809,0.1444
0.0010834236,10.3729806006,0.1463
0.0010834236,10.4309853203,0.1481
0.0010834236,10.48899004,0.1498
0.0010834236,10.5469947597,0.1515
0.0010834236,10.6049994794,0.1532
0.0010834236,10.6630041991,0.1547
0.0010834236,10.7210089188,0.1563
0.0010834236,10.7790136386,0.1577
0.0010834236,10.8370183583,0.1591
0.0010834236,10.895023078,0.1604
0.0010834236,10.9530277977,0.1617
0.0010834236,11.0110325174,0.1629
0.0010834236,11.0690372371,0.164
0.0010834236,11.1270419568,0.165
0.0010834236,11.1850466765,0.166
0.0010834236,11.2430513962,0.1668
0.0010834236,11.301056116,0.1676
0.0010834236,11.3590608357,0.1684
0.0010834236,11.4170655554,0.169
0.0010834236,11.4750702751,0.1695
0.0010834236,11.5330749948,0.17
0.0010834236,11.5910797145,0.1704
Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158
Parag
  • 41
  • 8
  • 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. – Parag Jun 11 '23 at 07:25
  • https://github.com/paragkan/dyanmic-recrystallization/blob/main/Figure_1.png This is the desired output of the above question. – Parag Jun 11 '23 at 08:46

1 Answers1

1

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: 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.

  • 1
    `aspect=dx/dy` gives you _exactly_ a square box. I'd like to warn the OP that changing `aspect` is acceptable IFF the units on the axes are different, if the units (e.g., km and km) are the same is better to have `aspect=1` (the default) – gboffi Jun 11 '23 at 21:39
  • Let me try. Thanks for your help. – Parag Jun 12 '23 at 09:21