在唯一功能调用下的Matplotlib imshow中缩放轴 [英] Rescaling axis in Matplotlib imshow under unique function call

查看:164
本文介绍了在唯一功能调用下的Matplotlib imshow中缩放轴的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个函数模块,该函数模块接受两个变量的参数.要绘图,我有

I have written a function module that takes the argument of two variables. To plot, I had

x, y = pylab.ogrid[0.3:0.9:0.1, 0.:3.5:.5]
z = np.zeros(shape=(np.shape(x)[0], np.shape(y)[1]))

for i in range(len(x)):
    for j in range(len(y[0])):    
        z[i][j] = fancyFunction(x[i][0], y[0][j])

pylab.imshow(z, interpolation="gaussian")

我得到的图像如下:

The image I get is the following:

但是当我尝试重新缩放x和y轴以匹配通过[c0>的[0.3:0.9:0.1,0.:3.5:.5]的范围

But when I tried rescaling the x and y axis to match the ranges of [0.3:0.9:0.1, 0.:3.5:.5] thru pylab.imshow(z, interpolation="gaussian", extent=[.3,.9,0.,3.5]) I get

我已经搜寻了几个小时,但仍然找不到一种方法来绘制轴比例不同的正方形图.

I've been googling for hours but still couldn't find a way to make a square plot with differently scaled axis.

谢谢!

推荐答案

使用aspect参数:

pylab.imshow(z, interpolation="gaussian", extent = [.3,.9,0.,3.5], aspect='auto')

这篇关于在唯一功能调用下的Matplotlib imshow中缩放轴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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