|
| 1 | +(* ::Package:: *) |
| 2 | + |
| 3 | +Usage[ForSciencePlotTheme]="ForSciencePlotTheme handles global options for the ForScience plot theme."; |
| 4 | + |
| 5 | + |
| 6 | +Begin["`Private`"] |
| 7 | + |
| 8 | + |
| 9 | +System`PlotThemeDump`resolvePlotTheme["ForScience",s_]:= |
| 10 | + System`PlotThemeDump`resolvePlotTheme[{"ForScience"},s] |
| 11 | +System`PlotThemeDump`resolvePlotTheme[{"ForScience",opts:OptionsPattern[]},s_]:= |
| 12 | + Join[ |
| 13 | + System`PlotThemeDump`resolvePlotTheme[{"FSColors",opts},s], |
| 14 | + System`PlotThemeDump`resolvePlotTheme[{"FSFrame",opts},s], |
| 15 | + System`PlotThemeDump`resolvePlotTheme[{"FSThickLines",opts},s], |
| 16 | + System`PlotThemeDump`resolvePlotTheme[{"FSMarkers",opts},s], |
| 17 | + System`PlotThemeDump`resolvePlotTheme[{"FSLabels",opts},s] |
| 18 | + ] |
| 19 | + |
| 20 | + |
| 21 | +FSThemeOption[opt_,OptionsPattern[ForSciencePlotTheme]]:= |
| 22 | + OptionValue[opt] |
| 23 | + |
| 24 | + |
| 25 | +FSLabelStyle[scaling:_?NumericQ:1,opts:OptionsPattern[ForSciencePlotTheme]]:= |
| 26 | + Directive[ |
| 27 | + FontColor->OptionValue["BaseColor"], |
| 28 | + FontSize->OptionValue[FontSize]*scaling , |
| 29 | + FontFamily->OptionValue[FontFamily] |
| 30 | + ] |
| 31 | + |
| 32 | + |
| 33 | +FSSmallFontSize[opts:OptionsPattern[ForSciencePlotTheme]]:= |
| 34 | + Directive[FontSize->OptionValue[FontSize]*OptionValue["FontRatio"]] |
| 35 | + |
| 36 | + |
| 37 | +Options[ForSciencePlotTheme]={FontSize->15,FontFamily->"Times New Roman","FontRatio"->0.9,"BaseColor"->Black,ColorFunction->"Jet",PlotMarkers:>VectorMarker[Automatic],Thickness->2}; |
| 38 | + |
| 39 | + |
| 40 | +System`PlotThemeDump`resolvePlotTheme[{"FSColors",opts:OptionsPattern[ForSciencePlotTheme]},s_]:= |
| 41 | + ( |
| 42 | + System`PlotThemeDump`$ThemeColorIndexed=112; |
| 43 | + System`PlotThemeDump`$ThemeColorDensity=FSThemeOption[ColorFunction,opts]; |
| 44 | + System`PlotThemeDump`$ThemeColorArrayPlot="Parula"; |
| 45 | + System`PlotThemeDump`$ThemeColorDensity3D=FSThemeOption[ColorFunction,opts]; |
| 46 | + System`PlotThemeDump`$ThemeColorVectorDensity="VibrantColorVectorDensityGradient"; |
| 47 | + System`PlotThemeDump`$ThemeColorFinancial=ColorData[112]/@{4,1}; |
| 48 | + System`PlotThemeDump`$ThemeColorGradient=ColorData[112]/@{1,5,2,4,3}; |
| 49 | + System`PlotThemeDump`$ThemeColorMatrix={ |
| 50 | + {0,RGBColor[0.63247,0.160941,0.]}, |
| 51 | + {0.1,RGBColor[0.790588,0.201176,0.]}, |
| 52 | + {0.499999,RGBColor[1.,0.960784,0.9]}, |
| 53 | + {0.5,Opacity[0,GrayLevel@1]}, |
| 54 | + {0.500001,RGBColor[1.,0.960784,0.9]}, |
| 55 | + {0.9,RGBColor[1.,0.607843,0.]}, |
| 56 | + {1,RGBColor[0.8505,0.4275,0.13185]} |
| 57 | + }; |
| 58 | + System`PlotThemeDump`$ThemeColorFractal="VibrantColorFractalGradient"; |
| 59 | + System`PlotThemeDump`$ThemeColorWavelet={ |
| 60 | + RGBColor[0.0621178,0.273882,0.727059], |
| 61 | + RGBColor[0.790588,0.201176,0.], |
| 62 | + RGBColor[1.,0.607843,0.], |
| 63 | + RGBColor[1.,1.,1.] |
| 64 | + }; |
| 65 | + System`PlotThemeDump`$ThemeColorGeography=Blend[ |
| 66 | + { |
| 67 | + Opacity[0.6,LABColor[0.8728,0.0831,0.4733]], |
| 68 | + Opacity[0.667,LABColor[0.6324,0.5685,0.7268]], |
| 69 | + Opacity[0.733,LABColor[0.5767,0.7148,0.706]], |
| 70 | + Opacity[0.8,LABColor[0.4072,0.5376,0.5415]] |
| 71 | + }, |
| 72 | + # |
| 73 | + ]&; |
| 74 | + System`PlotThemeDump`$ThemeColorDensityGeography=Blend[ |
| 75 | + { |
| 76 | + LABColor[0.8728,0.0831,0.4733], |
| 77 | + LABColor[0.6324,0.5685,0.7268], |
| 78 | + LABColor[0.5767,0.7148,0.706], |
| 79 | + LABColor[0.4072,0.5376,0.5415] |
| 80 | + }, |
| 81 | + # |
| 82 | + ]&; |
| 83 | + System`PlotThemeDump`resolvePlotTheme["ColorStyle",s] |
| 84 | + ) |
| 85 | +System`PlotThemeDump`resolvePlotTheme[{"FSColors",opts:OptionsPattern[ForSciencePlotTheme]},s:"SliceVectorPlot3D"|"ListSliceVectorPlot3D"]:= |
| 86 | + ( |
| 87 | + System`PlotThemeDump`$ThemeColorDensity="VibrantColorDensityGradient"; |
| 88 | + System`PlotThemeDump`resolvePlotTheme["ColorStyle",s] |
| 89 | + ) |
| 90 | + |
| 91 | + |
| 92 | +System`PlotThemeDump`resolvePlotTheme[{"FSColors",opts:OptionsPattern[ForSciencePlotTheme]},s:"ArrayPlot"|"RulePlot"]:= |
| 93 | + Themes`SetWeight[ |
| 94 | + { |
| 95 | + "DefaultColorFunction"->ColorData["Parula"] |
| 96 | + }, |
| 97 | + Themes`$ColorWeight |
| 98 | + ] |
| 99 | + |
| 100 | + |
| 101 | +System`PlotThemeDump`resolvePlotTheme[{"FSLabels",opts:OptionsPattern[]},s_/;!StringMatchQ[s,{"WordCloud","BodePlot"}]]:= |
| 102 | + Themes`SetWeight[ |
| 103 | + { |
| 104 | + LabelStyle->FSLabelStyle[opts] |
| 105 | + }, |
| 106 | + Themes`$FontWeight |
| 107 | + ] |
| 108 | +System`PlotThemeDump`resolvePlotTheme[{"FSLabels",opts:OptionsPattern[]},"BodePlot"]:= |
| 109 | + Themes`SetWeight[ |
| 110 | + { |
| 111 | + LabelStyle->{ |
| 112 | + FSLabelStyle[opts], |
| 113 | + FSLabelStyle[opts] |
| 114 | + } |
| 115 | + }, |
| 116 | + Themes`$FontWeight |
| 117 | + ] |
| 118 | + |
| 119 | + |
| 120 | +System`PlotThemeDump`resolvePlotTheme[{"FSFrame",opts:OptionsPattern[]},s_/;!StringMatchQ[s,{"WordCloud","*Gauge","*3D","Paired*","BarChart","RectangleChart","PieChart","SectorChart","CandlestickChart","KagiChart","LineBreakChart","PointFigureChart","RenkoChart","TradingChart","InteractiveTradingChart","NumberLinePlot","WaveletMatrixPlot","MandelbrotSetPlot","JuliaSetPlot","PolarPlot","ListPolarPlot"}]]:= |
| 121 | + Themes`SetWeight[ |
| 122 | + { |
| 123 | + Axes->False, |
| 124 | + Frame->True, |
| 125 | + FrameTicksStyle->FSSmallFontSize[opts], |
| 126 | + FrameStyle->FSThemeOption["BaseColor",opts], |
| 127 | + PlotRangePadding->None |
| 128 | + }, |
| 129 | + System`PlotThemeDump`$ComponentWeight |
| 130 | + ] |
| 131 | +System`PlotThemeDump`resolvePlotTheme[{"FSFrame",opts:OptionsPattern[]},"PolarPlot"|"ListPolarPlot"]:= |
| 132 | + Themes`SetWeight[ |
| 133 | + { |
| 134 | + Axes->False, |
| 135 | + TicksStyle->Directive[FSLabelStyle[FSThemeOption["FontRatio",opts],opts],FSThemeOption["BaseColor",opts]], |
| 136 | + PolarAxes->True, |
| 137 | + PolarTicks->{"Degrees",Charting`ScaledTicks[{Identity,Identity}][##]&}, |
| 138 | + PlotRange->All, |
| 139 | + PolarGridLines->Automatic, |
| 140 | + PlotRangePadding->Scaled@0.1 |
| 141 | + }, |
| 142 | + System`PlotThemeDump`$ComponentWeight |
| 143 | + ] |
| 144 | +System`PlotThemeDump`resolvePlotTheme[{"FSFrame",opts:OptionsPattern[]},s_/;StringMatchQ[s,"*3D"]&&!StringMatchQ[s,{"BarChart3D","RectangleChart3D","PieChart3D","SectorChart3D"}]]:= |
| 145 | + Themes`SetWeight[ |
| 146 | + { |
| 147 | + Axes->True, |
| 148 | + Boxed->True, |
| 149 | + BoxStyle->FSThemeOption["BaseColor",opts], |
| 150 | + AxesStyle->FSThemeOption["BaseColor",opts], |
| 151 | + TicksStyle->FSSmallFontSize[opts] |
| 152 | + }, |
| 153 | + System`PlotThemeDump`$ComponentWeight |
| 154 | + ] |
| 155 | +System`PlotThemeDump`resolvePlotTheme[{"FSFrame",opts:OptionsPattern[]},"BarChart"|"RectangleChart"]:= |
| 156 | + Themes`SetWeight[ |
| 157 | + { |
| 158 | + Axes->{True,False}, |
| 159 | + TicksStyle->FSThemeOption["BaseColor",opts], |
| 160 | + Frame->True, |
| 161 | + FrameTicks->{False,True}, |
| 162 | + FrameTicksStyle->FSSmallFontSize[opts], |
| 163 | + FrameStyle->FSThemeOption["BaseColor",opts] |
| 164 | + }, |
| 165 | + System`PlotThemeDump`$ComponentWeight |
| 166 | + ] |
| 167 | +System`PlotThemeDump`resolvePlotTheme[{"FSFrame",opts:OptionsPattern[]},"CandlestickChart"|"KagiChart"|"LineBreakChart"|"PointFigureChart"|"RenkoChart"]:= |
| 168 | + Themes`SetWeight[ |
| 169 | + { |
| 170 | + Axes->True, |
| 171 | + AxesStyle->FSThemeOption["BaseColor",opts], |
| 172 | + TicksStyle->FSThemeOption["BaseColor",opts], |
| 173 | + Frame->{{True,True},{False,True}}, |
| 174 | + FrameTicksStyle->FSSmallFontSize[opts], |
| 175 | + FrameStyle->FSThemeOption["BaseColor",opts] |
| 176 | + }, |
| 177 | + System`PlotThemeDump`$ComponentWeight |
| 178 | + ] |
| 179 | +System`PlotThemeDump`resolvePlotTheme[{"FSFrame",opts:OptionsPattern[]},"TradingChart"|"InteractiveTradingChart"]:= |
| 180 | + Themes`SetWeight[ |
| 181 | + { |
| 182 | + Axes->True, |
| 183 | + AxesStyle->FSThemeOption["BaseColor",opts], |
| 184 | + TicksStyle->Directive[FSThemeOption["BaseColor",opts],FSSmallFontSize[opts]], |
| 185 | + FrameStyle->FSThemeOption["BaseColor",opts], |
| 186 | + FrameTicksStyle->FSThemeOption["BaseColor",opts] |
| 187 | + }, |
| 188 | + System`PlotThemeDump`$ComponentWeight |
| 189 | + ] |
| 190 | +System`PlotThemeDump`resolvePlotTheme[{"FSFrame",opts:OptionsPattern[]},"PairedBarChart"]:= |
| 191 | + Themes`SetWeight[ |
| 192 | + { |
| 193 | + Axes->True, |
| 194 | + AxesStyle->FSThemeOption["BaseColor",opts], |
| 195 | + Frame->True, |
| 196 | + FrameStyle->FSThemeOption["BaseColor",opts], |
| 197 | + FrameTicks->{True,False}, |
| 198 | + FrameTicksStyle->FSSmallFontSize[opts] |
| 199 | + }, |
| 200 | + System`PlotThemeDump`$ComponentWeight |
| 201 | + ] |
| 202 | +System`PlotThemeDump`resolvePlotTheme[{"FSFrame",opts:OptionsPattern[]},"PairedHistogram"]:= |
| 203 | + Themes`SetWeight[ |
| 204 | + { |
| 205 | + Axes->True, |
| 206 | + AxesStyle->FSThemeOption["BaseColor",opts], |
| 207 | + TicksStyle->{{FSThemeOption["BaseColor",opts],FSThemeOption["BaseColor",opts]}}, |
| 208 | + Frame->True, |
| 209 | + FrameStyle->FSThemeOption["BaseColor",opts], |
| 210 | + FrameTicks->{True,False}, |
| 211 | + FrameTicksStyle->FSSmallFontSize[opts], |
| 212 | + PlotRangePadding->{Automatic,None} |
| 213 | + }, |
| 214 | + System`PlotThemeDump`$ComponentWeight |
| 215 | + ] |
| 216 | +System`PlotThemeDump`resolvePlotTheme[{"FSFrame",opts:OptionsPattern[]},"SectorChart"]:= |
| 217 | + Themes`SetWeight[ |
| 218 | + { |
| 219 | + PolarAxes->Automatic, |
| 220 | + PolarTicks->None, |
| 221 | + PolarGridLines->{None,Automatic} |
| 222 | + }, |
| 223 | + System`PlotThemeDump`$ComponentWeight |
| 224 | + ] |
| 225 | + |
| 226 | + |
| 227 | +System`PlotThemeDump`resolvePlotTheme[{"FSThickLines",opts:OptionsPattern[]},"ListLinePlot"|"StackedListPlot"|"StackedDateListPlot"|"ListStepPlot"|"ListCurvePathPlot"|"LogLinearPlot"|"LogLogPlot"|"LogPlot"|"PairedSmoothHistogram"|"Plot"|"PolarPlot"|"SmoothHistogram"|"DateListLogPlot"|"DateListPlot"|"DateListStepPlot"|"DiscretePlot"|"DiscretePlot3D"|"ListLogLinearPlot"|"ListLogLogPlot"|"ListLogPlot"|"ListPlot"|"ListPolarPlot"|"NumberLinePlot"|"BodePlot"|"NicholsPlot"|"NyquistPlot"|"RootLocusPlot"|"SingularValuePlot"|"TimelinePlot"|"WaveletListPlot"]:= |
| 228 | + Themes`SetWeight[ |
| 229 | + { |
| 230 | + "DefaultThickness"->{Directive[CapForm["Butt"],AbsoluteThickness@FSThemeOption[Thickness,opts]]} |
| 231 | + }, |
| 232 | + System`PlotThemeDump`$LineThicknessWeight |
| 233 | + ] |
| 234 | +System`PlotThemeDump`resolvePlotTheme[{"FSThickLines",opts:OptionsPattern[]},"ContourPlot"|"ListContourPlot"]:= |
| 235 | + Themes`SetWeight[ |
| 236 | + { |
| 237 | + "DefaultContourStyle"->{Opacity@1}, |
| 238 | + "DefaultThickness"->{AbsoluteThickness@FSThemeOption[Thickness,opts]} |
| 239 | + }, |
| 240 | + System`PlotThemeDump`$LineThicknessWeight |
| 241 | +] |
| 242 | + |
| 243 | + |
| 244 | +System`PlotThemeDump`resolvePlotTheme[{"FSMarkers",opts:OptionsPattern[]},"ListPlot"|"ListLogPlot"|"ListLinePlot"|"StackedListPlot"|"StackedDateListPlot"|"ListStepPlot"|"ListCurvePathPlot"|"ListLogLogPlot"|"ListLogLinearPlot"|"DateListPlot"|"DateListStepPlot"|"DateListLogPlot"|"FeatureSpacePlot"]:= |
| 245 | + Themes`SetWeight[ |
| 246 | + { |
| 247 | + PlotMarkers->FSThemeOption[PlotMarkers,opts] |
| 248 | + }, |
| 249 | + System`PlotThemeDump`$ComponentWeight |
| 250 | + ] |
| 251 | +System`PlotThemeDump`resolvePlotTheme[{"FSMarkers",opts:OptionsPattern[]},"ListPolarPlot"]:= |
| 252 | + Themes`SetWeight[ |
| 253 | + { |
| 254 | + PlotMarkers->FSThemeOption[PlotMarkers,opts], |
| 255 | + Joined->True |
| 256 | + }, |
| 257 | + System`PlotThemeDump`$ComponentWeight |
| 258 | + ] |
| 259 | + |
| 260 | +End[] |
0 commit comments