forked from davi-rodrigues/NAVanalysis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NAVoptions.wl
105 lines (81 loc) · 3.59 KB
/
NAVoptions.wl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
(* ::Package:: *)
(* ::Title:: *)
(*NAVoptions*)
(*Based on SetOptions5a.wl by D.C.Rodrigues*)
(* ::Subtitle:: *)
(*Davi C. Rodrigues*)
(* ::Text:: *)
(*Requires the CustomTicks package.*)
Needs["CustomTicks`"]
(* Shortcuts *)
TF = TableForm;
MF = MatrixForm;
(* Ticks options *)
SetOptions[LinTicks,
MajorTickLength->{0.015, 0.015},
MinorTickLength->{0.010, 0.010},
MajorTickStyle-> Thickness[0.0030],
MinorTickStyle-> Thickness[0.0015]
]; (* depends on CustomTicks.m *)
ClearAll[LinTicks2];
Options[LinTicks2] = Options[LinTicks];
LinTicks2[x__] := LinTicks[x,
MajorTickLength->{0.015, 0},
MinorTickLength->{0.010, 0},
MajorTickStyle-> Thickness[0.0030],
MinorTickStyle-> Thickness[0.0015]
];
SetOptions[LogTicks,
MajorTickLength->{0, 0.020},
MinorTickLength->{0, 0.010},
MajorTickStyle-> Thickness[0.0020],
MinorTickStyle-> Thickness[0.0015]
]; (* Depends on CustomTicks.m *)
plotstyleoptions[thickness_] = {
Directive[GrayLevel[0],Thickness[thickness]],
Directive[RGBColor[0.34398, 0.49112, 0.89936],Thickness[thickness]],
Directive[RGBColor[0.97, 0.606, 0.081],Thickness[thickness]],
Directive[RGBColor[0.448, 0.69232, 0.1538],Thickness[thickness]],
Directive[RGBColor[0.62168, 0.2798, 0.6914],Thickness[thickness]],
Directive[RGBColor[0.91, 0.318, 0.243],Thickness[thickness]],
Directive[GrayLevel[0],Thickness[thickness]] (*It is important that the last color is equal to the first one*)
};
colorplot[i_] := plotstyleoptions[0.002][[i,1]]; (*Calls the i-th color used in plotstyleoptions*)
plotMarkersOptions = Graphics[{colorplot @ #, Circle[]}, ImageSize -> 12] & /@ Range[7];
(* General options *)
generalOptions = {
PlotRangePadding -> Scaled[0.001],
Frame-> True,
Axes -> False,
(*FrameStyle -> Scaled[0.02], *)
GridLinesStyle -> Directive[Dashed, LightGray, Thickness[0.0001]], (* Use GridLines -> Auto, for instance, to show them*)
LabelStyle -> {FontFamily -> "Times", FontSize -> 15}, (*The font size is fixed.*)
FrameTicks -> {{LinTicks, StripTickLabels@LinTicks2}, {LinTicks, StripTickLabels@LinTicks2}},
AspectRatio -> 1
};
(* The new functions *)
ClearAll[nPlot];
SetAttributes[nPlot, HoldFirst];
Options[nPlot] = Options[Plot];
SetOptions[nPlot, Sequence@@generalOptions, PlotStyle -> plotstyleoptions[0.005]];
nPlot[args__, opts:OptionsPattern[]] := Plot[args, opts, Evaluate@Options[nPlot]];
ClearAll[nListPlot];
Options[nListPlot] = Options[ListPlot];
SetOptions[nListPlot, Sequence@@generalOptions, PlotMarkers -> plotMarkersOptions];
nListPlot[args__, opts:OptionsPattern[]] := ListPlot[args, opts, Evaluate@Options[nListPlot]];
ClearAll[nParametricPlot];
SetAttributes[nParametricPlot, HoldFirst];
Options[nParametricPlot] = Options[ParametricPlot];
SetOptions[nParametricPlot, Sequence@@generalOptions, PlotStyle -> plotstyleoptions[0.005]];
nParametricPlot[args__, opts:OptionsPattern[]] := ParametricPlot[args, opts, Evaluate@Options[nParametricPlot]];
(* ToCode definition*)
DeclarePackage["GeneralUtilities`", "ToCode"];
SetAttributes[ToCode, Attributes@HoldPrettyForm];
ToCode[x_] := Block[
{replaceTabs, replacePatterns},
replaceTabs = Replace[#, s_String :> StringReplace[s, "\t" -> " "], All] &;
replacePatterns = ReplaceAll[#, InterpretationBox[string_String, somethingelse__] :> string] & ;
Print[RawBoxes@replaceTabs@replacePatterns@ToBoxes@HoldPrettyForm[x]];
SelectionMove[SelectedNotebook[], Next, GeneratedCell];
FrontEndExecute@FrontEndToken[SelectedNotebook[], "Style", "Code"];
];