使用matshow()比使用imshow()更好的动画质量。怎么改进呢?

时间:2017-01-28 12:59:42

标签: python arrays matplotlib imshow

我用matshow显示了一个数组,它工作正常,但现在我想尝试imshow。问题是,与matshow相比,imshow的质量确实很差。

我该如何解决这个问题?

Matshow:

matshow(array)

FIG 1

Imshow:

plt.imshow(array)

FIG 2

1 个答案:

答案 0 :(得分:13)

问题归因于interpolation

Matplotlib matshowimshow的包装器,因为它"将原点设置为'upper','interpolation'设置为'nearest','aspect'设置为相等。 "

因此,虽然matshow始终使用 final String name = gson.fromJson(response, JsonElement.class).getAsJsonArray() .get(index).getAsJsonObject() .get("terms").getAsJsonObject() .get("category").getAsJsonArray() .get(0).getAsJsonObject() .get("name").getAsJsonPrimitive() .getAsString(); System.out.println(name); ,但默认情况下interpolation="nearest"imshow。请注意,这与interpolation=None不同。

  • interpolation="none"使用matplotlib rc fileinterpolation=None变量中的插值集(在不同的matplotlib版本中可能会有所不同。)
  • image.interpolation不使用插值,与interpolation="none"
  • 相同

解决此问题的最安全方法是在两次调用中专门设置插值方法

"nearest"
相关问题