Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have created a list in Mathematica and for some reason it does not want to Plot my list in pairs {x1,y1}, but instead does {y1,y2} even though I partitioned the list to make it in the correct format. Here is the code:

Dynamic[h = w[1.1][[All, 2]] + w[2.1][[All, 2]] + w[3.1][[All, 2]] + 
   w[4.1][[All, 2]] + w[5.1][[All, 2]] + w[6.1][[All, 2]] + w[7.1][[All, 2]] + 
   w[8.1][[All, 2]] + w[9.1][[All, 2]] + w[10.1][[All, 2]]]
k = Table[l + Pi/50, {l, -Pi/50, 49 Pi/50, Pi/50}]
Dynamic[List[p = Riffle[k, h/g]]]
Dynamic[Partition[p, 2]]

The first line takes previously made lists and adds the value of their second column -> (x1, y1) and (x2,y2) returns y3 where y3 = y1+y2. Then a new table from 0 to Pi is created. Then a new list is made, p, with riffle to make x-values go from 0 to Pi and y values are the values from table h. Then the values are partitioned into pairs (x1,y1). Finally, the list should be plotted. But again, Mathematica does (y1,y2,...) and not in pairs.

Little help? Thanks.

g is a constant between 1 and 10. Below is Full Form p.

share|improve this question
What is g? In any case not possible to answer without seeing p. Please evaluate FullForm[p] and add it to the question. – Mike Honeychurch Jan 25 '13 at 0:32
Using the definition of p that you just added ListPlot[p] works in version 7 on Windows: – Mr.Wizard Jan 25 '13 at 0:38
The image just provided by Mr. Wizard is my problem. The values of Pi should be x-axis while the numerical values should be y values. – Omid Talaee Jan 25 '13 at 0:44
You are plotting p not the Partitioned expression. – Verbeia Jan 25 '13 at 0:58

You are plotting p not the Partitioned expression. Merge the last two lines to read Dynamic[ListPlot[Partition[p,2]]] and it should work. You might need to Reverse each row so the $y$ values are second:

Dynamic[ListPlot[Reverse/@ Partition[p,2]]]
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.