Re: [astropy-dev] plotting data from astropy.table.table.Table using matplotlib

84 views
Skip to first unread message

Aldcroft, Tom

unread,
Mar 22, 2021, 2:53:50 PM3/22/21
to astropy-dev
Hi Lee,

Maybe this example will get you over the hill to having a plot:

In [1]: data = """obsid redshift  X      Y     object
   ...: 3102  0.32      4167  4085   Q1250+568-A
   ...: 877   0.22      4378  3892   "Source 82"
   ...: """                                                                    

In [2]: from astropy.table import Table                                        

In [3]: import matplotlib.pyplot as plt                                        

In [4]: %matplotlib  # Use "%matplotlib inline" in jupyter notebook
Using matplotlib backend: MacOSX

In [5]: t = Table.read(data, format='ascii')                                    

In [6]: plt.plot(t['X'], t['redshift'])                                        
Out[6]: [<matplotlib.lines.Line2D at 0x7fe97954dc10>]

image.png

Best,
Tom

On Mon, Mar 22, 2021 at 12:10 PM Lee Atkinson <lee.r.a...@gmail.com> wrote:
Hello,

I've stumbled upon and have started using astropy due to it being seemingly the only py module that supports reading from a tab formatted ascii file. 
After using ascii.read() to grab the data I want, I now run into the problem that I cant seem to figure out: how to plot the data (even with this information page https://docs.astropy.org/en/stable/visualization/matplotlib_integration.html).
My data table is pretty much analogous to the redshift table on this information page https://docs.astropy.org/en/stable/io/ascii/index.html?highlight=astropy.io.ascii (if that helps with context)

Help!

--
You received this message because you are subscribed to the Google Groups "astropy-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to astropy-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/astropy-dev/0692d0eb-f821-425c-869f-af967b66f758n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages