所以我在python中有此代码
Lemma hForall_inv'
(a : A)
(ls : list A)
(x : B a)
(hl : hlist ls)
: hForall (HCons x hl) -> P a x.
Proof.
intros H.
change (match HCons x hl return Prop with (* for some reason you have to explicitly annotate the return type as Prop right here *)
| HNil => True
| HCons x _ => P _ x
end).
destruct H.
- exact I. (* Replace [HCons x hl] with [HNil], the goal reduces to [True]. (This is an unreachable case.) *)
- assumption.
(* Or, directly writing down the proof term. *)
Restart.
intros H.
refine (match H in @hForall As hs return
match hs return Prop with
| HNil => True
| HCons x _ => P _ x
end
with
| hForall_nil => I
| hForall_cons _ _ _ _ => _
end).
assumption.
Qed.
当我编译它时,应该以我创建的零网格(M)覆盖整个区域,但相反,它覆盖了其中的一部分
我在这里做错了什么?
答案 0 :(得分:1)
我认为您在创建矩阵时只是感到困惑。
当您可能打算创建具有1900行和490列的矩阵时,您正在创建具有490行和1900列的矩阵。
只需更改定义矩阵M
的顺序即可解决您的问题:
import numpy as np
import matplotlib.pyplot as plt
M = np.zeros((1900, 490)) # change is here
fig, ax = plt.subplots()
plt.imshow(M, aspect='auto')
ax.set_ylabel('f2')
ax.set_xlabel('f1')
plt.xlim((0, 490))
plt.ylim((0, 1900))
x_range = np.arange(0, 490, step=50)
x_strings = [str(x+190) for x in x_range]
plt.xticks(x_range, x_strings)
y_range = np.arange(0, 1900, step=200)
y_strings = [str(y+1710) for y in y_range]
plt.yticks(y_range, y_strings)
plt.colorbar()
plt.ioff()
plt.show()
哪种产量:
您当然也可以通过反转xlim
和ylim
来更改图限制。