Convert a string of numbers into a graph

Click For Summary

Discussion Overview

The discussion revolves around the challenge of converting a string of numerical data into a graph, specifically focusing on organizing the data into 8-tuples for visualization. The context includes research applications rather than a traditional homework problem, with an emphasis on using software tools like Mathematica and gnuplot for graphing multidimensional data.

Discussion Character

  • Technical explanation
  • Exploratory
  • Homework-related

Main Points Raised

  • One participant describes the need to organize a large string of numbers into 8-tuples, consisting of 7 dependent variables and 1 independent variable, for graphing purposes.
  • Another participant suggests that plotting an 8D graph is not feasible and recommends plotting pairs of the data instead, proposing the use of an 8xN matrix format for the data.
  • A suggestion is made to use gnuplot, which can directly utilize text files for plotting, and to consider projecting the 8-dimensional data into a 2D plane.
  • Further clarification is provided about the data organization, indicating that the data is currently in a single string or in sets of 16 with new lines, and that it pertains to parameters of AGN disks as a function of radius.
  • Another participant reiterates the need to transpose the data into a matrix format and discusses the importance of knowing the row/column breaks for proper input into Mathematica.

Areas of Agreement / Disagreement

Participants generally agree on the challenges of visualizing 8-dimensional data and propose various methods for simplifying the representation. However, there is no consensus on the best approach or specific software to use, as different tools and methods are suggested.

Contextual Notes

Limitations include the need for clarity on how to handle varying whitespace in the data and the specific organization of the current file, which affects how the data can be processed for graphing.

Elwin.Martin
Messages
202
Reaction score
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
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.
 
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.
 
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:
(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))
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.
 
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:

Similar threads

  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
1K
Replies
11
Views
5K
Replies
2
Views
2K
Replies
4
Views
5K
  • · Replies 1 ·
Replies
1
Views
24K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 34 ·
2
Replies
34
Views
7K