Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/329.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python中的MaSt秀,具有在正方形中间生成刻度的范围 下面的代码生成一个矩阵图,每个方块在中间用1到39的索引: import numpy as np from matplotlib import pyplot as plt a=np.random.uniform(0,1,1600).reshape((40,40)) fig, ax = plt.subplots(1,1) ax.matshow(a, vmin = 0, vmax = 1, interpolation = 'none') label_list=np.arange(0,40,5) label_list=np.append(label_list,39) ax.set_xticks(label_list) ax.set_yticks(label_list) plt.show()_Python_Matplotlib - Fatal编程技术网

Python中的MaSt秀,具有在正方形中间生成刻度的范围 下面的代码生成一个矩阵图,每个方块在中间用1到39的索引: import numpy as np from matplotlib import pyplot as plt a=np.random.uniform(0,1,1600).reshape((40,40)) fig, ax = plt.subplots(1,1) ax.matshow(a, vmin = 0, vmax = 1, interpolation = 'none') label_list=np.arange(0,40,5) label_list=np.append(label_list,39) ax.set_xticks(label_list) ax.set_yticks(label_list) plt.show()

Python中的MaSt秀,具有在正方形中间生成刻度的范围 下面的代码生成一个矩阵图,每个方块在中间用1到39的索引: import numpy as np from matplotlib import pyplot as plt a=np.random.uniform(0,1,1600).reshape((40,40)) fig, ax = plt.subplots(1,1) ax.matshow(a, vmin = 0, vmax = 1, interpolation = 'none') label_list=np.arange(0,40,5) label_list=np.append(label_list,39) ax.set_xticks(label_list) ax.set_yticks(label_list) plt.show(),python,matplotlib,Python,Matplotlib,当我想将数字更改为介于0和1.95之间或基本上[0,39]*0.05时,标签会收缩到轴的开头。如果我尝试在matshow中使用区段,则标签不会指向正方形的中间!如何使此浮动索引指向正方形的中间?在不更改刻度的情况下更改刻度标签。这似乎有效!非常感谢。 import numpy as np from matplotlib import pyplot as plt a=np.random.uniform(0,1,1600).reshape((40,40)) fig, ax = plt.subplo


当我想将数字更改为介于
0
1.95
之间或基本上
[0,39]*0.05
时,标签会收缩到轴的开头。如果我尝试在
matshow
中使用区段,则标签不会指向正方形的中间!如何使此浮动索引指向正方形的中间?

在不更改刻度的情况下更改刻度标签。这似乎有效!非常感谢。
import numpy as np
from matplotlib import pyplot as plt

a=np.random.uniform(0,1,1600).reshape((40,40))
fig, ax = plt.subplots(1,1)
ax.matshow(a, vmin = 0, vmax = 1, interpolation = 'none')
tick_list = np.append(np.arange(0,40,5), 39)
label_list=map(lambda x: str(0.05*x), tick_list)
ax.set_xticks(tick_list)
ax.set_xticklabels(label_list)
ax.set_yticks(tick_list)
ax.set_yticklabels(label_list)
plt.show()