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$
0

1 Answer 1

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}]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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