If I create a Dataset:

dataSet = Dataset[
  AssociationThread[{"a", "b", "c", "d", "e"} -> #] & /@ RandomReal[{-1, 1}, {1000, 5}]

It should be easy to use a plotting function on it

dataSet[ListContourPlot, {"a", "e", "c"}]

but all I get is the list of associations back.

Why does Dataset not plot my data query?

I don't understand why this happens, since if I replace ListContourPlot with, say ListPointPlot3D (these functions work on lists of triplets), it works fine. ListDensityPlot has the same problem. This doesn't seem to have anything to do with extreme ranges in my dataset, and I can't see anything wrong with the dataset itself; i.e., the following works fine:

  t = {
    Normal @ dataSet[All, "a"],
    Normal @ dataSet[All, "e"],
    Normal @ dataSet[All, "c"]

3 Answers 3


I think what you want is the following:

dataSet[ListContourPlot, {#a, #e, #c} &]

Mathematica graphics

dataSet[ListDensityPlot, {#a, #e, #c} &]

Mathematica graphics

If you still want to use the Keys directly then you'll have to force ListContourPlot and ListDensityPlot to extract only the Values as follows:

dataSet[ListContourPlot[Values@#] &, {"a", "e", "c"}]
  • $\begingroup$ @gpap That's what it looks like. I bet what's happening is that ListPointPlot3D was updated to work with Associations whereas ListContourPlot and ListDensityPlot weren't. $\endgroup$
    – RunnyKine
    Oct 8, 2014 at 13:31

The problem does not lie with Dataset, but rather with ListContourPlot:

$data =
  { <|"a"->0.846,"e"->0.770,"c"->0.682|>
  , <|"a"->0.211,"e"->-0.434,"c"->0.944|>
  , <|"a"->0.716,"e"->0.171,"c"->0.529|>

ListContourPlot @ $data

(* ListContourPlot[{ <|a->0.846,e->0.77,c->0.682|>,
     <|a->0.211,e->-0.434,c->0.944|>,<|a->0.716,e->0.171,c->0.529|>}] *)

The result is inert, showing that ListContourPlot does not operate upon associations. It is necessary to explicitly extract the values:

ListContourPlot @ Values @ $data

contour plot screenshot

ListPointPlot3D, by contrast, does operate upon associations:

ListPointPlot3D @ $data

3D plot screenshot

The documentation for ListPointPlot3D makes no mention of this capability.

The documentation for Association says...

Typical list operations (such as Map, Select, and Sort) apply to the values in an association, leaving the keys unchanged.

... and ...

Keys are "transparent" for many operations

... but it remains silent on the identity of those "many operations" beyond a few examples. Apparently ListPointPlot3D is one of those operations, but ListContourPlot is not. Perhaps it is rather that the internal implementation of ListPointPlot3D uses one of those "many operations", but the implementation of ListContourPlot does not.

So, for the moment at least, we must learn the set of "many operations" by experimentation.


Note that Dataset already has up-value wrapper definitions for many operators, including ListContourPlot. WRI certainly has the option of adjusting the wrapper definition of Dataset instead of making ListContourPlot handle associations, although the latter would seem to have more general applicability.

  • $\begingroup$ Thanks a lot for your answer - I accepted the one that was offered first but yours is equally illuminating (I have upvoted). I was just surprised that it worked with one plotting function and not another seeing as the input they take is pretty much the same (list of triplets). $\endgroup$
    – gpap
    Oct 9, 2014 at 11:12

I can't quite wrap my head around what a Dataset is, and why it does work with ListPointPlot3D. But as a workaround you can just use



  • $\begingroup$ Thanks. The reason I am asking is 'cause I am trying to understand how datasets work too. I think your workaround is more shorthand than anything I've used so far (so +1) but I am actually interested in the why so I'll wait to get a bit more insight on that $\endgroup$
    – gpap
    Oct 8, 2014 at 11:41
  • $\begingroup$ The FullForm of a Dataset shows a data part and the internal data structure spec. Sounds like Although it may change in future revs, current Dataset, Query etc are specialized interfaces unlike generic M code. $\endgroup$ Oct 8, 2014 at 18:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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