我是Python的初学者。我相信Python会为3D等高线图执行此任务。 我有以下数据
Y/X (mm), 0, 10, 20, 30, 40
686.6, -5.02, -0.417, 0, 100.627, 0
694.08, -5.02, -4.529, -17.731, -5.309, -3.535
701.56, 1.869, -4.529, -17.731, -5.309, -3.535
709.04, 1.869, -4.689, -17.667, -5.704, -3.482
716.52, 4.572, -4.689, -17.186, -5.704, -2.51
724, 4.572, -4.486, -17.186, -5.138, -2.51
731.48, 6.323, -4.486, -16.396, -5.138, -1.933
738.96, 6.323, -4.977, -16.396, -5.319, -1.933
746.44, 7.007, -4.251, -16.577, -5.319, -1.688
753.92, 7.007, -4.251, -16.577, -5.618, -1.688
761.4, 7.338, -3.514, -16.78, -5.618, -1.207
768.88, 7.338, -3.514, -16.78, -4.657, -1.207
776.36, 7.263, -3.877, -15.99, -4.657, -0.822
任何帮助如何开始..
更新问题
(1)正如您可以看到的原始数据,它们分别在第1行,第1列中有xlabel和ylabel。 如果我使用numpy.loadtxt函数,如何拆分“xs”和“ys”?
data = numpy.loadtxt('131014-data-xy-conv-1.txt')
(2)您是否有想要旋转矩阵M x N?
(3)linepace有start = -70和stop = 60,num = 60,你知道怎么做第5步吗?
contour = subplot.contourf(xs, ys, data, levels=numpy.linspace(-70, 60, 60))
答案 0 :(得分:0)
您可以使用matplotlib
,即其contourf
功能:
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import numpy
xs = numpy.array([0, 10, 20, 30, 40])
ys = numpy.array([686.6, 694.08, 701.56, 709.04, 716.52,
724, 731.48, 738.96, 746.44, 753.92, 761.4, 768.88, 776.36])
data = numpy.array([
[-5.02, -0.417, 0, 100.627, 0],
[-5.02, -4.529, -17.731, -5.309, -3.535],
[1.869, -4.529, -17.731, -5.309, -3.535],
[1.869, -4.689, -17.667, -5.704, -3.482],
[4.572, -4.689, -17.186, -5.704, -2.51],
[4.572, -4.486, -17.186, -5.138, -2.51],
[6.323, -4.486, -16.396, -5.138, -1.933],
[6.323, -4.977, -16.396, -5.319, -1.933],
[7.007, -4.251, -16.577, -5.319, -1.688],
[7.007, -4.251, -16.577, -5.618, -1.688],
[7.338, -3.514, -16.78, -5.618, -1.207],
[7.338, -3.514, -16.78, -4.657, -1.207],
[7.263, -3.877, -15.99, -4.657, -0.822]])
fig = plt.figure()
subplot = fig.add_subplot(111, xlabel='$x$, mm', ylabel='$y$, mm')
contour = subplot.contourf(xs, ys, data, levels=numpy.linspace(-20, 120, 20))
subplot.set_xlim((xs[0], xs[-1]))
subplot.set_ylim((ys[0], ys[-1]))
fig.colorbar(contour)
fig.savefig('t.png')
您可以看到matplotlib
能够here的内容。