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

In summary: Try going to the Math'ca website (F1 on the keyboard) and looking for "new in 6" to see if there's a download link there.In summary, the researcher is trying to replicate the CFA Redshift Survey in a polar graph plot. They found the .dat file that has the most recent information, but the process of importing the data and plotting the points is a pain. Anyone have any ideas?
  • #1
Ai52487963
115
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
  • #2
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.
 
  • #3
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?
 
  • #4
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.
 
  • #5
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" [Broken]. 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:
  • #6
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: 688
Last edited:
  • #7
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:
  • #8
I tried doing what you suggested, but http://img216.imageshack.us/img216/2928/asdfwz1.jpg" [Broken]. 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:
  • #9
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: 573
  • #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!
 

What is the process of plotting data in Mathematica?

The process of plotting data in Mathematica involves first importing or entering the data into a Mathematica notebook, then using the built-in ListPlot or Plot functions to create a visual representation of the data. Additional customization options such as labels, axes, and styling can also be applied.

Can I plot multiple datasets in one graph using Mathematica?

Yes, Mathematica allows you to plot multiple datasets on one graph by using the Show function or by using curly brackets to enclose the different datasets within the ListPlot or Plot functions.

How can I customize the appearance of my plot in Mathematica?

There are many options for customizing the appearance of your plot in Mathematica. You can change the color, style, and size of the plot markers, adjust the axes and labels, add a title and legend, and even add mathematical functions or other graphics to your plot.

Can I export my plotted data from Mathematica to other file formats?

Yes, Mathematica allows you to export your plotted data to a variety of file formats, including PDF, PNG, SVG, and more. This can be done by using the Export function and specifying the desired file format.

Are there any limitations to plotting data in Mathematica?

While Mathematica offers a wide range of plotting capabilities, there may be some limitations depending on the complexity of your data and the type of plot you are trying to create. It is always best to consult the Mathematica documentation or online resources for tips and workarounds if you encounter any difficulties.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
5
Views
4K
  • Programming and Computer Science
Replies
18
Views
5K
  • Precalculus Mathematics Homework Help
Replies
2
Views
4K
Back
Top