0
$\begingroup$

I have the following code:

Show[LogLinearPlot[fpN, {t, 0.01, 10000}], 
 LogLinearPlot[fpS, {t, 0.01, 10000}], 
 ListLogLinearPlot[Table[dataa[[i]], {i, 1, 8}], 
  PlotMarkers -> {Automatic, 13}, AspectRatio -> 1 , 
  PlotLegends -> 
   Placed[{87, 85, 80, 75, 70, 65, 60, 55}, {0.14, 0.66}]], 
 Frame -> True, PlotRange -> All, Axes -> False, AspectRatio -> 1, 
 FrameStyle -> Directive[Black, 13], 
 FrameLabel -> {Style["x axis", 16], 
   Style["y axis", 16]}]

which gives me the following Figure:

figure

How can I put the markers and the curve figures of the same color in this code?. As an example in the figure the 55 data is a yellow rhombus but the line is red. The data at 60 is a blue square but its line is green. Similar for the other data.

Edit: Just for clarification purposes fpN plots the data from 87 to 75, fpS plots the data from 70 to 55 abd dataa[[i]] contains the data that I am plotting as markers

Thank you?

$\endgroup$

1 Answer 1

2
$\begingroup$

EDIT:

I added in PlotStyle -> ColorData[97] to the final ListLogLinearPlot. As BrettChampion mentioned, this will prevent issues if the default colour scheme ever changes. Also, I would generally recommend the first set of code if it works as it's a bit cleaner, but the second set of code should work if the first doesn't because fpN and fpS contain something unusual.

Original:

Depending on how exactly fpN and fpS are arranged, you could try:

Show[
  LogLinearPlot[
    fpN~Join~fpS, 
    {t, 0.01, 10000}
  ],
  ListLogLinearPlot[
    Table[dataa[[i]], {i, 1, 8}], 
    PlotMarkers -> {Automatic, 13}, 
    AspectRatio -> 1 , 
    PlotLegends -> Placed[{87, 85, 80, 75, 70, 65, 60, 55}, {0.14, 0.66}]
  ], 
  Frame -> True, PlotRange -> All, Axes -> False, AspectRatio -> 1, 
  FrameStyle -> Directive[Black, 13], 
  FrameLabel -> {Style["x axis", 16], Style["y axis", 16]}
]

which would join the two datasets and allow the automatic colouring to resolve the individual colours. You could also specify the colours directly:

Show[
  LogLinearPlot[
    fpN, 
    {t, 0.01, 10000},
    PlotStyle -> ColorData[97]/@{1, 2, 3, 4}
  ],
  LogLinearPlot[
    fpS,
    {t, 0.01, 10000},
    PlotStyle -> ColorData[97]/@{5, 6, 7, 8}
  ],
  ListLogLinearPlot[
    Table[dataa[[i]], {i, 1, 8}], 
    PlotMarkers -> {Automatic, 13}, 
    AspectRatio -> 1 , 
    PlotStyle -> ColorData[97],
    PlotLegends -> Placed[{87, 85, 80, 75, 70, 65, 60, 55}, {0.14, 0.66}]
  ], 
  Frame -> True, PlotRange -> All, Axes -> False, AspectRatio -> 1, 
  FrameStyle -> Directive[Black, 13], 
  FrameLabel -> {Style["x axis", 16], Style["y axis", 16]}
]

where ColorData[97] is the default Mathematica colouring scheme. There's over 100 built-in swatch colour schemes, and you can also make up lists of your own colours if you'd like more control over the colouring.

$\endgroup$
3
  • 1
    $\begingroup$ If you explicitly set the colors in some plots, go ahead and do it in all of them since the defaults occasionally change... $\endgroup$ Commented May 7, 2020 at 3:51
  • $\begingroup$ @MassDefect Thank you! Both suggestions work excellent! I appreciate your help! $\endgroup$
    – John
    Commented May 7, 2020 at 3:52
  • $\begingroup$ @BrettChampion You're right, I should have set it for the last plot as well. I'll add it in. $\endgroup$
    – MassDefect
    Commented May 7, 2020 at 4:02

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.