Belisarius gave the basic method. I shall introduce an advanced method, because you seem eager to learn First let me say that I saw what I believed were simplifications to your code, and I made them, hopefully not in error I will use this sample data in illustrations below: data = Prepend RandomInteger99, {5, 12}, DateString{1, #}, "MonthName" & /@ Range@12 Goals Since the main function used is Grid it makes sense to allow passing options to it You have a series of options that define your table. I want to be able to conveniently change these I want the possibility of custom options not understood by Grid Implementation Goal #1 An argument pattern opts:OptionsPattern is added, which matches any sequence of Option -> Setting arguments, and names it opts (See: OptionsPattern for more.) Then opts is inserted into the basic function before the other options for Grid This allows any explicitly given options to override the defaults, or new ones to be given customTabulardata_, opts : OptionsPattern := GridMapAtRotate#, 90 Degree & /@ # &, data, 1, opts, Background -> {{{White, Pink}}}, Dividers -> {All, {2 -> True}}, ItemSize -> {1 -> 5}, Alignment -> {Center, {1 -> Top}}, Frame -> True, FrameStyle -> Thickness2, ItemStyle -> DirectiveFontSize -> 15, Black, Bold // Text Examples: customTabulardata customTabulardata, Background -> LightBlue Goal #2 The options that define your tabular format can be separated from the function body.
This will allow them to be conveniently changed or referenced. I start by clearing the previous definition with ClearAll Then I set default Options for customTabular : ClearAllcustomTabular OptionscustomTabular = {Background -> {{{White, Pink}}}, Dividers -> {All, {2 -> True}}, ItemSize -> {1 -> 5}, Alignment -> {Center, {1 -> Top}}, Frame -> True, FrameStyle -> Thickness2, ItemStyle -> DirectiveFontSize -> 15, Black, Bold} Now the function proper. Here Options@customTabular gets the rules given above customTabulardata_, opts : OptionsPattern := GridMapAtRotate#, 90 Degree & /@ # &, data, 1, opts, Sequence @@ Options@customTabular // Text Now you can easily change the defaults with SetOptions Example: SetOptionscustomTabular, Background -> {{{LightMagenta, LightOrange}}} ; customTabulardata.
Belisarius gave the basic method. I shall introduce an advanced method, because you seem eager to learn. First let me say that I saw what I believed were simplifications to your code, and I made them, hopefully not in error.
I will use this sample data in illustrations below: data = Prepend RandomInteger99, {5, 12}, DateString{1, #}, "MonthName" & /@ Range@12 ; Goals Since the main function used is Grid it makes sense to allow passing options to it. You have a series of options that define your table. I want to be able to conveniently change these.
I want the possibility of custom options not understood by Grid. Implementation Goal #1 An argument pattern opts:OptionsPattern is added, which matches any sequence of Option -> Setting arguments, and names it opts. (See: OptionsPattern for more.) Then, opts is inserted into the basic function before the other options for Grid.
This allows any explicitly given options to override the defaults, or new ones to be given. CustomTabulardata_, opts : OptionsPattern := GridMapAtRotate#, 90 Degree & /@ # &, data, 1, opts, Background -> {{{White, Pink}}}, Dividers -> {All, {2 -> True}}, ItemSize -> {1 -> 5}, Alignment -> {Center, {1 -> Top}}, Frame -> True, FrameStyle -> Thickness2, ItemStyle -> DirectiveFontSize -> 15, Black, Bold // Text Examples: customTabulardata customTabulardata, Background -> LightBlue Goal #2 The options that define your tabular format can be separated from the function body. This will allow them to be conveniently changed or referenced.
I start by clearing the previous definition with ClearAll. Then I set default Options for customTabular: ClearAllcustomTabular OptionscustomTabular = {Background -> {{{White, Pink}}}, Dividers -> {All, {2 -> True}}, ItemSize -> {1 -> 5}, Alignment -> {Center, {1 -> Top}}, Frame -> True, FrameStyle -> Thickness2, ItemStyle -> DirectiveFontSize -> 15, Black, Bold}; Now the function proper. Here Options@customTabular gets the rules given above.
CustomTabulardata_, opts : OptionsPattern := GridMapAtRotate#, 90 Degree & /@ # &, data, 1, opts, Sequence @@ Options@customTabular // Text Now you can easily change the defaults with SetOptions. Example: SetOptionscustomTabular, Background -> {{{LightMagenta, LightOrange}}} ; customTabulardata Goal #3 Now I want to add an option that is not passed to Grid. I choose "Rotation" to change the text rotation of the title row.
Again I clear the prior definition and the default options. Notice the inclusion of "Rotation" -> 90 Degree in the list. ClearAllcustomTabular OptionscustomTabular = {Background -> {{{White, Pink}}}, Dividers -> {All, {2 -> True}}, ItemSize -> {1 -> 5}, Alignment -> {Center, {1 -> Top}}, Frame -> True, FrameStyle -> Thickness2, ItemStyle -> DirectiveFontSize -> 15, Black, Bold, "Rotation" -> 90 Degree}; Now I need a way to use this new option, and I need a way to keep this option from being sent to Grid: I access the option with OptionValue which will give the default if none is explicitly given.
I pass only valid Grid options by using FilterRules. I first join any explicit options to the front of the Options@customTabular list, again to override defaults. CustomTabulardata_, opts : OptionsPattern := GridMapAtRotate#, OptionValue"Rotation" & /@ # &, data, 1, Sequence @@ FilterRules{opts} ~Join~ Options@customTabular, Options@Grid // Text Example: SetOptionscustomTabular, Background -> {{{LightBrown, LightYellow}}}; customTabulardata, Dividers -> All, "Rotation" -> -90 Degree, FrameStyle -> {Darker@Red, Thick} .
1 Very nice! Shows the design process, not just the result. +1 – Leonid Shifrin May 28 at 20:43 @Leonid, thank you.
Any suggested improvements? – Mr.Wizard May 28 at 20:46 @Mr.Wizard Nothing much comes to mind. If you really want this to be maximally didactic (it is didactic already), you could may be put references / links to the documentation for things like OptionsPattern and FilterRules, and a few links to some places where options mechanism is discussed.
– Leonid Shifrin May 28 at 20:57 1 wish I could +100! – d00b May 28 at 22:18 1 @Mr.Wizard Nope, it is not safe (IMO). The problem is that when you pass options more than once, you may accumulate the depth of the rule list.
And since rules at depth more than one in a (nested) list are not interpreted as options, you may run into trouble. And in any case, I would not count on that - this does not look for me like a good case for saving a few keystrokes. Just my two cents... – Leonid Shifrin May 28 at 8:27.
I'd do it the usual way fdata_, color1_, color2_ := Text@Grid{MapRotateText#, 90 Degree &, data1}~Join~ data2 ;;, Background -> {{{{color1, color2}}, {1 -> color1}}}, Dividers -> {All, {1 -> True, 2 -> True, 0 -> True}}, ItemSize -> {1 -> 5, Automatic}, Alignment -> Top, Frame -> True, FrameStyle -> Thickness2, ItemStyle -> {Automatic, Automatic, {{1, 1}, {1, Length@data1}} -> DirectiveFontSize -> 15, Black, Bold} f{{t1, t2, t3}, {1, 2, 3}, {4, 5, 6}}, LightBlue, Orange I am not sure what you are trying to ask for in the last part such a graph as an output ...
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.