[Tutor] 3D plotting
Jack Lambert
jack.lambert at gmail.com
Mon May 29 16:40:19 EDT 2017
Hello!
I am very new to python and am using it for some astronomy data analysis.
What I am trying to is plot a 3D scatter plot of three variables that are
being read from a file. I've tried using code from other examples of 3d
plots but, having little idea how the code functions, I have had very
little luck. Here is the relevant code I am hoping to augment.
>
import numpy as np
import scipy as sp
import math
from astropy.io import fits
import matplotlib.pyplot as plot
from pylab import *
import matplotlib as mpl
from mpl_toolkits.mplot3d import Axes3D
def sread(infile):
hdulist = fits.open(infile)
tdata = hdulist[1].data
ra = tdata['ra'] # degrees
dec = tdata['dec'] # degree
p = tdata['parallax'] # mas
return ra,dec,p
ra,dec,p = sread('TgasSource_000-000-001.fits')
for i in range(len(ra)):
if ra[i] > 164 and ra[i] < 166 and dec[i] > 49 and dec[i] < 51 :
plot(ra[i],dec[i],'bo')
show()
>
so I'm hoping to plot ra and dec on the x and y axes with p on the z axis.
Any way you can give me an idea how to implement this?
Thanks!
More information about the Tutor
mailing list