{"record":{"id":"80cd0ffcd1738b26","repo":"matplotlib/matplotlib","slug":"data-with-more-than-2-24-rows-cannot-be-accuratel","errorCode":null,"errorMessage":"Data with more than 2**24 rows cannot be accurately displayed. Downsampling to less than 2**24 rows before displaying. To remove this warning, manually downsample your data.","messagePattern":"Data with more than 2\\*\\*24 rows cannot be accurately displayed\\. Downsampling to less than 2\\*\\*24 rows before displaying\\. To remove this warning, manually downsample your data\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"lib/matplotlib/image.py","lineNumber":182,"sourceCode":"    \"\"\"\n    Convenience wrapper around `._image.resample` to resample *data* to\n    *out_shape* (with a third dimension if *data* is RGBA) that takes care of\n    allocating the output array and fetching the relevant properties from the\n    Image object *image_obj*.\n    \"\"\"\n    # AGG can only handle coordinates smaller than 24-bit signed integers,\n    # so raise errors if the input data is larger than _image.resample can\n    # handle.\n    msg = ('Data with more than {n} cannot be accurately displayed. '\n           'Downsampling to less than {n} before displaying. '\n           'To remove this warning, manually downsample your data.')\n    if data.shape[1] > 2**23:\n        warnings.warn(msg.format(n='2**23 columns'))\n        step = int(np.ceil(data.shape[1] / 2**23))\n        data = data[:, ::step]\n        transform = Affine2D().scale(step, 1) + transform\n    if data.shape[0] > 2**24:\n        warnings.warn(msg.format(n='2**24 rows'))\n        step = int(np.ceil(data.shape[0] / 2**24))\n        data = data[::step, :]\n        transform = Affine2D().scale(1, step) + transform\n    # decide if we need to apply anti-aliasing if the data is upsampled:\n    # compare the number of displayed pixels to the number of\n    # the data pixels.\n    interpolation = image_obj.get_interpolation()\n    if interpolation in ['antialiased', 'auto']:\n        # don't antialias if upsampling by an integer number or\n        # if zooming in more than a factor of 3\n        pos = np.array([[0, 0], [data.shape[1], data.shape[0]]])\n        disp = transform.transform(pos)\n        dispx = np.abs(np.diff(disp[:, 0]))\n        dispy = np.abs(np.diff(disp[:, 1]))\n        if ((dispx > 3 * data.shape[1] or\n                dispx == data.shape[1] or\n                dispx == 2 * data.shape[1]) and\n            (dispy > 3 * data.shape[0] or","sourceCodeStart":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/matplotlib/matplotlib/blob/b379c1b69e012b142c0f496a52bcb30513802d72/lib/matplotlib/image.py#L164-L200","documentation":"The row-side twin of the column check in matplotlib's _resample helper: the AGG renderer needs coordinates to fit 24-bit signed integers, so an image array with more than 2**24 (16,777,216) rows cannot be displayed accurately. matplotlib warns and decimates the rows with an integer step (data[::step, :]) while adding a compensating Affine2D(1, step) to the transform. The column budget is lower (2**23).","triggerScenarios":"ax.imshow(A) where A.shape[0] > 2**24 - e.g. tens of millions of scan lines, a full-depth volumetric slice, or a stacked time-series raster; any draw path that routes through _resample with an extremely tall array.","commonSituations":"Instrument/telemetry captures with tens of millions of rows; concatenating many rasters vertically before plotting; plotting raw sensor streams without decimation.","solutions":["Downsample before plotting: step = int(np.ceil(A.shape[0] / 2**24)); ax.imshow(A[::step, :], extent=(0, A.shape[1], A.shape[0], 0)).","Use block statistics (mean or min/max pooling over row blocks) so thin features survive the reduction.","Slice to the region of interest instead of passing the full-height array to imshow."],"exampleFix":"# before\nax.imshow(tall)               # tall.shape == (20_000_000, 500)\n\n# after\nstep = int(np.ceil(tall.shape[0] / 2**24))\nax.imshow(tall[::step, :], extent=(0, tall.shape[1], tall.shape[0], 0))","handlingStrategy":"validation","validationCode":"import numpy as np\n\ndef fit_agg_limits(data):\n    h, w = data.shape[:2]\n    if h > 2**24:\n        data = data[::int(np.ceil(h / 2**24)), :]\n    if w > 2**23:\n        data = data[:, ::int(np.ceil(w / 2**23))]\n    return data","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Decimate or block-reduce tall arrays (rows > 16.7M) before plotting.","Pass extent=(0, ncols, nrows, 0) so decimated pixels keep true data coordinates.","Window the plot to the region of interest instead of rendering the full capture."],"tags":["matplotlib","image","imshow","downsampling","userwarning"],"backgroundTag":"large-array-downsampling","analyzedSha":"b379c1b69e012b142c0f496a52bcb30513802d72","analyzedAt":"2026-08-21T23:31:55.468Z","schemaVersion":2},"datasetVersion":"2026-08-22T04:17:13.399Z"}