Building a Plot with Array Data: A Challenge

AI Thread Summary
The discussion revolves around building real-time plots using arrays in Mathematica. The user is trying to plot values from two arrays, x and W, but encounters issues with the ListPlot function, particularly with transposing the arrays. Suggestions include ensuring both arrays are properly defined and using ListPlot with Transpose to plot the data correctly. Additionally, there are discussions about the challenges of using extremely small or large values in ListPlot3D, which can affect the visual output. Ultimately, scaling the z-values may help in achieving a clearer plot representation.
sukharef
Messages
54
Reaction score
0
Hello.
I've got an idea to build a plot in real time. What i want to do:
1) I've got a row (array) of numbers
2) for these numbers i calculate values of the expression i want to plot, put them into array,
3) use list plot or smth like that with the row and the array.
The question is : how can i build plot with my row and array? i didn't find how can i use arrays with plot, listplot etc. they don't react with my data.

Thank you in advance.
 
Physics news on Phys.org
What language / software are you working with?

Have you got any code so far?
 
Simon_Tyler said:
What language / software are you working with?

Have you got any code so far?

i use mathematica.

n = 100;
Array[x, n];
x[1] = 0;
For[p = 2, p <= n, p++, x[p] = x[1] + (2 \[Pi])/n];

Array[W, n];
For[p = 1, p <= n, p++,

...

W[p] = (2 \[Pi])^4/c Abs[\[Sigma]]^2
Abs[e/(2 \[Pi]^2) 1/Abs[v[[3]]]]^2
Norm[CrossProduct[k, (\[Omega] b v T - c^2 Q)]]^2;
];

ListPlot[W, x] <---- ?
 
I am guessing you have vectors x and W and you wish to plot points with the x coordinate from your W vector and your y coordinate from your x vector. If that is true then this might help.

x = {1, 2, 3}; W = {1, 2, 3}; ListPlot[Transpose[{W,x}], PlotStyle -> PointSize[0.05]]

Once you see this working and if you have enough points in your own vectors you can remove the ,PlotStyle->PointSize[0.05] or adjust the .05 to make the points the size you wish.
 
Bill Simpson said:
I am guessing you have vectors x and W and you wish to plot points with the x coordinate from your W vector and your y coordinate from your x vector. If that is true then this might help.

x = {1, 2, 3}; W = {1, 2, 3}; ListPlot[Transpose[{W,x}], PlotStyle -> PointSize[0.05]]

Once you see this working and if you have enough points in your own vectors you can remove the ,PlotStyle->PointSize[0.05] or adjust the .05 to make the points the size you wish.
i have these erros
Transpose::nmtx: The first two levels of the one-dimensional list \
{W,x} cannot be transposed. >>
ListPlot::lpn: Transpose[{W,x}] is not a list of numbers or pairs of \
numbers. >>
 
Show us this:

Print[FullForm[x]]

and then

Print[FullForm[W]]

I am guessing either W or x is not a list or has not been assigned a value.
 
Bill Simpson said:
Show us this:

Print[FullForm[x]]

and then

Print[FullForm[W]]

I am guessing either W or x is not a list or has not been assigned a value.

i decided to put all figures i need by my hands. it's my business and it's not so hard to dp. whatever...
here is an example of my listplot 3d:

data = List[{5.71199, 0.856798, 2.88706*10^-47}, {5.71199, 0.571199,
4.5452*10^-47}, {5.71199, 0.285599, 1.36553*10^-47}, {5.14079,
2.85599, 3.71906*10^-47}, {5.1, 2.85, 3.7*10^-47}];
ListPlot3D[data]

but i get nothing :

[PLAIN]http://i074.radikal.ru/1108/c9/4faa1c86be13.jpg

then i add the option DataRange:

ListPlot3D[data, DataRange -> All]

[PLAIN]http://s47.radikal.ru/i115/1108/cb/e237f2f6dc7b.jpg

i get the picture. but as you can see the Z axis has no order of figures i posted.

first of all i decreased the figures order to -35. and guess what i get a picture without any additional options.

data = List[{5.71199, 0.856798, 2.88706*10^-35}, {5.71199, 0.571199,
4.5452*10^-35}, {5.71199, 0.285599, 1.36553*10^-35}, {5.14079,
2.85599, 3.71906*10^-35}, {5.1, 2.85, 3.7*10^-35}];
ListPlot3D[data]

[URL]http://i020.radikal.ru/1108/2e/6811bd1912ce.jpg[/URL]

i don't think that somehow mathematica realized that my figures are too small for her and decided not to build a plot. what do you think it is?
 
Last edited by a moderator:
Sometimes just entering the data is the most efficient way to get an answer.

Changing from ListPlot to ListPlot3D would require changes to my example to automate your data handling.

By coincidence someone else posted elsewhere a few days ago about ListPlot3D failing when some of the values were extremely large or extremely small.

http://groups.google.com/group/comp.soft-sys.math.mathematica/browse_thread/thread/d3c7f16ff3a8f345#

When I remove the *10^-47 from all your z values I get something similar to your second plot.

I expect someone at Wolfram will take a look at this. I do not know whether they will think it is important enough to fix or not.
 
Last edited:
Bill Simpson said:
Sometimes just entering the data is the most efficient way to get an answer.

Changing from ListPlot to ListPlot3D would require changes to my example to automate your data handling.

By coincidence someone else posted elsewhere a few days ago about ListPlot3D failing when some of the values were extremely large or extremely small.

http://groups.google.com/group/comp.soft-sys.math.mathematica/browse_thread/thread/d3c7f16ff3a8f345#

When I remove the *10^-47 from all your z values I get something similar to your second plot.

I expect someone at Wolfram will take a look at this. I do not know whether they will think it is important enough to fix or not.

you know, if for Math the order is so important i can decrease it by writing addtional program. For me is more important to see the surface. so all these math bugs are **** details =)
 
  • #10
Trying to plot a surface with only five data points almost certainly doesn't give any idea how well it will plot your surface if you have lots of points reasonably spread across the surface.

You might not need to write another program if you just need to scale your z value.

Perhaps this can show you how to scale z by 100.

In[6]:= data={{a,b,1*10^-47},{d,e,2*10^-47},{g,h,1.5*10^-47}};newdata=Map[#*{1,1,10^47}&,data]

Out[7]= {{a,b,1},{d,e,2},{g,h,1.5}}

You can change the scale factor for z to suit your problem
 

Similar threads

Replies
5
Views
2K
Replies
12
Views
4K
Replies
1
Views
2K
Replies
1
Views
1K
Replies
11
Views
4K
Replies
10
Views
556
Replies
2
Views
2K
Back
Top