4
$\begingroup$

I would like to plot some functions with different line styles(dot,dash,points,etc). Where I can handle the color for example in black and the size.

This is the code.

Plot[{1 - Exp[-t], 1 - Exp[-1/2 t], 1 - Exp[-2/3 t], 
   1 - Exp[-3/4 t]}, {t, 0, 10},  
   PlotLegends -> {"q \[Rule] 1 ", "q=1/2 ", "q=2/3",  "q=3/4 "}, 
   PerformanceGoal -> "Quality", PlotStyle -> {{Black, Dashed, Dot}},
   LabelStyle -> Directive[Bold, FontFamily -> "Arial"], 
  AxesLabel -> {"\[Tau] (a.u)", "\!\(\*SubscriptBox[\(r\), \(q\)]\)"}]
$\endgroup$
2
  • 1
    $\begingroup$ PlotStyle -> {{Black}, {Black, Dashed}, {Black, Dotted}, {Black, Dashing[1/5, 0]}} $\endgroup$
    – Domen
    Sep 8, 2023 at 11:01
  • $\begingroup$ Try e.g.: PlotStyle -> {{Black}, {Blue, Dashing[{0.04, 0.01}]}, {Green, Dashing[{0.03, 0.01}]}, {Orange, Dashed, Dot}}, LabelStyle -> Directive[Bold, FontFamily -> "Arial"] $\endgroup$ Sep 8, 2023 at 11:10

2 Answers 2

8
$\begingroup$
fun = {1 - Exp[-t], 1 - Exp[-1/2 t], 1 - Exp[-2/3 t], 1 - Exp[-3/4 t]};

Plot[fun, {t, 0, 10},
 PlotLegends -> {"q=1 ", "q=1/2 ", "q=2/3", "q=3/4 "},
 PerformanceGoal -> "Quality",
 PlotStyle -> {{Black}, {Black, Dashed}, {Black, Dotted}, {Black, Dashing[1/20, 0]}}, 
 LabelStyle -> Directive[Bold, FontFamily -> "Arial"],
 AxesLabel -> {"\[Tau] (a.u)", "\!\(\*SubscriptBox[\(r\), \(q\)]\)"}]

enter image description here

Alternatively, you can use PlotTheme -> "Monochrome"

Plot[fun, {t, 0, 10},
 PlotLegends -> {"q \[Rule] 1 ", "q=1/2 ", "q=2/3", "q=3/4 "},
 PerformanceGoal -> "Quality",
 PlotTheme -> "Monochrome",
 LabelStyle -> Directive[Bold, FontFamily -> "Arial"],
 AxesLabel -> {"\[Tau] (a.u)", "\!\(\*SubscriptBox[\(r\), \(q\)]\)"}]

enter image description here

And you can use ListLinePlot as follows:

tab = Transpose @ Table[fun, {t, 0, 10, 0.5}];

ListLinePlot[tab,
 PlotLegends -> {"q \[Rule] 1 ", "q=1/2 ", "q=2/3", "q=3/4 "},
 PlotMarkers -> "OpenMarkers",
 PlotStyle -> Black]

enter image description here

Addendum

There is an old answer of @kglr which combines Plot and markers:

Plot with plot markers without using ListPlot

markers = {\[FilledSmallSquare], \[EmptyDownTriangle], \[FilledUpTriangle], \[SixPointedStar], ""};

Module[{i = 1, j},
 Plot[fun, {t, 0, 10},
   PlotPoints -> 48,
   MaxRecursion -> 0,
   PlotStyle -> {GrayLevel[0.00], GrayLevel[0.01], GrayLevel[0.02], 
     GrayLevel[0.03]},
   PlotLegends -> LineLegend["Expressions",
     Joined -> False,
     LegendMarkers -> markers]] /. 
  Line[x_] :> (j = i++; {{Thickness[0.001], 
      Line[x]}, (Inset[markers[[j]], #] & /@ x)})]

enter image description here

$\endgroup$
1
$\begingroup$
$Version

(* "13.3.1 for Mac OS X ARM (64-bit) (July 24, 2023)" *)

Clear["Global`*"]

f[q_, t_] := 1 - Exp[-q*t]

qValues = ReverseSortBy[{1, 1/2, 2/3, 3/4}, N];

Plot[Evaluate[f[#, t] & /@ qValues],
 {t, 0, 10},
 PlotLegends -> Placed[
   (StringForm["q\[ThinSpace]=\[ThinSpace]``", #] & /@ qValues),
   {.8, .45}],
 PerformanceGoal -> "Quality",
 PlotStyle ->
  ({Black, #} & /@ {Black, DotDashed, Dotted, Dashed}),
 LabelStyle -> Directive[Bold, FontFamily -> "Arial"],
 AxesLabel -> {"τ (a.u)", "\!\(\*SubscriptBox[\(r\), \(q\)]\)"}]

enter image description here

$\endgroup$

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.