Building a Plot with Array Data: A Challenge

Click For Summary

Discussion Overview

The discussion revolves around the challenge of building a plot in real time using array data in Mathematica. Participants explore how to effectively use arrays for plotting, specifically addressing issues with ListPlot and ListPlot3D functions, and the handling of data points and their values.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant describes a method to plot real-time data using arrays but encounters issues with ListPlot not reacting to their data.
  • Another participant asks for clarification on the programming language and requests to see any existing code.
  • A participant provides a code snippet suggesting the use of Transpose to plot points from two vectors but notes that errors occur due to the data structure.
  • Some participants suggest checking the structure of the arrays using Print[FullForm[]] to diagnose potential issues with data assignment.
  • One participant shares their experience with ListPlot3D, noting that the Z-axis does not reflect the order of input values and discusses the impact of very small or large values on plotting.
  • Another participant mentions that changing from ListPlot to ListPlot3D may require adjustments in data handling and shares a link to a related discussion about similar plotting issues in Mathematica.
  • There is a suggestion that scaling Z values could help with visualization, and an example is provided to demonstrate how to adjust the scale of Z values in the data.

Areas of Agreement / Disagreement

Participants express varying opinions on the best approach to plotting and the challenges faced with data values. There is no consensus on the specific solutions, and multiple viewpoints on handling the data and plotting techniques remain present.

Contextual Notes

Participants highlight limitations related to the handling of data structures and the effects of extreme values on plotting functionality. The discussion does not resolve these issues, leaving them open for further exploration.

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 1 ·
Replies
1
Views
3K
  • · Replies 4 ·
Replies
4
Views
7K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 12 ·
Replies
12
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 11 ·
Replies
11
Views
4K
  • · Replies 10 ·
Replies
10
Views
792
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K