I don't understand how to modify the ColorData in the mapIndexed for the code from another post found here and is copied below for reference. What I want to do is control the color of each trace as well as its style (e.g., bold, dashed).
My main problem is I do not understand what "[#2[[1]]]" is doing. I understand what a slot is, but apparently not in this example. Slot one references both datasets, slot 2 gives the first two colors in the ColorData pallet chosen, and slot 3 does not exist.
If I try and force it using PlotStyle -> {{Black,Thick},{Blue,Thick,Dashed}}
in the MapIndexed
function it just takes the first entry for both plots. It also won't match the axes colors for reader reference.
I also tried removing PlotStyle -> {{Black,Thick},{Blue,Thick,Dashed}}
and putting it in the options of the function calling the module the same error occurs.
Any help would be most appreciated!
Module[{fgraph, ggraph, frange, grange, fticks,
gticks}, {fgraph, ggraph} =
MapIndexed[
Plot[#, {x, x1, x2}, Axes -> True,
PlotStyle -> ColorData[1][#2[[1]]]] &, {f, g}]; {frange,
grange} = (PlotRange /. AbsoluteOptions[#, PlotRange])[[
2]] & /@ {fgraph, ggraph}; fticks = N@FindDivisions[frange, 5];
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}}]]```
CombinePlots
. $\endgroup$ResourceFunction["CombinePlots"][p111, p222, "AxesSides" -> "TwoY"]
$\endgroup$