- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在尝试设置等高线图,但该图最终看起来像这样:
。
我认为这是因为 y 轴大约有 10 到 80 个单位,而 x 只有 4 到 9 个单位,并且网格是方形的,因此每个单位在 x 和 y 轴上的缩放比例相同。如何更改 x 轴的缩放比例以使其成为可用的图像?
import numpy as np
import matplotlib.pyplot as plt
import time as time
from scipy.interpolate import griddata
x = np.array([3.98, 3.98, 3.99, 3.98, 6.02, 6.05, 6.03, 6.04, 10.01, 10.07, 10.09, 10.1])
y = np.array([79.5, 40, 20.07, 10.04, 79.67, 40.08, 20.23, 10.01, 79.42, 39.63, 20.14, 10.11])
z = np.array([38.82697111, 34.61715402, 22.46052757, 13.51888155, 48.52466738, 42.1140194, 28.37788811, 16.48901657, 55.40461783, 46.88792485, 33.66091083, 20.9200696])
extent = (min(x), max(x), min(y), max(y))
xs,ys = np.mgrid[extent[0]:extent[1]:30j, extent[2]:extent[3]:30j]
resampled = griddata((x, y), z, (xs, ys))
plt.figure(figsize=(8,8))
plt.imshow(resampled.T, extent=(min(x), max(x), max(y), min(y)),interpolation='bicubic')
plt.contour(resampled.T, extent=(min(x), max(x), max(y), min(y)),interpolation='bicubic',origin='upper')
plt.hold(True)
plt.scatter(x,y,c=z)
plt.gca().invert_yaxis()
plt.colorbar()
plt.show()
最佳答案
只需手动设置 aspect
关键字即可:
plt.imshow(resampled.T, extent=(min(x), max(x), max(y), min(y)),interpolation='bicubic', aspect=0.1)
或者使用auto
选项:
plt.imshow(resampled.T, extent=(min(x), max(x), max(y), min(y)),interpolation='bicubic', aspect='auto')
另一种选择是使用pcolormesh()
关于python - 调整网格 xy 比例等值线图 matplotlib,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38070067/
我已经上传了一个 shapefile here . #First, read it in library(rgdal) pols % mutate(id = as.numeric(id)) #some
我正在尝试制作分区统计图,但如何设置 map 的大小?现在我有了这张 map : 我想将 map 扩展到所有空间,我阅读了文档,但没有找到解决方案。 这是我的代码: var data = [{
我有一张美国各州的分区统计图,使用分位数比例显示总人口。我还设置了一个下拉菜单,允许用户使用 colorbrewer 定义的配色方案来选择自己选择的配色方案。选择后, map 将填充新的配色方案。 我
我正在使用 d3(更像是学习使用)来创建等值线图。我已经设法加载我的数据和 geojson 对象并获得要显示的 map ,但我想添加一些转换和用户选择数据的能力。 这是我目前所拥有的示例(感谢 git
我已经包含了下面的 html 代码,其中导入了 dc.js 的 javascript 和 css。当我加载页面时,所有元素都位于正确的位置。当我选择一个县路径元素并取消选择 fill:none css
我是一名优秀的程序员,十分优秀!