[Solved] When should give ax.imshow() a variable name? [closed]


You should use im = ax.imshow() when you want add something to the existing axis, for example, a colorbar. If you don’t need to add anything to the axis, then it is fine to just use ax.imshow(). See this: https://www.geeksforgeeks.org/matplotlib-axes-axes-imshow-in-python/

Example from the link:

c = ax.imshow(z, cmap ='Greens', vmin = z_min,
              vmax = z_max, extent =[x.min(),
                                     x.max(),
                                     y.min(),
                                     y.max()],
              interpolation ='nearest', 
              origin ='lower')
  
fig.colorbar(c, ax = ax)

solved When should give ax.imshow() a variable name? [closed]