Building a Plot with Array Data: A Challenge

In summary, you are trying to plot a graph of a set of numbers. However, you cannot seem to get the plot to work with your data.
  • #1
sukharef
54
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
  • #2
What language / software are you working with?

Have you got any code so far?
 
  • #3
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] <---- ?
 
  • #4
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
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. >>
 
  • #6
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
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:
  • #8
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:
  • #9
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
 

1. What is the purpose of building a plot with array data?

The purpose of building a plot with array data is to visually represent the relationship between multiple variables in a dataset. This allows for easier interpretation and analysis of the data.

2. How do I choose which type of plot to use for my array data?

The type of plot to use depends on the type of data and the relationship you want to show. For example, a scatter plot is useful for showing the correlation between two variables, while a bar graph is better for comparing different categories of data.

3. What is the difference between a one-dimensional and multi-dimensional array?

A one-dimensional array contains a single row or column of data, while a multi-dimensional array contains multiple rows and columns. Multi-dimensional arrays are often used for plotting data as they allow for visualization of relationships between multiple variables.

4. How can I customize my plot to make it more visually appealing?

There are many ways to customize a plot, such as changing the colors, fonts, and labels. You can also add titles, legends, and annotations to make the plot more informative and visually appealing.

5. Can I export my plot to use in a presentation or report?

Yes, most plotting libraries allow you to export your plot as an image or PDF file that can be easily inserted into presentations or reports. Some libraries also have built-in options for sharing plots on social media or embedding them on websites.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
985
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
12
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
261
  • Advanced Physics Homework Help
Replies
6
Views
625
  • MATLAB, Maple, Mathematica, LaTeX
Replies
10
Views
249
  • MATLAB, Maple, Mathematica, LaTeX
Replies
11
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
Back
Top