2
$\begingroup$

I used the following function in order to plot multiple separate graph. How can I integrate PlotStyle in func in order to generate each graphic in different color e.g following "TemperatureMap"?

file = FileNames["*.dat", NotebookDirectory[]];

func[file_String /; FileExistsQ[file]] := 
  Module[{data, formatted}, data = Import[file, "Table"];
   formatted = {{#1, #2}, ErrorBar[#4, #3]} & @@@ data;
   ErrorListPlot[{formatted}, 
    PlotLegends -> Placed[LineLegend[{FileBaseName[file]}], {Right, Bottom}]]];

func /@ file
$\endgroup$
1
$\begingroup$
ClearAll[func2]; 
func2[file_String /; FileExistsQ[file], color_] := Module[{data, formatted}, 
 data = Import[file, "Table"]; formatted = {{#1, #2}, ErrorBar[#4, #3]} & @@@ data;
 ErrorListPlot[{formatted}, 
    PlotLegends -> Placed[LineLegend[{FileBaseName[file]}], {Right, Bottom}], 
    PlotStyle -> color]]; 
colors = ColorData[ "TemperatureMap"] /@ (Range[Length[file]]/Length[file]); 
func2 @@@ Transpose[{file, colors}]
| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.