Can someone explain this matplotlib pcolormesh quirk?

前端 未结 1 446
清酒与你
清酒与你 2020-12-21 14:45

Plotting an array with pcolormesh with x and y data removes a row of the data

To illustrate what I mean, see the following:

data = np.random.random([         


        
相关标签:
1条回答
  • 2020-12-21 15:43

    The behaviour you see is expected. The pcolor documentation states for
    pcolor(X, Y, C, **kwargs):

    Ideally the dimensions of X and Y should be one greater than those of C; if the dimensions are the same, then the last row and column of C will be ignored.

    The same is of course true for pcolormesh.

    I'm not sure if this is the place to discuss whether this behaviour is a "quirk", but the underlying idea is that the grid defines the edges of the colored faces. Just as on a number line you have n numbers and n-1 intervals in between.

    It actually makes sense to define the edges by the grid, because pcolormesh also allows for unequally spaced grids which would be impossible to define otherwise.

    0 讨论(0)
提交回复
热议问题