I have a two-part question about the automatic generation of file names and Plot Legends, Labels.
Part 1: I typically work with very large matrices of data with columns of the form:
MASTERdataset: {a-parameter, b-parameter, c-parameter, x-var, y-var}
A sample dataset is below:
masterDATA = {{1200, 700, 150, 285.29323135045837`,
124.81439541987501`}, {1200, 700, 150, 286.60945594708426`,
126.30947680625`}, {1200, 700, 150, 287.92561104172626`,
127.73505620875001`}, {1200, 700, 150, 289.24169417515805`,
129.08867440106252`}, {1200, 700, 150, 290.5577029045866`,
130.367888590125`}, {1200, 700, 150, 291.8736347915017`,
131.5702602656875`}, {1200, 700, 150, 293.1894874091171`,
132.69336264156252`}, {1200, 700, 150, 294.5052583400343`,
133.7347783193125`}, {1200, 700, 150, 295.8209451736646`,
134.692096710125`}, {1200, 700, 150, 297.1365455140142`,
135.5629218201875`}, {1200, 700, 150, 298.4520569668892`,
136.3448594556875`}, {1200, 700, 150, 299.7674771578958`,
137.0355352228125`}, {1200, 700, 150, 301.0828037094413`,
137.63257152881252`}, {1200, 700, 150, 302.39803426883464`,
138.13361568262502`}, {1200, 700, 150, 303.7131664753014`,
138.5363069099375`}, {1200, 700, 150, 305.02819799763193`,
138.83831400093752`}, {1200, 700, 150, 306.34312649281645`,
139.0372939459375`}, {1200, 700, 150, 307.65794964948805`,
139.1309353780625`}, {1200, 700, 150, 308.9726651454576`,
139.116916108125`}, {1100, 700, 150, 285.20258900103653`,
136.52080780656252`}, {1100, 700, 150, 286.51872642831677`,
138.33050686200002`}, {1100, 700, 150, 287.8347978496311`,
140.07419995162502`}, {1100, 700, 150, 289.15080077907106`,
141.7494011668125`}, {1100, 700, 150, 290.4667327507974`,
143.3536446684375`}, {1100, 700, 150, 291.7825912998558`,
144.8844655020625`}, {1100, 700, 150, 293.0983739766935`,
146.339414115`}, {1100, 700, 150, 294.41407833772337`,
147.716046920125`}, {1100, 700, 150, 295.729701949836`,
149.01193080800002`}, {1100, 700, 150, 297.0452423911218`,
150.2246438690625`}, {1100, 700, 150, 298.36069724507706`,
151.35176959956252`}, {1100, 700, 150, 299.6760641116824`,
152.3909079801875`}, {1100, 700, 150, 300.99134059121155`,
153.33965928456252`}, {1100, 700, 150, 302.30652430565584`,
154.195645504125`}, {1100, 700, 150, 303.62161287225007`,
154.95648387356252`}, {1100, 700, 150, 304.93660393503`,
155.61981842875002`}, {1100, 700, 150, 306.2514951283887`,
156.1832835626875`}, {1100, 700, 150, 307.5662841177902`,
156.64454473943752`}, {1100, 700, 150, 308.8809685567008`,
157.0012554253125`}, {1200, 650, 140, 294.568511670944`,
152.44652887431252`}, {1200, 650, 140, 295.5572385555695`,
153.244130479`}, {1200, 650, 140, 296.5459073608416`,
153.983652730375`}, {1200, 650, 140, 297.5345169136301`,
154.663922498125`}, {1200, 650, 140, 298.52306602239275`,
155.28374823993752`}, {1200, 650, 140, 299.5115535361726`,
155.84197899893752`}, {1200, 650, 140, 300.49997828288434`,
156.33744269000002`}, {1200, 650, 140, 301.48833910612274`,
156.768982907625`}, {1200, 650, 140, 302.4766348644878`,
157.135458251875`}, {1200, 650, 140, 303.46486439545527`,
157.43570619850001`}, {1200, 650, 140, 304.4530265778131`,
157.668605535625`}, {1200, 650, 140, 305.44112027103967`,
157.83301574143752`}, {1200, 650, 140, 306.4291443464566`,
157.92780813756252`}, {1200, 650, 140, 307.41709769382004`,
157.95187248018752`}, {1200, 650, 140, 308.4049791815327`,
157.904077172125`}, {1200, 650, 140, 309.39278771614994`,
157.7833287685625`}, {1200, 650, 140, 310.3805221893237`,
157.5885189215`}, {1200, 650, 140, 311.3681814999415`,
157.3185465185`}, {1200, 650, 140, 312.3557645686668`,
156.97233222306252`}, {1200, 650, 140, 313.34327029479664`,
156.54877533212502`}, {1200, 650, 140, 314.33069761222396`,
156.046809738625`}, {1200, 650, 140, 315.3180454445702`,
155.4653590640625`}, {1200, 650, 140, 316.3053127179819`,
154.80334945506252`}, {1200, 650, 140, 317.29249838358635`,
154.05973203875`}, {1150, 600, 140, 298.23873411795546`,
164.05272120981252`}, {1150, 600, 140, 299.2273312653466`,
164.975212389875`}, {1150, 600, 140, 300.2158717606931`,
165.8410515253125`}, {1150, 600, 140, 301.20435441922945`,
166.64905385056252`}, {1150, 600, 140, 302.1927780834343`,
167.3980618443125`}, {1150, 600, 140, 303.18114157670266`,
168.0868989015625`}, {1150, 600, 140, 304.169443745497`,
168.7144114848125`}, {1150, 600, 140, 305.1576834377865`,
169.27944756325002`}, {1150, 600, 140, 306.14585949313545`,
169.7808467010625`}, {1150, 600, 140, 307.13397078169055`,
170.2174790450625`}, {1150, 600, 140, 308.1220161542818`,
170.58819542525`}, {1150, 600, 140, 309.1099944821404`,
170.89186707275002`}, {1150, 600, 140, 310.0979046420354`,
171.1273707566875`}, {1150, 600, 140, 311.08574549827347`,
171.293570783625`}, {1150, 600, 140, 312.0735159488727`,
171.38936517175`}, {1150, 600, 140, 313.06121487255257`,
171.4136326405625`}, {1150, 600, 140, 314.0488411653967`,
171.36526927356252`}, {1150, 600, 140, 315.03639373319686`,
171.24318086262502`}, {1150, 600, 140, 316.0238714652131`,
171.04625666781251`}, {1150, 600, 140, 317.011273287306`,
170.77342254962502`}, {1150, 600, 140, 317.99859810628294`,
170.42358531543752`}, {1150, 600, 140, 318.98584484300574`,
169.995665827125`}, {1150, 600, 140, 319.9730124318714`,
169.48859848168752`}, {1150, 600, 140, 320.96009978832717`,
168.90129872643752`}};
I partition the matrix into sub-matrices corresponding to the values of the (a,b,c) parameters with:
SELECTfxn[data_,a_,b_,c_]:=Select[data,#[[1";;" 3]]=={a,b,c}&]"
To plot the data or perform other manipulations I need to delete the first three columns and assign a file name that uses the (a,b,c) parameters so that I can keep track of which is which later. Up to now I’ve been doing this “by hand” with lots of strategic copy/paste and find/replace operations. I’ve been naming the files with this scheme:
a1200b700c150 = SELECTfxn[masterDATA, 1200, 700, 150][[All , {4, 5}]];
a1100b700c150 = SELECTfxn[masterDATA, 1100, 700, 150][[All , {4, 5}]];
a1200b650c140 = SELECTfxn[masterDATA, 1200, 650, 140][[All , {4, 5}]];
a1150b600c140 = SELECTfxn[masterDATA, 1150, 600, 140][[All , {4, 5}]];
This takes an enormous amount of time and is prone to mistakes. I would like an operation that would achieve the following:
AUTOfileNAMES[data_]:= “Perform operation SELECTfxn[data_,a_,b_,c_] for all unique combinations of (a,b,c) and assign filenames according to the values (a,b,c) similar to above `by hand' example“
I'm sure this is possible but I can't figure it out. Can someone help?
Part 2: The second part of my question is how to incorporate this information into PlotLegends.
I like the data with different groupings and look for patterns. Doing this by hand takes forever and I often make mistakes in the labels for PlotLegends. Is there a way to assign Legend labels automatically that have the form:
a=1200, b = 700, c =150
where the values (1200,700,150) are taken from file names of the form: file=a1200b700c150?
Here's an example of how I'd like the end-product to look:
fontsize = 16;
SAMPLEdataset = {a1200b700c150, a1100b700c150, a1200b650c140,
a1150b600c140};
ListPlot[SAMPLEdataset, PlotStyle -> PointSize[Large], Frame -> True,
Axes -> False, FrameLabel -> {"x", "y"},
PlotLegends ->
Placed[LineLegend[{"a=1200, b=700, c=150", "a=1100, b=700, c=150",
"a=1200,b=650, c=140",
"a=1150, b=600, c = 140"},(*LegendFunction\[Rule]"Frame",*)
LegendMarkerSize -> 20, LabelStyle -> Directive[Bold, fontsize],
LegendLayout -> "Column"], Right]]
Has someone done something like this before?
Thank you!