Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Bug]: matplotlib.pyplot.matshow "(first dimension of the array) are displayed horizontally" but are displayed vertically #27852

Closed
@tkuraku

Description

@tkuraku

Bug summary

matshow states that "(first dimension of the array) are displayed horizontally": https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.matshow.html#matplotlib-pyplot-matshow. However it seems that the first dimension is vertically.

Code for reproduction

import numpy as np
import matplotlib.pyplot as plt


nx = 15
ny = 21

img = np.zeros((nx, ny))

for i in range(nx):
    for j in range(ny):
        if j == i:
            img[i, j] = 1

plt.figure()
plt.subplot(1, 2, 1)
plt.imshow(img)
plt.title('imshow')
plt.subplot(1, 2, 2)
plt.matshow(img, fignum=0)
plt.title('matshow')
plt.show()

Actual outcome

First dimension is shown vertically

Expected outcome

I would expect that the first dimension be show horizontally according to the documentation.

Additional information

No response

Operating system

Debian 12

Matplotlib Version

3.8.0

Matplotlib Backend

module://matplotlib_inline.backend_inline

Python version

3.10.12

Jupyter version

No response

Installation

conda

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions