6
$\begingroup$

I want to show plots in Dataset. Something like this

Table[<|"a" -> 
    ListPlot[RandomReal[1, 10], Frame -> True, ImageSize -> 200],
   "b" -> 
    ListLinePlot[RandomReal[1, 10], Frame -> True, 
     ImageSize -> 200]|>, {i, 1, 5}] // Dataset

will give

enter image description here

You can see

  1. the Frame is not showing
  2. ImageSize is not working

How to correctly show plots in Dataset?

$\endgroup$
3
  • $\begingroup$ e.g., ds[5, 2] // Normal indicates that it has been stored correctly and the Frame is also there. A related discussion on dataset formatting is here $\endgroup$
    – Syed
    Commented Nov 15, 2021 at 4:02
  • $\begingroup$ @Syed Thank you, I came up with a solution $\endgroup$
    – matheorem
    Commented Nov 15, 2021 at 5:01
  • $\begingroup$ I learned a new feature. Thanks. $\endgroup$
    – Syed
    Commented Nov 15, 2021 at 5:04

1 Answer 1

6
$\begingroup$

I came up with a solution using ItemDisplayFunction

Define

data=Table[<|
"a"->ListPlot[RandomReal[1,10],Frame->True,ImageSize->200],
"b"->ListLinePlot[RandomReal[1,10],Frame->True,ImageSize->200]|>,{i,1,5}];

then

dset=Dataset[data, ItemDisplayFunction -> (StandardForm[#] &)]

enter image description here

However, if we select two rows,

dset[[{1,2}]]

still gives

enter image description here

For this, I can only solve it awkwardly by Normal and Dataset again like

Dataset[Normal@dset[[{1,2}]],ItemDisplayFunction -> (StandardForm[#] &)]

gives

enter image description here

$\endgroup$
2
  • $\begingroup$ You can use SetOptions to include that option everytime you use Dataset. For example: SetOptions[Dataset, ItemDisplayFunction -> (StandardForm[#] &)] or SetOptions[Dataset, ItemDisplayFunction -> (Pane[#] &)] $\endgroup$
    – chuy
    Commented Nov 16, 2021 at 17:13
  • $\begingroup$ @chuy Hi. Thank you for reply. It would be a much better solution. However, I tried your solution, it didn't work $\endgroup$
    – matheorem
    Commented Nov 17, 2021 at 0:12

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.