麻烦使用Matplotlib进行绘图

时间:2014-08-23 04:34:35

标签: python matplotlib

我再次道歉,如果已经发布并讨论过,但这是我从我的代码中得到的输出:

Traceback (most recent call last):
  File "photometry_V1283_Her.py", line 28, in <module>
    plt.scatter(xcoord,ycoord)
  File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 2550, in scatter
    ax = gca()
  File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 701, in gca
    ax =  gcf().gca(**kwargs)
  File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 369, in gcf
    return figure()
  File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 343, in figure
    **kwargs)
  File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py", line 80, in new_figure_manager
    window = Tk.Tk()
  File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1712, in __init__
    self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable

我正在Windows计算机上运行Xming,使用PuTTY在我的服务器上运行代码。这是我的代码:

import scipy.ndimage as snd
import pyfits
import aplpy
import matplotlib.pyplot as plt
import numpy as np

a1 = pyfits.open('final_processed1.fit')

Image_1 = a1[0].data

Image_1 = Image_1.reshape(Image_1.shape[2:])

threshold = Image_1.mean() + 2*Image_1.std()

print threshold

labels, num = snd.label(Image_1 > threshold, np.ones((3,3)))

centers = snd.center_of_mass(Image_1, labels, range(1, num + 1))

print centers

xcoord = [a[0] for a in centers]
ycoord = [a[1] for a in centers]

print xcoord,ycoord

plt.scatter(xcoord,ycoord)
plt.savefig('star_positions_V1283_Her.jpg')

它找到了图像中的所有星位,在这种情况下,是我正在研究的变星的V1283 Her的图像。我想绘制此代码的输出,该代码按原样打印:

[5.4528163019450888, 76.484683060846763, 96.25283577429451, 133.0, 164.82650590142723, 169.8320261305239, 177.98832604084942, 233.28232143914147, 239.0, 258.17815256468492, 257.02193435130732, 260.50503209293748, 261.02212680561541, 265.0, 279.0, 293.99894094320223, 297.0, 306.0, 330.60227293401715, 347.0, 409.0, 412.45866606520525, 431.01612522746746, 440.0, 457.0, 460.0, 461.83741684760963, 508.58063037685065]

作为x坐标,

[423.51536446140085, 757.97957285998814, 535.94001057710625, 641.0, 183.74640134087025, 264.83875681244996, 550.34113141774742, 265.81037713985006, 165.0, 375.58603732999728, 406.96129416111245, 76.0, 478.12486839424827, 458.0, 673.4953061140526, 508.99336986804775, 51.528063913624557, 327.0, 746.62083264590092, 347.93356549524702, 346.0, 327.13278979301151, 106.62161219292472, 345.0, 157.0, 578.0, 58.855805168101405, 459.94512381829935]

作为y坐标。

希望你们能帮忙, 布兰登

0 个答案:

没有答案