-1
$\begingroup$

Here is my code:

ListLinePlot[{Transpose[{Flatten[falset1alphav1], 
Flatten[detectiont1alphav1]}], 
Transpose[{Flatten[falset1huberv1], Flatten[detectiont1huberv1]}], 
Transpose[{Flatten[falset1alphav15], Flatten[detectiont1alphav15]}],
Transpose[{Flatten[falset1huberv15], 
Flatten[detectiont1huberv15]}], 
Transpose[{Flatten[falset1alphav2], Flatten[detectiont1alphav2]}], 
Transpose[{Flatten[falset1huberv2], Flatten[detectiont1huberv2]}], 
Transpose[{Flatten[falset08alphav1], Flatten[detectiont08alphav1]}],
Transpose[{Flatten[falset08huberv1], 
Flatten[detectiont08huberv1]}], 
Transpose[{Flatten[falset08alphav15], 
Flatten[detectiont08alphav15]}], 
Transpose[{Flatten[falset08huberv15], 
Flatten[detectiont08huberv15]}], 
Transpose[{Flatten[falset08huberv2], Flatten[detectiont08huberv2]}],
Transpose[{Flatten[falset08huberv2], 
Flatten[detectiont08huberv2]}], 
Transpose[{Flatten[falset1likelihoodv1], 
Flatten[detectiont1likelihoodv1]}], 
Transpose[{Flatten[falset1energyv1], 
Flatten[detectiont1energyv1]}]}, PerformanceGoal -> "Quality", 
PlotMarkers -> {
"", "", "", "", "", 
"", {"+", 18}, {"+", 18}, {"+", 18}, {"+", 18}, {"+", 18}, {"+", 
18}}, PlotStyle -> {{Blue, Thick}, Directive[Orange, Thick], 
Directive[Red, Thick], Directive[Green, Thick], 
Directive[Black, Thick], Directive[Purple, Thick], {Blue, Thick}, 
Directive[Orange, Thick], Directive[Red, Thick], 
Directive[Green, Thick], Directive[Black, Thick], 
Directive[Purple, Thick], Directive[Cyan, Thick, Dashed], 
Directive[Magenta, Thick, Dashed]}, BaseStyle -> 22, 
AspectRatio -> .7, PlotRange -> Automatic, 
AxesStyle -> Arrowheads[0.03], 
AxesLabel -> {Style[\!\(\*SubscriptBox[\(P\), \(F\)]\), 
FontSize -> 21], 
Style[\!\(\*SubscriptBox[\(P\), \("D"\)]\), Italic, 
FontSize -> 21]}, 
PlotLegends -> 
Placed[LineLegend[{{Blue, Thick}, Directive[Orange, Thick], 
Directive[Red, Thick], Directive[Green, Thick], 
Directive[Black, Thick], Directive[Purple, Thick], {Blue, Thick},
Directive[Orange, Thick], Directive[Red, Thick], 
Directive[Green, Thick], Directive[Black, Thick], 
Directive[Purple, Thick], Directive[Cyan, Thick, Dashed], 
Directive[Magenta, Thick, 
  Dashed]}, {"\[Alpha]-div(\[Theta]=1,\!\(\*SubscriptBox[\(\
\[ScriptCapitalU]\), \(1\)]\))", 
 "Huber(\[Theta]=1,\!\(\*SubscriptBox[\(\[ScriptCapitalU]\), \
\(1\)]\))", 
 "\[Alpha]-div(\[Theta]=1,\!\(\*SubscriptBox[\(\[ScriptCapitalU]\)\
, \(2\)]\))", 
 "Huber(\[Theta]=1,\!\(\*SubscriptBox[\(\[ScriptCapitalU]\), \
\(2\)]\))", 
 "\[Alpha]-div(\[Theta]=1,\!\(\*SubscriptBox[\(\[ScriptCapitalU]\)\
, \(3\)]\))", 
 "Huber(\[Theta]=1,\!\(\*SubscriptBox[\(\[ScriptCapitalU]\), \
\(3\)]\))", 
 "\[Alpha]-div(\[Theta]=0.8,\!\(\*SubscriptBox[\(\[ScriptCapitalU]\
\), \(1\)]\))", 
 "Huber(\[Theta]=0.8,\!\(\*SubscriptBox[\(\[ScriptCapitalU]\), \
\(1\)]\))", 
 "\[Alpha]-div(\[Theta]=0.8,\!\(\*SubscriptBox[\(\[ScriptCapitalU]\
\), \(2\)]\))", 
 "Huber(\[Theta]=0.8,\!\(\*SubscriptBox[\(\[ScriptCapitalU]\), \
\(2\)]\))", 
 "\[Alpha]-div(\[Theta]=0.8,\!\(\*SubscriptBox[\(\[ScriptCapitalU]\
\), \(3\)]\))", 
 "Huber(\[Theta]=0.8,\!\(\*SubscriptBox[\(\[ScriptCapitalU]\), \
\(3\)]\))", "Likelihood", "Energy Det."}, 
LegendLayout -> {"Column", 2}, LabelStyle -> 21, 
LegendFunction -> (Framed[#, RoundingRadius -> 2, 
    FrameStyle -> LightGray] &)], {Right, Bottom}], 
GridLines -> Automatic, GridLinesStyle -> LightGray, Joined -> True]

As you can see I have many curves in one listlineplot and I need to use markers for some of them only. The problem is that every curve which needs plotmarkers have many data points inside, lets say 200 or more. Therefore, there are too many plot markers and it seems really so ugly. I need lets say around 20 markers per curve. How can I do this? I checked other questions here but I couldnt solve my problem.

$\endgroup$
4
  • $\begingroup$ It is not a well-formulated question. Please provide a minimal self-contained code sample allowing to reproduce your issue. Also, have you read the Documentation for MaxPlotPoints? This option probably should solve your problem. $\endgroup$ May 7, 2016 at 19:00
  • $\begingroup$ @AlexeyPopkov it is helpful for the ones which require markers but for other curves, the curves seem worse because of the lack of enough data points $\endgroup$ May 7, 2016 at 19:18
  • $\begingroup$ @AlexeyPopkov I need really to reduce the number of plot markers. But this shouldn't degrade the quality of the plot. Your proposal was a solution to reduce the number of plotmarkers but it doesn't preserve the quality. My code is okay up to the data. One can put there any data, it doesn't matter. I cannot upload my data here and it actually doesn't change anything. Put any data with 200-300 samples $\endgroup$ May 7, 2016 at 20:55
  • $\begingroup$ @AlexeyPopkov my code can be evaluated. Just put random data instead of the data in my code. I don't know how to do it, else I would have done it before. I posted here a working code up to the data, which I cannot upload here. I have 64kbit/s and less now. I would at least upload my figure. Replying you from my mobile. $\endgroup$ May 7, 2016 at 21:11

2 Answers 2

5
$\begingroup$

You can post-process to Downsample the set of Insets as in the following example (assuming that all Insets are plot markers):

ClearAll[foo]
foo[n_Integer] = # /. {dir___, insets : Repeated[Inset[___], {1, Infinity}]} :> 
   {dir, (Downsample[{insets}, n])} &;

Example:

lp = ListLinePlot[{Range[20], Range[20] + 2, Range[20] + 4}, 
         PlotMarkers -> {Automatic, 14}, ImageSize -> 300];
lp2 = MapAt[foo[3], lp, {1}];
Row[{lp, lp2}, Spacer[5]]

Mathematica graphics

Row[{#, MapAt[foo[3], #, {1}]}, Spacer[5]] &@
 ListLinePlot[{Range[20], Range[20] + 2, Range[20] + 4}, 
  PlotMarkers -> {"", {"+", 18}, {"+", 18}}, ImageSize -> 300, 
  AxesStyle -> Arrowheads[0.03], 
  AxesLabel -> {Style[Subscript[P, F], FontSize -> 21], Style[
\!\(\*SubscriptBox[\(P\), \("\<D\>"\)]\), Italic, FontSize -> 21]}]

Mathematica graphics

$\endgroup$
1
  • $\begingroup$ that helps alot, Mr. Güler thank you;) $\endgroup$ May 8, 2016 at 0:21
4
$\begingroup$

Here is what I would call the canonical approach to your problem which should work starting from version 6, where Span (;;) was introduced:

data = Table[Table[{x, f}, {x, 0, 2 Pi, 0.03}], {f, {Sin[x], Sin[2 x], Sin[3 x]}}];

pl1 = Show[ListLinePlot[data], 
  (* taking every 15th data point from every dataset *)
  ListPlot[data[[;; , ;; ;; 15]], PlotMarkers -> {Automatic, 14}], 
  ImageSize -> 300, PlotRange -> All]

plot

The same is achievable with the new in version 9 Downsample:

pl2 = Show[ListLinePlot[data], 
  ListPlot[Downsample[data, {1, 15, 1}], PlotMarkers -> {Automatic, 14}], 
  ImageSize -> 300, PlotRange -> All];

pl2 == pl1
True
$\endgroup$
2
  • $\begingroup$ thx for the post. $\endgroup$ Jun 13, 2016 at 3:29
  • $\begingroup$ @Alexey Popkov: How about PlotLegends in such a method? The legend looks different depending on which of the graphs it is added to. If added to both graphs, Show displays two legends. $\endgroup$ Oct 24, 2022 at 2:24

Your Answer

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

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