Mathematica Making a Polar Graph Plot in Mathematica: Replicating the CFA Redshift Survey

AI Thread Summary
The discussion revolves around replicating the CFA Redshift Survey using polar graph plotting in Math'ca after importing data from an Excel file. The user successfully imported the data but faced challenges in plotting it in polar coordinates. They received guidance on using the ListPolarPlot function, which can plot data points based on radial distance and angle. It was noted that the data might need transformation from sky coordinates (altitude, azimuth) to the appropriate (angle, radius) format for successful plotting. There were also troubleshooting tips regarding the syntax for importing data and the formatting of lists, including the significance of floating-point numbers in the output. The user suspected that their version of Mathematica (5.1) might lack certain functionalities available in newer versions, which could be causing their plotting issues.
Ai52487963
Messages
111
Reaction score
0
(not for homework, just for fun)

I'm doing research with my professor, and as an 'easy project' (har har) she gave me the task to replicate the CFA Redshift Survey in a polar graph plot. So with some clever googling I found the .dat file that has the most recent info in it, and I'm fairly confident I know which numbers to plot vs what and how to bound it and all, but the whole process of actually importing the data and plotting the points is a pain. Anyone have any ideas?
 
Physics news on Phys.org
Suppose you put the data into Excel.

In Math'ca type

data = Import[at which point go to Insert menu, then select File Path, then (in the dialog box) double-click on the Excel data file

then type ] to close the Import bracket.

The input line will look like:
data = Import["C:\\My Documents\\Excel file.xls"]

Put the cursor anywhere on the line and hit Shift+Enter.

Math'ca will take a second or two to read the data.

You will have created a Math'ca data table named data. For example, typing

data[[1]]

then shift+entering will print the first row of the data. (If that doesn't work, try data[[1,1]].) Likewise, data[[1,4]] (or data[[1,1,4]]) will print the 4th column on the first row.
 
Thank you x a billion, enuma, but now that I have my data in it, how would one plot this wackyness as a function of radial distance vs angle? eg, plotting data points in polar coordinates?
 
If you go to Math'ca help (F1 on the keyboard) then type "polar" as the search term, you'll see (among others):

ListPolarPlot[{r1, r2, ...}]
plots points equally spaced in angle at radii ri.

ListPolarPlot[{list1, list2, ...}]
plots several lists of values.
 
I guess I misspoke (mistyped?) when I said 'polar'. Pretty much I have to replicate http://cfa-www.harvard.edu/~huchra/2mass/images/cfa2.n30.gif" . I have the data, I just don't know how to fumble with the plotting tools, since excel doesn't fit the bill.

Does the ListPolarPlot function allow me to plot like in the link above?
 
Last edited by a moderator:
Carefully look at the examples under ListPolarPlot help.

ListPolarPlot[Table[Sqrt[n],{n,100}]] will produce a conch (spiral) pattern. Note that
Table[Sqrt[n],{n,100}] = {1., 1.41421, 1.73205, 2., 2.23607, 2.44949, 2.64575, 2.82843, 3., 3.16228, 3.31662, 3.4641, 3.60555, 3.74166, 3.87298, 4., 4.12311, ..., 10}. If your data look like these numbers, ListPolarPlot will produce this pattern.

ListPolarPlot[Table[{n,Log[n]},{n,500}]] will produce a starfish (?) pattern. Note Table[{n,Log[n]},{n,500}] = {{1, 0.}, {2, 0.693147}, {3, 1.09861}, {4, 1.38629}, {5, 1.60944}, ..., {500, 6.21461}}. If your data look like these pairs of numbers, then ListPolarPlot will produce this pattern.
 

Attachments

  • Clipboard01.jpg
    Clipboard01.jpg
    35.7 KB · Views: 746
Last edited:
Looking at the sky plot you posted, I suspect that your data are in sky coordinates (altitude, azimuth). If so, you need to transform your data points into an (angle, radius) representation before you plot them using ListPolarPlot.

In Math'ca help, the input line that produces the spiral pattern consists of a list of numbers. Math'ca interprets each of these numbers as a radius (and plots them with uniformly spaced angles).

The input line that produces the starfish pattern consists of a list of number pairs. Math'ca interprets the first element of each pair as an angle and the second element of the pair as a radius.

You may wish to post under the PF Astronomy forum for further help on this conversion.
 
Last edited:
I tried doing what you suggested, but http://img216.imageshack.us/img216/2928/asdfwz1.jpg" . I don't know where the periods after the x values keep coming from, since they're not in my excel spreadsheet, if that's the error.
 
Last edited by a moderator:
I see the problem, you have too many {}'s wrapped around your list.

When defining data, you don't need to wrap {} around Import[].

Try removing those and then see if it works.

The periods are harmless; they mean "floating point number" (as opposed to "integer" or "fraction"). It's a programming convention.
 
Last edited:
  • #10
fah! it keeps giving me the same output as before, even without the {}s. Thanks for your patience, by the way.
 
  • #11
Try inputting data and ListPolarPlot as separate input statements.

FYI, when I copy & paste your data points I can generate a real picture (see attached).
 

Attachments

  • Clipboard02.jpg
    Clipboard02.jpg
    16.1 KB · Views: 638
  • #12
I googled the ListPolarPlot function and it comes under a "new in 6" page. I have mathematica 5.1. I'm assuming its just some package thing I'm missing then...or...at least I hope it is!
 
  • #13
That would definitely explain it!
 
Back
Top