11
$\begingroup$

Here is an example,

Grid[Transpose@Insert[Transpose@Insert[Table[aaa,
      {ab, {{1, 1}, {1, 2}, {1, 3}, {2, 3}}}, {ϕ, {0, π/
        4, π/2, (3 π)/4, π}}], {0, π/4, π/2, (
      3 π)/4, π}, 1], {Grid[{{"\\", ϕ}, {"x:y", "\\"}}], 
    "1:1", "1:2", "1:3", "2:3"}, 1], Frame -> All]

it gives enter image description here

Notice the ugly slash header? That is because I don't know how to do it, so I do it ugly. I want a perfect slash separate "x:y" and "$\phi$", and maybe even multi-slash header.


edit

I temporarily accept Graumagier's answer, though like Kuba said "it is like an acrobatic". But it works and has some sort of flexibility, because the header is now a graphic, we can move the labels around using drawing tools for graphics for better appearance and also resize the size of the slash header easily by just dragging the graphic border. Finally, better solutions are welcome :)

Updata

write a function that generate a slash header graphic to make life easier.

Clear[corner];
corner[rowlabel_, columnlabel_, ratioofhtow_, fontsize_: Larger] := 
 Module[{heightvec = {0, ratioofhtow}, widthvec = {1, 0}}, 
  Graphics[{Line[{heightvec, widthvec}], 
    Text[Style[rowlabel, "StandardForm", fontsize], 
     0.5*(heightvec + widthvec) - 0.25*heightvec], 
    Text[Style[columnlabel, "StandardForm", fontsize], 
     0.5*(heightvec + widthvec) + 0.25*widthvec]}, 
   AspectRatio -> Automatic, ImageSize -> Tiny]]

So now

enter image description here

$\endgroup$
1
  • 1
    $\begingroup$ TableForm might give a more pleasant output. Try TableForm[ Table[aaa, {ab, {{1, 1}, {1, 2}, {1, 3}, {2, 3}}}, {\[Phi], {0, \[Pi]/4, \[Pi]/2, (3 \[Pi])/4, \[Pi]}}], TableHeadings -> {{"1:1", "1:2", "1:3", "2:3"}, {0, \[Pi]/4, \[Pi]/2, (3 \[Pi])/4, \[Pi]}}]. $\endgroup$ Oct 31, 2015 at 16:22

2 Answers 2

17
$\begingroup$

You might want to try something like this:

Grid[
 Transpose@
  Insert[
   Transpose@
    Insert[
     Table[
      aaa,
      {ab, {{1, 1}, {1, 2}, {1, 3}, {2, 3}}}, {\[Phi], {0, \[Pi]/
         4, \[Pi]/2, (3 \[Pi])/4, \[Pi]}}], {0, \[Pi]/4, \[Pi]/
       2, (3 \[Pi])/4, \[Pi]}, 1
     ],
   {
    Graphics[{
      Line[{{0, 1}, {2, 0}}],
      Text[Style["x:y", "StandardForm", Larger], {0.5, 0.25}],
      Text[Style["\[Phi]", "StandardForm", Larger], {1.5, 0.75}]
      },
     ImageSize -> Tiny],
    "1:1", "1:2", "1:3", "2:3"}, 1],
 Frame -> All
 ]

It's probably not the most robust solution in terms of scaling/spacing, but I think it comes close to what you wanted to achieve.

enter image description here

$\endgroup$
7
  • 4
    $\begingroup$ V10+ and we still have to do such silly acrobatics... (+1 ofc) $\endgroup$
    – Kuba
    Oct 31, 2015 at 21:13
  • 1
    $\begingroup$ True, it does make one long for something like TikZ/PGF from time to time ;) $\endgroup$
    – Graumagier
    Oct 31, 2015 at 21:18
  • 2
    $\begingroup$ @Kuba Is there a system in which layout is not a pain? Maybe publishers have such. You can edit the graphics by hand and align the labels with the centers (using the Drawing Tools). Like this: i.stack.imgur.com/xBpSu.png $\endgroup$
    – Michael E2
    Oct 31, 2015 at 21:24
  • 2
    $\begingroup$ @MichaelE2 you have the point. Maybe I have too much of a demanding attitude. But I really feel like some basic/standard grid layout solutions are expected to be built-in. There is something in Grid, something in TableForm, and with Graphics one can get some nice results. But I find it too much for a simple crude presentation of results. $\endgroup$
    – Kuba
    Oct 31, 2015 at 21:32
  • $\begingroup$ @Kuba Well, I agree that Mathematica is a poor tool for layout and seems worse than it should be, imo. For the most part, I don't get irritated because I don't publish things that use scatter plots, legending, or tables. So mostly, I just feel sorry for the users who have to meet publishers' style guides. $\endgroup$
    – Michael E2
    Oct 31, 2015 at 21:46
11
$\begingroup$

There's Backslash:

Grid[Transpose@
  Insert[Transpose@
    Insert[Table[
      aaa,
      {ab, {{1, 1}, {1, 2}, {1, 3}, {2, 3}}},
      {ϕ, {0, π/ 4, π/2, (3 π)/4, π}}],
    {0, π/4, π/2, (3 π)/4, π}, 1],
   {Backslash["x:y", ϕ], "1:1", "1:2", "1:3", "2:3"}, 1],
 Frame -> All]

Mathematica graphics

You can use various things to control size and placement. For instance, using

Backslash[Pane["x:y", ImageSize -> {Automatic, 30}, Alignment -> Bottom], ϕ]

results in

Mathematica graphics

Update

This looks a little better to me, but one can spend a lot of time fussing just to satisfy one's picayune aesthetic quirks.

Grid[Transpose@
  Insert[Transpose@
    Insert[Table[
      aaa,
      {ab, {{1, 1}, {1, 2}, {1, 3}, {2, 3}}},
      {ϕ, {0, π/ 4, π/2, (3 π)/4, π}}],
    {0, π/4, π/2, (3 π)/4, π}, 1],
  {Backslash["x:y", Pane[ϕ, ImageSize -> {Automatic, 30}, Alignment -> Center]],
     "1:1", "1:2", "1:3", "2:3"}, 1], Frame -> All, 
 Alignment -> {Center, Center, Table[{i, 1} -> ":", {i, 5}]}]

Mathematica graphics

$\endgroup$
0

Your Answer

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

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