与matplotlib中的matlab的imagesc等效吗? [英] Equivalent to matlab's imagesc in matplotlib?

查看:585
本文介绍了与matplotlib中的matlab的imagesc等效吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从Matlab的背景开始学习Python,numpy和matplotlib.我一直使用的Matlab函数之一是imagesc.在matplotlib中的某个地方有与此完全相同的东西吗?我知道imshowpcolor,但是第一个不允许您轻松设置imagesc之类的轴单位,第二个使您可以设置坐标的边界的x坐标和y坐标.像素,而不是像素中心,我觉得这不直观.

I am coming to Python and numpy and matplotlib from a Matlab background. One function in matlab that I use all the time is imagesc. Is there an exact equivalent to this somewhere in matplotlib? I know about imshow and pcolor, but the first doesn't allow you to easily set the units of the axes like imagesc, and the second makes you set the x- and y-coordinates of the boundaries of the pixels, rather than the centers of the pixels, which I do not find intuitive.

基本上,如果我要显示的图像带有x和y轴标签,这些标签不是像素数而是数字,例如以mm为单位的距离,那么在matplotlib中最简单的方法是什么?

Basically, if I have an image that I want to display with x- and y-axis labels that are not pixel numbers but are numerical, like distance in mm, what is the easiest way to do it in matplotlib?

推荐答案

您要

You want the extent kwarg

ax.imshow(data, extent=[0, 1, 0, 1])

有关更详细的示例,请参见 Imshow:范围和方面.

See Imshow: extent and aspect for a more detailed example.

这篇关于与matplotlib中的matlab的imagesc等效吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆