# Plot in real time

1. Aug 20, 2011

### sukharef

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.

2. Aug 20, 2011

### Simon_Tyler

What language / software are you working with?

Have you got any code so far?

3. Aug 21, 2011

### sukharef

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] <---- ?

4. Aug 21, 2011

### Bill Simpson

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.

5. Aug 21, 2011

### sukharef

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. >>

6. Aug 21, 2011

### Bill Simpson

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.

7. Aug 21, 2011

### sukharef

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 :

then i add the option DataRange:

ListPlot3D[data, DataRange -> All]

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]

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: May 5, 2017
8. Aug 21, 2011

### Bill Simpson

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.

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: Aug 21, 2011
9. Aug 22, 2011

### sukharef

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. Aug 22, 2011

### Bill Simpson

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