# ListPlot from DataSet

Let's say that I have the following Dataset:

ds = Dataset[
AssociationThread[{"A", "B"}, #] & /@ {{Range[10],
Sin[#] & /@ Range[10]}, {Range[10],
Cos[#] & /@ Range[10]}, {Range[10], Tan[#] & /@ Range[10]}}];


In column B, you have in each row respectively: Sin, Cos and Tan of the values that are in the same row of A.

How can do a ListPlot of those three rows in the most convenient way ?

• That's... a really weird format. Do you actually get a Dataset[] shaped like this in your actual problem? Apr 10 '18 at 14:30
• Can you consider re-formatting, eg to this? Range[10] // Map[<|"A" -> #, "B" -> Cos[#], "C" -> Sin[#], "D" -> Tan[#]|> &] // Dataset . Then you can plot pairs like: ds2[All, {"A", "B"} /* Values] // ListPlot Apr 10 '18 at 14:36
• @J.M. I agree. The reason: I am acquiring experimental data of a reflection spectrum of different samples. Each sample is specified by a set of parameters, like size, thickness etc. -> one number for each parameter. For each of those samples, I record the "wavelength" and the "reflection" -> those two are lists, for the wavelength from 400nm to 800nm and for the reflection you have a value between 0 and 1 depending on your wavelength. So basically I have a table where in the first columns there is only one number, and in the last two, there are lists. Apr 10 '18 at 15:19
• @J.M. I figured a way how to change the dataset structure. Apr 10 '18 at 15:29

## 1 Answer

Assuming that each row represents a list with x values (key A) and y values (key B), I would do something like this to get all data in 1 plot:

ListPlot[Transpose[{#A, #B}] & /@ ds]

• Great ! Thanks a lot ! Apr 10 '18 at 15:30