Here is my bid for the bounty It is based on the existing solutions from Janus and belisarius, but I consider it an improvement Corrected to work with Plot..., {PlotStyle -> ...} and to move the assignment from Rule Supporting functions ClearAlltoDirective, styleJoin toDirective{ps__} | ps__ := FlattenDirective @@ Flatten{#} & /@ {ps} styleJoinstyle_, base_ := Module{ps, n}, ps = toDirective /@ {PlotStyle /. Optionsbase, style}; ps = ps /. Automatic :> Sequence; n = LCM @@ Length /@ ps; MapThreadJoin, PadRight#, n, # & /@ ps Main function pp is the list of Plot functions you want to affect sh is needed to handle pass-through plots like LogPlot LogLinearPlot DateListLogPlot etc pp = {Plot, ListPlot, ParametricPlot, ParametricPlot3D}; Unprotect /@ pp; (#a__, be : OptionsPattern := Block{$alsoPS = True, sh}, sh = Cases{b}, ("MessagesHead" -> hd_) :> hd, {-2}, 1 /.
{{z_} :> z, {} -> #}; With{new = styleJoinOptionValuePlotStyle, sh}, #a, PlotStyle -> new, be /;! TrueQ$alsoPS ) & /@ pp Usage Now different plot types may be individually styled as follows: SetOptionsPlot, PlotStyle -> ColorData3, "ColorList" Or in groups (here using pp defined above): SetOptionspp, PlotStyle -> ColorData3, "ColorList" PlotStyle options are then automatically added: fns = Tablex^n, {n, 0, 5}; dash = TableAbsoluteDashingi, {i, 1, 6}; Plotfns, {x, -1, 1}, PlotStyle -> dash Plot... and Plot..., PlotStyle -> Automatic are consistent: Plotfns, {x, -1, 1}, Plotfns, {x, -1, 1}, PlotStyle -> Automatic.
Here is my bid for the bounty. It is based on the existing solutions from Janus and belisarius, but I consider it an improvement. Corrected to work with Plot..., {PlotStyle -> ...} , and to move the assignment from Rule.
Supporting functions ClearAlltoDirective, styleJoin toDirective{ps__} | ps__ := FlattenDirective @@ Flatten{#} & /@ {ps} styleJoinstyle_, base_ := Module{ps, n}, ps = toDirective /@ {PlotStyle /. Optionsbase, style}; ps = ps /. Automatic :> Sequence; n = LCM @@ Length /@ ps; MapThreadJoin, PadRight#, n, # & /@ ps Main function pp is the list of Plot functions you want to affect.Sh is needed to handle pass-through plots like LogPlot, LogLinearPlot, DateListLogPlot, etc. Pp = {Plot, ListPlot, ParametricPlot, ParametricPlot3D}; Unprotect /@ pp; (#a__, be : OptionsPattern := Block{$alsoPS = True, sh}, sh = Cases{b}, ("MessagesHead" -> hd_) :> hd, {-2}, 1 /.
{{z_} :> z, {} -> #}; With{new = styleJoinOptionValuePlotStyle, sh}, #a, PlotStyle -> new, be /;! TrueQ$alsoPS ) & /@ pp; Usage Now different plot types may be individually styled as follows: SetOptionsPlot, PlotStyle -> ColorData3, "ColorList"; Or in groups (here using pp defined above): SetOptionspp, PlotStyle -> ColorData3, "ColorList"; PlotStyle options are then automatically added: fns = Tablex^n, {n, 0, 5}; dash = TableAbsoluteDashingi, {i, 1, 6}; Plotfns, {x, -1, 1}, PlotStyle -> dash Plot... and Plot..., PlotStyle -> Automatic are consistent: Plotfns, {x, -1, 1}, Plotfns, {x, -1, 1}, PlotStyle -> Automatic Pass-through plots (those that call Plot, ListPlot or ParametricPlot) can be given their own style: SetOptionsLogPlot, PlotStyle -> ColorData2, "ColorList"; LogPlot{Tanhx, Erfx}, {x, 1, 5} LogPlot{Tanhx, Erfx}, {x, 1, 5}, PlotStyle -> {{Dashed, Thick}} PlotStyle handling can be extended to different Plot types. I included ParametricPlot3D above as an example: fns = {1.16^v Cosv(1 + Cosu), -1.16^v Sinv(1 + Cosu), -2 1.16^v (1 + Sinu)}; ParametricPlot3Dfns, {u, 0, 2 Pi}, {v, -15, 6}, Mesh -> None, PlotStyle -> Opacity0.6, PlotRange -> All, PlotPoints -> 25 Implementation note As it stands, resetting SetOptions..., PlotStyle -> Automatic will revert the colors to the original defaults.
If this behavior is undesirable, the code can be modified to give a different default color, in the manner of Janus' also function, upon which my styleJoin is clearly based.
1 This is a nice kind of automation. I would like to point out, though, that because up-values are only detected on level 1 of the input, your code will not kick-in for Plotfns, {x, -1, 1}, {PlotStyle -> TableAbsoluteDashingi, {i, 1, 6}}. – Sasha Apr 14 at 1:29 Sasha, I've never used that form.Is it commonplace?
If it is, is it reasonable to create another definition to flatten out option lists, or will that break something? – Mr.Wizard Apr 14 at 9:23 1 @Simon, by the way, I may have to add "I code perverse Mathematica" to my profile. ;-p – Mr.Wizard Apr 14 at 12:14 1 @Mr.Wizard: It looks fine (+125)!
A lot more solid than the previous version. I'm sure that this was some of the hardest 100pts that you've earned. And since your solution built off that of @Janus and @Belisarius, I feel like they should share in the bounty.
So everyone who has voted up Mr.Wizards answer, go and vote up Janus' and Belisarius' answers! – Simon Apr 14 at 23:17 1 @Simon, thank you! The rep points are nice, but the real reward is knowing I helped.
:-) – Mr.Wizard Apr 147 at 9:31.
Here is one take on it -- the hard part was estimating how the PlotStyle option is turned into a list of directives. I think this works as the internal implementation: canonicalPlotStyle::usage = "Turn a PlotStyle option into the canonical form {_Directive...}"; canonicalPlotStyleps_ := Replaceps, { a_List :> (FlattenDirective @@ Flatten{#} &) /@ a, a_ :> {Flatten@Directivea}} Building on canonicalPlotStyle it's now just a matter of combining two lists of unequal length: also::usage = "Combines a specified plotstyle with the current defaults as \ specified by Options. "; alsoplotstyle_ := Module{ps, n}, ps = canonicalPlotStyle /@ { (PlotStyle /.
OptionsPlot) /. Automatic :> ColorData1, "ColorList", plotstyle}; n = LCM @@ (Length /@ ps); Join @@@ TransposeFlattenTable#, {n/Length#}, 1 & /@ ps This does require you to call the function when you plot, but I couldn't see any way around that part: SetOptionsPlot, PlotStyle -> ColorData3, "ColorList"; GraphicsRow{Plotfns, {x, -1, 1}, Plotfns, {x, -1, 1}, PlotStyle -> also@dash} HTH.
As you can see, I'm using the defaults from Plot no matter where also is used. It might actually be nicer to use Options associated with also. This would also remove any need to fiddle with Options for Plot... – Janus Mar 23 at 3:24 Nice!
+1. I think I prefer keeping the options associated with Plot (or which ever plotting function you want to use also with) so that it behaves as close to normal as possible. Obviously, it's not quite the answer I'm hoping for (ie a simple setting for a default color scheme), but it's still useful.
– Simon Mar 23 at 4:10 Two small problems. 1) also overrides any manually set colors in the plot. This is simply fixed by reversing the order of terms in ps putting the locally supplied options last.2) You need also every time you make a plot using a manual PlotStyle setting -- a little annoying, but not a deal breaker!
– Simon Mar 23 at 4:13 @Simon -- Thanks for catching the ordering bug. I actually thought it had to be the way I did it, maybe inspired by rules. Will edit above.
– Janus Mar 23 at 5:01.
This is work in progress, I'm posting it because I'm not sure to be able to finish it, and perhaps someone wants to. The idea is to combine the wonderful Janus's solution with this nice trick to redefine the Plot standard behavior. The program below works for a large subset of the help page for Plot , but fails for two or three.
The code is not tidied up, just a draft with leftovers. UnprotectPlot; PlotargsANDopts___ := Block {$inMsg = True, result, also, canonicalPlotStyle, opts, args, optPstyle}, If(opts = FilterRulesCases{argsANDopts}, _Rule, OptionsPlot) == {}, opts = {Axes -> (Axes /. OptionsPlot)};(*Anything not null*) args = Cases{argsANDopts}, Except@_Rule; If(optPstyle = Casesopts, RulePlotStyle, y__ :> y) == {}, optPstyle = (PlotStyle /.
OptionsPlot); canonicalPlotStyleps_ := Replaceps, {a_List :> (FlattenDirective @@ Flatten{#} &) /@ a, a_ :> {Flatten@Directivea}}; alsoplotstyle_ := Module{ps, n}, ps = canonicalPlotStyle /@ {(PlotStyle /. OptionsPlot) /. Automatic :> ColorData1, "ColorList", plotstyle}; n = LCM @@ (Length /@ ps); Join @@@ TransposeFlattenTable#, {n/Length#}, 1 & /@ ps; (*Print@opts; Print@args; Print@optPstyle; Print@Evaluate@alsoopts;*) result = Plot Evaluate@Sequence@@args, PlotStyle -> alsooptPstyle, Evaluate@Sequene@@opts ; result /;!
TrueQ$inMsg; SetOptionsPlot, PlotStyle -> ColorData3, "ColorList"; ProtectPlot; samples: Does not work for: Plot{Sinx, Sin2 x, Sin3 x}, {x, 0, 2 Pi}, PlotStyle -> {Red, Green, Blue}.
1 for still using the magic variable $inMsg! I'm overrun at the moment, so will look more carefully at the code on the weekend... – Simon Mar 24 at 1:27 @Mr. The work is only half done :( Took me more time than I thought initially. The problem is that the Filling doesn't inherit the color from PlotStyle.
The third image is what you get when you specify PlotStyle->Red using the standard Plot. So I guess the Filling needs a special treatment if you want the same color. – belisarius Mar 24 at 8:59.
The most likely source of style data, in my opinion, is: System`Private`$PlotStyleFunction5 {{Hue0.67, 0.6, 0.6}, {Hue0.906068, 0.6, 0.6}, {Hue0.142136, 0.6, 0.6}, {Hue0.378204, 0.6, 0.6}, {Hue0.614272, 0.6, 0.6}} However, using Unprotect and changing this function does not effect the desired change in Plot. Perhaps the call is out of reach to normal methods.
Mr.W: It did look promising - but doesn't actually seem do do anything. Have you looked at Trace with TraceInteral->True? I discovered GraphicsPerformanceTuningDump`colors` that way... but it also seems to be/do nothing.
Another interesting thing to look at is the output of DeleteCasesTable{x, Namesx "Color*", IgnoreCase -> True}, {x, Contexts}, {_, {}} // Column... There might be something useful there, but I haven't found it yet (or figured out the right way of using it). – Simon Apr 9 at 9:05 Mma 7 does not appear to have "Graphics`PerformanceTuningDump`colors`" unless I am doing it wrong. When you say $PlotStyleFunction doesn't do anything, do you mean with regard to Plot?
Because it certainly does give the right output on my system. (editing post to include that...) – Mr.Wizard Apr 9 at 9:22 I see, nice! That matches exactly the colors used by Plot -- unlike ColorData1,"ColorList" which is out by 10^-16 in some cases.
System`Private`$PlotStyleFunctionn, lst gives a list of styles n long where extra styles in lst are "Riffled" into it. This behaviour can be easily emulated, but changing $PlotStyleFunction (either as a DownValue or a pure function OwnValue) doesn't seem to make any difference to Plot... :( – Simon Apr 10 at 0:08 @Simon, you see why I was excited, and then disappointed. I wonder if that actually is the right function, but if it is called at a level lower than DownValues/OwnValues and thereby out of reach.Do you know if this is possible?
– Mr.Wizard Apr 10 at 2:25 1 @Mr.Wizard When searching the string $PlotStyleFunction in the Mathematica's directory by Total Commander I have found four files in the "C:\Program Files\Wolfram Research\Mathematica\7.0\SystemFiles\Kernel\" subdirectories: {Binaries\Windows-x86-64\mathdll. Dll,Binaries\Windows\mathdll. Dll,SystemResources\Windows-x86-64\Explore\PlotExplorer.
Mx,SystemResources\Windows\Explore\PlotExplorer. Mx}.HTH. – Alexey Popkov 6-643 at 12:18.
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.