Hot answers tagged output-formatting
10
Here is a solution :
m = RandomInteger[{-5, 5}, {10, 10}];
m /. {x__, y_ /; y > 0} :> (Style[#, Red] & /@ {x, y});
% // TableForm
Explanation about TableForm[]
TableForm[] accepts as argument only a List[] of List[].
m /. {x__, y_ /; y > 0} ->
Style[{x, y}, Red] seems to be a List[] of List[] :
but in fact the red lines have ...
8
The * multiplication operator is rendered in InputForm:
c = a*b;
c // InputForm
a*b
For producing/exporting strings:
ExportString[c, "Text"]
ToString[c, InputForm]
"a*b"
"a*b"
5
As excellently described by andre the problem is that style is applied to the row vectors rather than the array elements themselves, and TableForm is not written to handle this situation. For ease of use you may wish to write a variant of Style that automatically threads over lists:
style[args__] := Thread[Style[args], List, 1]
Now:
m = ...
5
Another way, copying once more from @J.M.'s answer here: How can I fill under a function in a plot just to right of a specified vertical line?
Using @b.gatessucks definition of f:
f[r_, k_] = (HarmonicNumber[k] - HarmonicNumber[k - r]) (HarmonicNumber[k] -
HarmonicNumber[-1 + r])
we can do:
With[{ff = f[r, 10]},
...
4
One way :
f[r_, k_] = (HarmonicNumber[k] - HarmonicNumber[k - r]) (HarmonicNumber[k] -
HarmonicNumber[-1 + r])
sol1 = r /. FindRoot[f[r, 10] == 0.4, {r, 2}];
sol2 = r /. FindRoot[f[r, 10] == 0.4, {r, 9}];
m = FindMaximum[f[r, 10], {r, sol1, sol2}][[1]];
Show[Plot[f[r, 10], {r, 0, 11}],
Plot[f[r, 10], {r, 0, sol1}, Filling -> Bottom],
...
4
Not quite tested
embeddedNotebookForm/:
MakeBoxes[embeddedNotebookForm[nb:Notebook[cells_List,___]],StandardForm]:=
MakeBoxes@DocumentNotebook[{TextCell@"tag"}]/.{
{{Cell["tag"]}}:>Block[{},List/@
Replace[cells,
Cell[CellGroupData[{cs__Cell},_]]:>cs, {1}]
/;True],
...
3
As Anon suggests, ImageSize is the key. For instance:
BarChart3D[Range[5], ImageSize -> 500]
fixes the size at 500, no matter how many data points it has. You can find this kind of thing out for yourself using the built in help. When you look at the help file for BarChart3D, found by the shortcut ?BarChart3D, you can read "BarChart3D has the same ...
3
I'd say it was possible, but some work would be required to make it slick:
Pane[
Column[{
Pane[
Grid[Insert[data, headings, 1],
Background -> {None, {LightCyan}}],
{800, 15}],
Pane[
Grid[data],
{800, 200}, Scrollbars -> True]
}]
]
3
You could draw an invisible second function (a block) and have the filling occur between the two:
f[r_, k_] = (HarmonicNumber[k]-HarmonicNumber[k-r])(HarmonicNumber[k]-HarmonicNumber[-1 + r]);
max = NMaxValue[{f[r, 10], 0 < r < 11}, r]
min = NMinValue[{f[r, 10], 0 <= r <= 11}, r]
Plot[
{
f[r, 10],
Rescale[ Boole[f[r, 10] > 0.4], ...
1
For version 7:
Warning: for simplicity r is not localized in either method; Formal Symbols advised in practice.
hf[K_] := With[{H = HarmonicNumber}, (H[K] - H[K - r]) (H[K] - H[r - 1])]
Plot[
{If[hf[10] < 0.4, hf[10]], If[hf[10] >= 0.4, hf[10]]},
{r, 0, 11},
Filling -> {1 -> Bottom},
PlotStyle -> Black
]
Or:
Plot[
{If[hf[10] < ...
1
I don't know if it will be possible to produce the Cell dingbat et al, as those don't appear on inline cells. However, you can at least get the formatting of your Cell expression by preventing it from being converted to Box form (doubly, making it inert).
Here is a practical example:
myPrintTemp[expr_Cell] :=
Internal`InheritedBlock[{MakeBoxes},
...
1
Apparently ImageCompose isn't working the same way across the versions, with regard to scaling. You could try either Style[f2@#, Red, 80] by itself or changing the final line to:
Map[Show[Rasterize@#, Graphics@Text[Style[f2@#, Red, 80], {59, 59}]] &,
grid, {2}] // GraphicsGrid
1
Here's what I've come up with based on the comments and suggestions posted:
cheadings = Table["Col" <> ToString[i], {i, 1, 10}];
rheadings = Table["Row" <> ToString[j], {j, 1, 100}];
data = Table[RandomReal[], {j, 1, 100}, {i, 1, 10}];
Dynamic@Pane[
Grid[{
{"", Pane[TableForm[Insert[data, cheadings, 1]], {500, 15},
ScrollPosition ...
1
One day, WRI should get round to implementing and documenting the TableView function properly. It's frustratingly close to what you want:
TableView[data]
but its use isn't recommended (and the TableHeadings options are not implemented anyway).
1
I may be missing a subtlety in your question but if you just want the numeric values:
lst = {6., 6.63583, 7.64905, 8.97767, 10.5495, 12.2936, 14.1498, 16.0735, 18.0349,
20.0161, 22.0073, 24.0032, 26.0014, 28.0006, 30.0003, 32.0001, 34., 36., 38., 40., 42.,
44., 46., 48., 50., 52., 54., 56., 58., 60.};
MapIndexed[#/#2[[1]] &, lst]
{6., ...
1
The following routine tries to eliminate the linear terms by completing the square for arbitrary number of variables:
CenterPoly[poly_] := Module[{a, b, c, u, vars},
vars = Variables[poly];
{c, b, a} = {#[[1]], #[[2]]/2, (#[[3]] + Transpose[#[[3]]])/2} &@
Normal@CoefficientArrays[poly, vars];
u = PseudoInverse[a].b;
(#\[Transpose].a.#)[[1, ...
1
Here's a version that doesn't require a temporary file.
Linux (needs xclip)
SetAttributes[copyUnicode, HoldAll];
copyUnicode[expr_] := With[{
stream = OpenWrite["!xclip -in -selection clipboard", CharacterEncoding -> "UTF-8"]
},
WriteString[stream, ToString[Unevaluated@expr, InputForm]];
Close@stream;
];
Example: executing the cell
...
Only top voted, non community-wiki answers of a minimum length are eligible




