Summary
I am currently attempting to make some of my earlier plots more fit for black-and-white printing, while keeping color and typesetting in TeX/Latin Modern Roman. While at it, I tried to highlight certain data points by adding PlotMarkers to both legend and plot.
Very close to what I wanted was the answer given for the question How to use PlotMarkers or Mesh with Plot to creat Marks on the plot, but I have a lot of trouble getting MaTeX to work with it. So far, I lose both my axis labels and the plot markers (as they can be seen in the linked answer) in the legend.
Details
I'm currently basing it all on the first suggestion of that answer, because I have trouble even understanding what the second part is doing, as I'm still somewhat new to Wolfram's syntax. Adding to that the warnings of Michael E2 regarding his own suggestion, I thought the first is probably a safer bet, anyway. I might be wrong here, so if my goal is more easily reached with the second idea, help with that would be appreciated.
This is what I managed:
ClearAll[markerMesh];
SetAttributes[markerMesh, HoldAll];
Needs["MaTeX`"]
texStyle = {FontFamily ->
"Latin Modern Roman 7"};(* This may need changing depending on the \
OS and its naming of Latin Roman fonts.*)
markerMesh[Plot[fns_List, {x_, x1_, x2_}, opts : OptionsPattern[]],
markerOpts : OptionsPattern[]] :=
Show[
Plot[fns, {x, x1, x2},
Evaluate@FilterRules[{opts}, Except[{Mesh}]],
PlotLegends -> {MaTeX["\\eta=1"], MaTeX["\\sin(D)"],
MaTeX["\\cos(D)"], MaTeX["\\log(D)"], MaTeX["J_0(D)"]},
AxesLabel -> {MaTeX["D"], MaTeX["\\eta"]}],(* Plot Options End;
Here I get the Legend TeXed*)
ListPlot[MapThread[
Table[{x, #}, {x,
Replace[#2,
n_Integer :>
Rescale[N@Range[1, n], {0, n + 1}, {x1, x2}]]}] &, {fns,
PadRight[{}, Length[fns],
Replace[OptionValue[Plot, {opts}, Mesh], n_Integer :> {n}]]}],
FilterRules[{opts}, Options[ListPlot]],
FilterRules[{markerOpts}, Except[{PlotLegends}]]],(*
ListPlot Options End*)
ListLinePlot[{{}, {}}, FilterRules[{opts}, Options[ListPlot]],
markerOpts],(*ListLinePlot Options End *)
BaseStyle -> texStyle,
LabelStyle -> {}](* Show Options End; End markerMesh definition*)
markerMesh[Plot[{1, Sin[D], Cos[D], Log[D], BesselJ[0, D]}, {D, 3, 16},
PlotRange -> Full,
GridLinesStyle -> Directive[Dotted, Gray],
GridLines -> Automatic,
PlotTheme -> {"Detailed", "Monochrome", "ThickLines", "Vibrant"},
Mesh -> {Range[3, 16, 1], Range[3, 16, 1], Range[3, 16, 1],
Range[3, 16, 1], Range[3, 16, 1]}],(* End inner plot options*)
PlotMarkers -> {Automatic, 16},
BaseStyle -> {}]
So far, I have not managed to get either the PlotMarkers back into the legend, nor the axis labels, at all. Depending where I change what and in what combination, very unexpected behavior occurs. Deleting the last BaseStyle, for example, changes the marker color to black.
Related: At some point, I intend to start changing which ticks appear on the x-axis (what I labelled "D"), but given my rather erratic trial-and-error for just the typesetting: How can I decide where this would have to be included as an option? For example, only with trial-and-error did I learn that the option ImageSize -> Automatic -> 1024 would have to be added to the Plot when markerMesh is called, not as an option to markerMesh itself.
Questions
- How to get the plot markers back into the legend?
- How to have axis labels?
- Bonus: Explanation/Guidance on how to decide which options (or combination of options) to change when further changing the plot...
