Is there a way to exert finer control Dataset Cell Coloration Like in Grid?

In Grid one can control the foreground and background color of specific cells, rows, and columns, whether initially or via computation. Although Dataset seems to use Grid intrinsically, from existing documentation and web resources I can as yet find no way to exert finer control on Dataset output. Is there a way to do this?

As an example,

header = Style[#, Bold, Background-> LightBlue]& @/{"A", "Header B", "FooBar C"};
data = {1, 2, 3}


Although I can use Style[#,Bold, Background-> Lightblue] as a function for my header column, only the background immediately surrounding the output text of the header has a LightBlue background, which does not fill the rest of the otherwise grayed cells, which remains filled with the color of the padding space (default gray).

Likewise, it would be desirable to be able to use different background colors for different categories (rows or columns) of data, both in the header and data files (ie key->value fields) or to change the look of different datasets or the coloration of merged datasets so that the colors correspond to those in the original datasets, thereby permitting visual recognition of different categories or sources of data in the tabular output of Dataset. Likewise, alternating background colors can often make it easier to read data with many columns and rows or highlight data of particular importance.

Perhaps an alternate way to ask this question is whether or not it possible to apply selectively Color Schemes to rows, column, cells of Datasets to accomplish this?

• Names["Dataset$*"] // TableForm shows a list of variables associated with the Dataset namespace, including Dataset$DatasetFrameColor and other potential formatting handles, but I don't see that my datasets look any different when I change the values of those namespace variables... – Josh Bishop Apr 18 '17 at 20:32
• There will be in version 12.1 – M.R. Nov 20 '19 at 17:42
• Look forward to that. I'm at 12.0.0 and ready to go as could much simplify both automation and flexibility hopefully as well as performance. – Stuart Poss Dec 22 '19 at 4:39

A partial answer to this problem can be found from the following example code:

ClearAll;
keys = {"Bank", "Jobs Transferred", "Destination", "Bank",
"Jobs Transferred", "Destination", "Bank", "Jobs Transferred",
"Destination", "Bank", "Jobs Transferred", "Destination", "Bank",
"Jobs Transferred", "Destination"};

values = {"JP Morgan", 5000, "Unknown",
"UBS", 2500, "Unknown",
"Morgan Stanley", 1000, "Frankfurt",
"Goldman Sachs", 1000, "Frankfurt",
"HBSC", 1000, "Paris"};

dataSet = Partition[Thread[keys -> values], 3];

Style[Dataset[KeyIntersection[dataSet]], Background -> LightBlue, ]


This resolves the problem with being unable to correctly color the background encountered previously for the values. However, still no solution to the problem here of making the background of the header (key) row a different color/font and suitably filling in the background. In general, it would appear Gregory is correct in that what styling one can do on datasets seems confined to adding wrappers around the dataset. I too don't see a way for finer control for specific lines, short of piping the Dataset to a grid and then reformatting.

As noted by Josh,

 Names["Dataset$*"] // TableForm  provides a list of variables associated with the Dataset namespace. I suspect that the \$DatasetKeyColor or possibly \\$DatasetStyle variables might provide a means of changing the color of the header keys, but don't know how to effect this change within the code just given. Attempting to style the variable keys in the code snippet above doesn't seem to readily, at least, solve the problem.

Dataset[] is really meant for arranging data and is a very useful wrapper for several key data processing functions, such as Query[], allowing fro grouping, sorting, efficient row/column computation, etc. While it has a great built in visualization mechanism, including the ability to dive deeper into grouped cells, yet to achieve maximum control over visualization you would have to use your data in something like a Grid or TextGrid, and style the cells any way you see fit. It's really not the best idea to store styled data in a Dataset. What would be great is if Wolfram would allow rule-based cell highlighting in datasets, but I don't think this exists in 11.1. Meanwhile try this for header and alternate-row highlighting:

TextGrid[ {header} ~Join~ Normal@Values@myDataset, Background->Background -> {None,{Orange,{LightBlue,While}}} ]


Alternatively, you can use Item[... , Background->...]` to specify item-specific cell properties in a TextGrid. This still will not work in a Dataset.

• Besides its great built in visualization mechanism, I don't see the point of Dataset. Query[ ] works very well on associations and list of associations without having to use Dataset which I find slow. – Gustavo Delfino Jul 25 '17 at 17:14