Files
@ ef14718be3e4
Branch filter:
Location: AENC/switchchain/triangle_successrate_correlation_plots.m
ef14718be3e4
4.6 KiB
application/vnd.wolfram.mathematica.package
Update CCM time evol plots
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 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | (* ::Package:: *)
Needs["ErrorBarPlots`"]
(* ::Section:: *)
(*Plot successrate over time*)
gsraw=Import[NotebookDirectory[]<>"data/graphdata_successrates_timeevol.m"];
(* gsraw=SortBy[gsraw,{#[[1,1]]&,#[[1,2]]&}]; (* Sort by n and then by tau. The {} forces a *stable* sort because otherwise Mathematica sorts also on triangle count and other things. *) *)
gdata=GatherBy[gsraw,{#[[1,2]]&,#[[1,1]]&}];
(* Data format: *)
(* gdata[[ tau index, n index, run index , datatype index ]] *)
(* datatype index:
1: {n,tau}
2: avgtris
3: successrate
*)
nlabels=Map["n = "<>ToString[#]&,gdata[[1,All,1,1,1]]];
taulabels=Map["tau = "<>ToString[#]&,gdata[[All,1,1,1,2]]];
TwoAxisPlot[{f_, g_},{plotrange1_,plotrange2_}] :=
Module[{fgraph, ggraph, frange, grange, fticks, gticks, manualRanges},
manualRanges={plotrange1,plotrange2};
{fgraph, ggraph} =
MapIndexed[
ListPlot[#1, Axes -> True, Joined->True,ImageSize->300,
PlotRange->manualRanges[[#2[[1]]]],
DataRange->{0,measureSkip*maxTime}
(* PlotStyle -> ColorData[1][#2[[1]]] *)
] &, {f, g}];
{frange, grange} = (PlotRange /. AbsoluteOptions[#, PlotRange])[[2]] & /@ {fgraph, ggraph};
fticks = N@FindDivisions[frange, 10];
gticks = Quiet@Transpose@{fticks, ToString[NumberForm[#, 2], StandardForm] & /@ Rescale[fticks, frange, grange]};
Show[fgraph, ggraph /. Graphics[graph_, s___] :> Graphics[GeometricTransformation[graph, RescalingTransform[{{0, 1}, grange}, {{0, 1}, frange}]], s],
Axes -> False, Frame -> True,
(*FrameStyle -> {ColorData[1] /@ {1, 2}, {Automatic, Automatic}}, *)
FrameTicks -> {{fticks, gticks}, {Automatic, Automatic}}]]
(* Test of plot function *)
TwoAxisPlot[{gdata[[1,1,{1,3},2]],gdata[[1,1,{1,3},3]]},{{0,12000},{0,100}}]
MeanFilter
(* For export *)
selectedData=gdata[[2,1]][[{1,3,4,5}]];
measureSkip=100;
minCount=Min[Map[Min[#[[2]]]&,selectedData]];
maxCount=Max[Map[Max[#[[2]]]&,selectedData]];
maxCount=Max[Map[1.5*Max[#[[2,-100;;-1]]]&,selectedData]];
maxTime=Max[Map[Length[#[[2]]]&,selectedData]];
(* maxTime=Round[30000/measureSkip]; *)
skipPts=Max[1,Round[maxTime/5000]]; (* Plotting every point is slow. Plot only once per `skipPts` timesteps *)
maxTime=Round[50000/measureSkip];
coarseData=Map[#[[2,1;;maxTime;;skipPts]]&,selectedData];
coarseData2=Map[#[[3,1;;maxTime;;skipPts]]/100&,selectedData];
coarseData3=Map[MeanFilter[#[[3]],6]/100&,selectedData];
labels=Map["{n,tau} = "<>ToString[#[[1]]]&,selectedData]
TwoAxisPlot[{coarseData,coarseData2},{{0,maxCount},{0,1}}]
plotTimeEvol1=ListPlot[coarseData,Joined->True,PlotRange->{0*minCount,maxCount},DataRange->{0,measureSkip*maxTime},Frame->True,FrameLabel->{"timesteps","number of triangles"},PlotLabel->"n = 1000, \[Tau]=2.2",ImageSize->300]
plotTimeEvol2=ListPlot[coarseData2,Joined->True,PlotRange->{0,1},DataRange->{0,measureSkip*maxTime},Frame->True,FrameLabel->{"timesteps","successrate"},PlotLabel->"n = 1000, \[Tau]=2.2",ImageSize->300,PlotStyle->Opacity[0.5]];
plotTimeEvol3=ListPlot[coarseData3,Joined->True,PlotRange->{0,1},DataRange->{0,measureSkip*maxTime}];
plotTimeEvol4=Show[plotTimeEvol2,plotTimeEvol3]
(* Map[ListPlot[#,Joined->True,PlotRange\[Rule]{minCount,maxCount},DataRange\[Rule]{0,maxTime}]&,coarseData] *)
Export[NotebookDirectory[]<>"plots/timeevol_22_successrate_triangles.pdf",plotTimeEvol1]
Export[NotebookDirectory[]<>"plots/timeevol_22_successrate.pdf",plotTimeEvol4]
(* ::Section:: *)
(*Plot #trianges vs some successrate*)
gsraw=Import[NotebookDirectory[]<>"data/graphdata_successrates.m"];
(* gsraw=SortBy[gsraw,{#[[1,1]]&,#[[1,2]]&}]; (* Sort by n and then by tau. The {} forces a *stable* sort because otherwise Mathematica sorts also on triangle count and other things. *) *)
gdata=GatherBy[gsraw,{#[[1,2]]&,#[[1,1]]&}];
(* Data format: *)
(* gdata[[ tau index, n index, run index , datatype index ]] *)
(* datatype index:
1: {n,tau}
2: avgtris
3: successrate
*)
nlabels=Map["n = "<>ToString[#]&,gdata[[1,All,1,1,1]]];
taulabels=Map["\[Tau] = "<>ToString[#]&,gdata[[All,1,1,1,2]]];
allPlots=Map[Show[
ListPlot[#[[All,{3,2}]],
AxesOrigin->{0,0},
Frame->True,FrameLabel->{"successrate","average number of triangles"},
(*AspectRatio->Automatic,*)
PlotRange->{{0,1},Automatic},
ImageSize->Automatic,
PlotLabel->"n = "<>ToString[#[[1,1,1]]]<>" , \[Tau] = "<>ToString[#[[1,1,2]]],
PlotStyle->PointSize[0.0001]
],Plot[x,{x,1,10000}]]
&,gdata,{2}]
combiPlot=ListLogPlot[gdata[[{1,3,5,7,9},1,All,{3,2}]],
AxesOrigin->{0,0},
Frame->True,FrameLabel->{"successrate","average number of triangles"},
(*AspectRatio->Automatic,*)
PlotRange->Automatic,
ImageSize->300,
PlotLabel->"n = "<>ToString[gdata[[1,1]][[1,1,1]]],
PlotLegends->taulabels[[{1,3,5,7,9}]]
]
Export[NotebookDirectory[]<>"plots/successrate_correlations.pdf",combiPlot]
|