Convert a string of numbers into a graph

In summary, the author is having trouble graphing an 8-tuple and is considering taking a python script and inserting commas before each whitespace and brackets around every 8 numbers and removing the white space...but is not sure if this is the best way to go about it. The author suggests plotting couples of triplets of data (2d or 3d representations), projecting the 8-dimension data into a 2-dimension plane, and using gnuplot to plot the data.
  • #1
Elwin.Martin
207
0

Homework Statement


This isn't actually a homework problem it's a problem I'm having in research since the fortran code I was given spat out a huge chunk of numbers. I've gotten the new-lines removed and I would like to graph what I have but it should really be organized in like 8-tuples.

I haven't used mathematica (for graphing) in a while and I'm not sure if I can even use it to graph an 8-tuple...It's 7 dependent variables and 1 dependent one.
[various parameters as a function of radius from the center of the galaxy]

Homework Equations


N/A


The Attempt at a Solution


I am considering taking a python script and inserting commas before each whitespace and brackets around every 8 numbers and removing the white space...but I don't know if I can just feed these into Mathematica or if I should be using another graphing utility...things will need to be on a log scale...

Ideas?
 
Physics news on Phys.org
  • #2
Well, you won't be able to plot an 8D graph! So you need to start out with some idea of how you'd go about graphing your 8-tuples by hand.
Then you can find the mathematica plotting function that automates that.

i.e. what you want the graph for dictates what you do.

Mathematica does have the ability to use a text file as a source of data so you are fine there.

Your representation would be an 8xN matrix, where the first row is your independent variable and you have N of them. If you just plot(x,y) the other 7 against the first row, you'd get 7 lines on a 2D graph. Of course, you can plot any pair of rows against each other.
 
  • #3
You may also use gnuplot, which uses directly text files.

As Simon said, unless you got a computer from the 9th dimension, you will have some difficulties plotting all the variables at the same time. Solutions include:
  • Plotting couples of triplets of data (2d or 3d representations)
  • Project your 8-dimension data into a 2-dimension plane

Without knowing more about the data you want to process, it is a bit difficult to give tailored advices.

J.
 
  • #4
jfgobin said:
You may also use gnuplot, which uses directly text files.

As Simon said, unless you got a computer from the 9th dimension, you will have some difficulties plotting all the variables at the same time. Solutions include:
  • Plotting couples of triplets of data (2d or 3d representations)
  • Project your 8-dimension data into a 2-dimension plane

Without knowing more about the data you want to process, it is a bit difficult to give tailored advices.

J.
I suppose I wasn't clear enough, sorry about that:
The data should be organized like this:
[itex](r,f_1(r),f_2(r),f_3(r),f_4(r),f_5(r),f_6(r),f_7(r),f_8(r))[/itex]
Currently it is in two forms:
1. A single string of all the numbers with varying white space and no commas or parens.
2. Sets of 16 with a '\n' [new line] after each set.

Though not really necessary, I'll mention that these are various parameters of AGN disks, as a function of radius, like Rosseland Mean Opacity.
 
  • #5
OK then, basically the same as before, but transposed:
... for N sample points (N-1 intervals) you'll end up with a Nx9 data matrix D.

$$D = \left [ \begin{array}{ccccc}
r_1 & f_1(r_1) & f_2(r_1) & \cdots & f_8(r_1)\\
r_2 & f_1(r_2) & f_2(r_2) & \cdots & f_8(r_2)\\
r_3 & f_1(r_3) & f_2(r_3) & \cdots & f_8(r_3)\\
\vdots & \vdots & \vdots & \ddots & \vdots\\
r_{N-1} & f_1(r_{N-1}) & f_2(r_{N-1}) & \cdots & f_8(r_{N-1})\\
r_N & f_1(r_N) & f_2(r_N) & \cdots & f_8(r_N)
\end{array} \right ]$$

How you get it into that form is up to you... and kinda depends on the organization of the current file.
I think mathematica can handle arbitrary space characters - what's important is it needs to know where the row/column breaks are for the matrix.
i.e. if the forst N numbers are all r, and the next N are f1, and the next N f2 etc, then you'll want to tell mathematical that.

Once you have the matrix D:
plot(D) will give you a graph with 8 lines, one for each ##f_n##.
 
Last edited:

Related to Convert a string of numbers into a graph

1. How do you convert a string of numbers into a graph?

To convert a string of numbers into a graph, you first need to determine the type of graph you want to create (e.g. bar graph, line graph, pie chart). Once you have selected the type of graph, you can use a software program or coding language to input the numbers and generate the graph.

2. What type of data is needed to create a graph?

The type of data needed to create a graph depends on the type of graph you want to create. For a bar graph, you will need numerical data for each category. For a line graph, you will need numerical data for both the x and y-axis. For a pie chart, you will need numerical data for each section of the chart.

3. Can you create a graph from non-numerical data?

No, a graph can only be created from numerical data. This is because graphs are used to visually represent numerical data and non-numerical data cannot be accurately represented in this way.

4. Are there any limitations to converting a string of numbers into a graph?

There are some limitations to converting a string of numbers into a graph. One limitation is that the accuracy of the graph depends on the accuracy of the data input. Another limitation is that some types of data may not be suitable for certain types of graphs (e.g. using a bar graph to represent time-series data).

5. Can you customize the appearance of a graph generated from a string of numbers?

Yes, you can customize the appearance of a graph generated from a string of numbers. Most software programs and coding languages allow you to change the colors, labels, and other design elements of a graph to suit your preferences or to make it more visually appealing.

Similar threads

  • Programming and Computer Science
Replies
2
Views
1K
  • Introductory Physics Homework Help
Replies
3
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
11
Views
5K
  • Precalculus Mathematics Homework Help
Replies
7
Views
1K
  • Programming and Computer Science
Replies
4
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
23K
  • Engineering and Comp Sci Homework Help
Replies
3
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
5
Views
8K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
0
Views
2K
Back
Top