4

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\)]\)"}]
eldo
  • 67,911
  • 5
  • 60
  • 168
irondonio
  • 545
  • 2
  • 9
  • 1
    PlotStyle -> {{Black}, {Black, Dashed}, {Black, Dotted}, {Black, Dashing[1/5, 0]}} – Domen Sep 08 '23 at 11:01
  • 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"] – Daniel Huber Sep 08 '23 at 11:10

2 Answers2

8
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

eldo
  • 67,911
  • 5
  • 60
  • 168
1
$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

Bob Hanlon
  • 157,611
  • 7
  • 77
  • 198