我有强度数据(扫描电镜.txt)我想通过将行重新指定为列来将图像旋转90度。Python给了我一个“代码分析无效语法”错误,它说“for m:”—我做错什么了?你知道吗
import numpy as np
import matplotlib.pyplot as plt
a=np.loadtxt("SEM.txt")
Intensity=np.loadtxt("SEM.txt")
Intensity[n,m]=Raw_Intensity
for m:
for n:
New_Intensity[m,n]=Raw_Intensity[n,m]
plt.imshow(New_Intensity)
你要做的是变换一个数组。直接使用转置。见numpy transpose
下面是我建议的演示
如果你想手动完成,那么你可以这样做。你知道吗
结果与只使用
numpy.transpose
相同,但需要更多的输入。你知道吗for循环语法不正确。你需要这样的东西
不过我很确定你可以用这样的列表来替换那些循环
假设你真的想这么做。。。。你知道吗
编辑
根据您上面关于需要使用for循环的评论,您可以这样做
相关问题 更多 >
编程相关推荐