Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Plot in real time

  1. Aug 20, 2011 #1
    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.
  2. jcsd
  3. Aug 20, 2011 #2
    What language / software are you working with?

    Have you got any code so far?
  4. Aug 21, 2011 #3
    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] <---- ?
  5. Aug 21, 2011 #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.
  6. Aug 21, 2011 #5
    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. >>
  7. Aug 21, 2011 #6
    Show us this:


    and then


    I am guessing either W or x is not a list or has not been assigned a value.
  8. Aug 21, 2011 #7
    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}];

    but i get nothing :

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

    then i add the option DataRange:

    ListPlot3D[data, DataRange -> All]

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

    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}];


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


    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
  10. Aug 22, 2011 #9
    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 =)
  11. Aug 22, 2011 #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
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook