animal[i][2] - will access numbers in your array (actually i-th element)

Combine those to get what you need. I dont have Mathematica here so I can not write a code, but if you dont succeed alone with this help I'll do it later :D

Solved

Posted on 2008-11-18

Hi,

I am a beginner of Mathematica. Now I have a question on drawing a diagram with some data in a List.

I have a 2-D List like this:

animal = { {Dog, 1}, {Cat, 2}, {Rabbit, 3}, ... }

How can I draw a line (ListLinePlot) with numbers in the List above only? In other words, I wish to draw a line with data 1, 2, 3, ... the names of animal can be ignored.

Thanks in advance for any help.

I am a beginner of Mathematica. Now I have a question on drawing a diagram with some data in a List.

I have a 2-D List like this:

animal = { {Dog, 1}, {Cat, 2}, {Rabbit, 3}, ... }

How can I draw a line (ListLinePlot) with numbers in the List above only? In other words, I wish to draw a line with data 1, 2, 3, ... the names of animal can be ignored.

Thanks in advance for any help.

8 Comments

animal[i][2] - will access numbers in your array (actually i-th element)

Combine those to get what you need. I dont have Mathematica here so I can not write a code, but if you dont succeed alone with this help I'll do it later :D

First, thanks for your help.

I have only data for y variable. The x axis just uses the natural number.

Given animal = { {Dog, 10}, {Cat, 20}, {Rabbit, 30}, ... }, the result diagram should be a line passing through {x, y} = {1, 10}, {2, 20}, {3, 30}, ...

```
animal = { {Dog, 1}, {Cat, 2}, {Rabbit, 3} }
myArray = {}
For[i=1, i<=Length[animal],i++,
AppendTo[myArray, {i, animal[[j,2]]}
]
ListPlot[myArray, PlotJoined->True]
(* or draw only points like this *)
ListPlot[myArray, PlotStyle->PointSize[0.05]
```

Title | # Comments | Views | Activity |
---|---|---|---|

Microsoft Dynamics Roles question | 4 | 28 | |

OST To PST Converter | 8 | 124 | |

Software - Posting same reply on multiple forums. | 4 | 41 | |

MDT 2013 (Microsoft Deployment Toolkit) Using Litetouch.vbs does not capture an image. | 8 | 75 |

This is about my first experience with programming Arduino.

Join the community of 500,000 technology professionals and ask your questions.

Connect with top rated Experts

**17** Experts available now in Live!