# Accessing Plot's default formatting [duplicate]

I'd like to plot multiple sets of data, along with trend line fits for each. I can do this by plotting the fits, and then including the data in an Epilog. But I'd like the color of the data points to match the color of the curves in Plot. Is there an easy way to access the default colors of plots?

I've done what I want here: But, I had to do clunky things. First, I assigned the output of the Plot to a variable out. Then in the Epilog, I called stuff like out[[1, 1, 2, 1, 2, 2, 2]] to get the correct color. There has to be a better way.

TIA

• Maybe not quite what you asked, but an easy way to extract the colors used in some plot is to use out//Cases[#,_RGBColor,Infinity]&. More generally if you want the colors to be the same you can combine the ListPlot and Plot with Show, specifying in both the same list of colors to be used for the plot (using the PlotStyle option)
– glS
Jul 12, 2016 at 23:09
• The default color of Plot can be found here. Jul 12, 2016 at 23:43
• In addition to the two marked duplicates (links inserted above your question) you may find (17252) of interest, especially xslittlegrass's restylePlot2. Please try to apply what you learn from all of these to your problem. If you have trouble let me know and I'll try to help; if I can't you can post a new question. Jul 13, 2016 at 5:50
• Thanks all. Sorry about the dup. Jul 13, 2016 at 13:40

Use Show to combine a ListPlot of the data and Plot of the fit functions. If the data is listed in the same order as the fit functions then the data will match the fit color.

dataA = {{0, 21}, {4, 18}, {9, 10}};
dataB = {{0, 45}, {5, 44}, {10, 38}};
dataC = {{0, 32}, {6, 22}, {11, 26}};

fitA = LinearModelFit[dataA, x, x];
fitB = LinearModelFit[dataB, x, x];
fitC = LinearModelFit[dataC, x, x];

Show[
Plot[{fitA[x], fitB[x], fitC[x]}, {x, 0, 12},
PlotLabels -> {"Data A", "Data B", "Data C"}, AxesOrigin -> {0, 0}],
ListPlot[{dataA, dataB, dataC}]
] • You can just use Plot[{modelA /. fitA, modelB /. fitB}, {x, 0, 10}], instead of going to the effort to create a function that you can pass the variable x to. Jul 13, 2016 at 0:37
• …and if you use LinearModelFit[], you can get a function that is quite easily plotted. Jul 13, 2016 at 0:51