Autoscaling imagesc plot and imshow plots

Matlab / GNU Octave

Matlab/Octave default axis scaling scales x and y axes proportionally to the axes values. If one axis values span a much wider range than the other axis, the smaller span axis gets very thin and almost invisible.

Fix invisible axis in plot

insert axis('square') after imagesc()

rdat = rand(1000,10);


Force axes to represent actual data size

This is the opposite to the previous problem, where you want the axes to be representative of number of data elements (skinny images appear skinny)–insert axis('equal') after imagesc().

rdat = rand(1000,10);



In Matplotlib, the same issue occurs, which can be overcome with aspect='auto' property of ax.imshow().

You can conversely allow the “true” axes ratio driven by the actual data aspect='equal'

Set this after the plot is created in axes ax by

import numpy as np
from matplotlib.pyplot import figure,show

rdat = np.random.rand(1000,10)

ax = figure().gca()

# %% pick ONE of the following

# non-shared axes

# shared axes only (e.g. subplots(sharex=True))