New answers tagged

1

matrix = RandomInteger[{0, 10}, {5, 4}]; Grid[matrix, Background -> {None, DeleteCases[ Table[Which[matrix[[i, 3]] > 6, i -> Red], {i, 1, Length[matrix]}], Null]}, Frame -> All]


1

SeedRandom[420]; matrix = RandomInteger[{0, 10}, {5, 4}]; colorrules = Table[n -> If[matrix[[n, 3]] < 6, Gray, Pink], {n, 1, 5}]; Grid[matrix, Frame -> All, Background -> {None, colorrules}]


4

According to this MathGroup post the function SpaceForm was documented only via Information (i.e. the SpaceForm::usage Message) even in Mathematica 3.0. With current version 10.4.1 the situation is still the same: ? SpaceForm SpaceForm[n] prints as n spaces. So you shouldn't worry: this function is in the current situation right from the start, ...


3

f = OpenWrite["test.txt"]; nsp[n_] := OutputForm[StringJoin[ConstantArray[" ", n]]] Write[f, 1, nsp[3], 2, nsp[1], 3]; Close[f] FilePrint["test.txt"] 1 2 3


8

Manipulate[ pascal = Row[Pane[#, 50, Alignment -> Center] & /@ #] & /@ Table[CoefficientList[(x + 1)^i, x], {i, 0, n - 1}]; product = Pane @ StringPadLeft[ToString[#], 40, "."] & /@ Table[(j!)^(j - 1)/BarnesG[j + 1]^2, {j, 0, n - 1}]; Grid[{{ Column[pascal, Center], Column[product, Right] }}, BaseStyle -> 15] , ...


4

In general you can exert quite a bit of control over the results by using an XMLTemplate. For example: hoverGrid= "<!DOCTYPE html> <html> <head> <style> table { width:100%; } th, td { padding: 8px; border: 1px solid black; text-align: right; } tr:hover{background-color:lavender} ...


3

Yes, it seems Column and Row are still broken (How to add a Style string or Hyperlink in CloudDeploy?). Let's use Spacer to create space. Also Grid seems to respect Alignment option: CloudDeploy[ FormFunction[ {"x" -> "String", "y" -> "String"}, Grid[List /@ {#x, Spacer[1], #y, #y, #y}, Alignment -> Left] & ] ]


2

To display multiple lines in a browser insert a <br> tag between each line: CloudDeploy[ FormFunction[{"x" -> "String", "y" -> "String"}, #x <> "<br>" <> #y & ], FileNameJoin[{$CloudRootDirectory, "TwoLineTextOutput"}]]


7

The Dataset visualizer does not presently (v10.4.1) support a nice layout for triply-nested associations. However, we can get close by nesting datasets: plots[ GroupBy[{#color&, #suit&, #elf& -> (#plot&)}] /* KeySortBy[<|"Red"->1,"Black"->2|>] , KeySort /* Dataset , KeySort , First ] KeySort and KeySortBy are used at ...


2

r = RandomInteger[{0, 1}, {10, 10}]; bg = Thread[SparseArray[r]["NonzeroPositions"] -> LightBlue]; Grid[r, Background -> {None, None, bg}]


3

There are better ways to make this list that don't involve emulating MATLAB, but what you want is straightforward: meshgrid3D[xxx_List, yyy_List, zzz_List] := Table[#, {x, xxx}, {y, yyy}, {z, zzz}] & /@ {x, y, z} {xxx, yyy, zzz} = meshgrid3D[Range[-2, 2, .1], Range[-2, 2, .1], Range[-2, 2, .1]]; ListContourPlot3D[xxx^2 + yyy^2 - zzz^2, Contours ...


5

Grid[Item[#, Background -> If[# == 1, Blue]] & /@ # & /@ RandomInteger[{0, 1}, {10, 10}]] Grid[RandomInteger[{0, 1}, {10, 10}]] /. 1 -> Item[1, Background -> Blue] Grid[m = RandomInteger[{0, 1}, {10, 10}], Background -> {None, None, Thread[Position[m, 1] -> Blue]}]



Top 50 recent answers are included