3
$\begingroup$

Question 1 I have a plot which consists of six curves, and I wanted to differentiate these line without using any color. I the only option that I left with is to use different line style. After looking at the documentation I only come up with these three, but I have six curves? how to do this?

Question 2 Out of these six plots, bottom three curves I have to name as mode shapes, the upper three curves as non-dimensional frequency. And there is a no horizontal line crossing at y=0; how to fix this?

ClearAll["Global`*"];
s1 = {4.76592, 4.80264, 4.84021, 4.87866, 4.91803, 4.95834, 4.99961, 
   5.04189, 5.08519, 5.12956, 5.17503, 5.22163, 5.26941, 5.31839, 
   5.36862, 5.42013, 5.47298, 5.52719, 5.58282, 5.63992, 5.69852, 
   5.75867, 5.82042, 5.88383, 5.94893, 6.01577, 6.08441, 6.15488, 
   6.22724, 6.30151, 6.37773, 6.45593, 6.53613, 6.61831, 6.70246, 
   6.78854, 6.87645, 6.96606, 7.05715, 7.14942, 7.24241, 7.33546, 
   7.42764, 7.51761, 7.60347, 7.6826, 7.7515, 7.80584, 7.84099, 
   7.8532, 7.84099, 7.80584, 7.7515, 7.6826, 7.60347, 7.51761, 
   7.42764, 7.33546, 7.24241, 7.14942, 7.05715, 6.96606, 6.87645, 
   6.78854, 6.70246, 6.61831, 6.53613, 6.45593, 6.37773, 6.30151, 
   6.22724, 6.15488, 6.08441, 6.01577, 5.94893, 5.88383, 5.82042, 
   5.75867, 5.69852, 5.63992, 5.58282, 5.52719, 5.47298, 5.42013, 
   5.36862, 5.31839, 5.26941, 5.22163, 5.17503, 5.12956, 5.08519, 
   5.04189, 4.99961, 4.95834, 4.91803, 4.87866, 4.84021, 4.80264, 
   4.76592};

s2 = {7.91294, 7.97447, 8.03787, 8.10242, 8.17017, 8.23608, 8.30852, 
   8.38107, 8.45563, 8.53225, 8.61098, 8.69187, 8.77496, 8.8603, 
   8.94792, 9.03787, 9.13018, 9.22488, 9.32199, 9.42152, 9.52347, 
   9.62782, 9.7345, 9.84343, 9.95447, 10.0674, 10.1818, 10.2973, 
   10.4131, 10.528, 10.6403, 10.7472, 10.8444, 10.9251, 10.9794, 
   10.995, 10.9619, 10.8794, 10.7575, 10.6107, 10.4515, 10.2891, 
   10.1298, 9.97812, 9.83806, 9.71347, 9.60863, 9.52835, 9.47753, 
   9.46008, 9.47753, 9.52835, 9.60863, 9.71347, 9.83806, 9.97812, 
   10.1298, 10.2891, 10.4515, 10.6107, 10.7575, 10.8794, 10.9619, 
   10.995, 10.9794, 10.9251, 10.8444, 10.7472, 10.6403, 10.528, 
   10.4131, 10.2973, 10.1818, 10.0674, 9.95447, 9.84343, 9.7345, 
   9.62782, 9.52347, 9.42152, 9.32199, 9.22488, 9.13018, 9.03787, 
   8.94792, 8.8603, 8.77496, 8.69187, 8.61098, 8.53225, 8.45563, 
   8.38107, 8.30852, 8.23794, 8.17017, 8.10242, 8.03741, 7.97447, 
   7.91294};

s3 = {11.0794, 11.1662, 11.2555, 11.3489, 11.4432, 11.5415, 11.6428, 
   11.7471, 11.8545, 11.965, 12.0786, 12.1953, 12.3151, 12.4381, 
   12.5641, 12.6931, 12.825, 12.9595, 13.0965, 13.2354, 13.3757, 
   13.5164, 13.6558, 13.7914, 13.9186, 14.0295, 14.11, 14.1365, 
   14.0811, 13.9338, 13.7184, 13.4721, 13.2245, 12.9965, 12.8054, 
   12.6674, 12.5945, 12.5884, 12.6394, 12.7332, 12.8573, 13.0026, 
   13.1625, 13.3323, 13.5074, 13.6822, 13.8488, 13.9943, 14.0984, 
   14.1372, 14.0984, 13.9943, 13.8488, 13.6822, 13.5074, 13.3323, 
   13.1625, 13.0026, 12.8573, 12.7332, 12.6394, 12.5884, 12.5945, 
   12.6674, 12.8054, 12.9965, 13.2245, 13.4721, 13.7184, 13.9338, 
   14.0811, 14.1365, 14.11, 14.0295, 13.9186, 13.7914, 13.6558, 
   13.5164, 13.3757, 13.2354, 13.0965, 12.9595, 12.825, 12.6931, 
   12.5641, 12.4381, 12.3151, 12.1953, 12.0786, 11.965, 11.8545, 
   11.7471, 11.6428, 11.5415, 11.4432, 11.348, 11.2555, 11.1667, 
   11.0794};

z1 = Table[i, {i, 0.01, 0.99, 0.01}];
data1 = Transpose[{z1, s1}];
data2 = Transpose[{z1, s2}];
data3 = Transpose[{z1, s3}];
peaks1 = FindPeaks[s1];
peaks2 = FindPeaks[s2];
peaks3 = FindPeaks[s3];
mark1 = {{0.50, 7.8532}};
mark2 = {{0.36, 10.995}, {0.64, 10.995}};
mark3 = {{0.28, 14.1365}, {0.50, 14.1372}, {0.72, 14.1365}};

mark4 = {{0.50, 0}};
mark5 = {{0.36, 0}, {0.64, 0}};
mark6 = {{0.28, 0}, {0.50, 0}, {0.72, 0}};
p1 = ListPlot[data1, Joined -> True, 
   PlotStyle -> {Black, Thickness[0.004], Dashing[Tiny]}, 
   AxesStyle -> Black, PlotRange -> All];
p2 = ListPlot[data2, Joined -> True, 
   PlotStyle -> {Black, Thickness[0.004], Dashing[Large]}, 
   AxesStyle -> Black, PlotRange -> All];
p3 = ListPlot[data3, Joined -> True, 
   PlotStyle -> {Black, Thickness[0.004]}, AxesStyle -> Black, 
   PlotRange -> All];

p4 = Graphics[{Text[Style["\[EmptyUpTriangle]", 25], #] & /@ mark1}];
p5 = Graphics[{Text[Style["\[EmptyCircle]", 25], #] & /@ mark2}];
p6 = Graphics[{Text[Style["\[EmptySquare]", 25], #] & /@ mark3}];
p7 = Graphics[{Text[Style["\[EmptyUpTriangle]", 25], #] & /@ mark4}];
p8 = Graphics[{Text[Style["\[EmptyCircle]", 25], #] & /@ mark5}];
p9 = Graphics[{Text[Style["\[EmptySquare]", 25], #] & /@ mark6}];


L = 1;
beta1 = {4.7300, 7.8532, 10.9956, 14.1372};
modefunction = ((Cos[b*x2] - 
      Cosh[b*x2]) - (((Cos[b*L] - Cosh[b*L])/(Sin[b*L] - 
         Sinh[b*L]))*(Sin[b*x2] - Sinh[b*x2])));
m3 = modefunction /. b -> beta1[[2]];
m4 = modefunction /. b -> beta1[[3]];
m5 = modefunction /. b -> beta1[[4]];
p10 = Plot[m3, {x2, 0, L}, 
   PlotStyle -> {Black, Thickness[0.004], Dashing[Tiny]}, 
   AxesStyle -> Black, PlotRange -> All];
p11 = Plot[m4, {x2, 0, L}, 
   PlotStyle -> {Black, Thickness[0.004], Dashing[Large]}, 
   AxesStyle -> Black, PlotRange -> All];
p12 = Plot[m5, {x2, 0, L}, PlotStyle -> {Black, Thickness[0.004]}, 
   AxesStyle -> Black, PlotRange -> All];
fig = Show[p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, 
   PlotRange -> All, AxesStyle -> Black, 
   Frame -> {{True, True}, {True, False}}, 
   FrameLabel -> {"Beam Length", "Non-dimensional \[Beta]", , 
     "Mode Shapes"}, PlotLabel -> None, 
   LabelStyle -> {FontFamily -> "Arial", 40, GrayLevel[0]}];
fig = Style[fig, GraphicsBoxOptions -> {ImageSize -> 1000}]
$\endgroup$
5
$\begingroup$

You can use PlotTheme -> "Monochrome" as follows:

{if1, if2, if3} = Interpolation /@ {data1, data2, data3};  

Quiet@Plot[{ m3, m4, m5, if1[x2], if2[x2], if3[x2]}, {x2, 0, L}, 
   PlotTheme -> "Monochrome", AxesStyle -> Black, PlotRange -> All, 
   PlotLegends -> LineLegend[{"m3", "m4", "m5", "data1", "data2", "data3"}], 
   ImageSize -> Large, Frame -> True, Axes -> False, 
   GridLines -> {None, {0, 5}}, 
   GridLinesStyle -> Directive[Gray, Dashing[{}]], 
   FrameLabel -> {{StringPadLeft["Non-dimensional β", 60], 
      StringPadRight[ "Mode shapes", 70]}, {"Beam Length", None}}, 
   Epilog -> ListPlot[{data1, data2, data3}, MaxPlotPoints -> 30, 
      PlotStyle -> Black, PlotTheme -> {"OpenMarkers"}][[1]]]

enter image description here

Use Epilog -> (First /@ {p4, p5, p6, p7, p8, p9}) to get

enter image description here

$\endgroup$
  • $\begingroup$ actually, I have marked some maximum points in my OP, where I have used the triangle, circle, and squares. Now the thing is even we have a limited number of markers right. How to mark these point differentely $\endgroup$ – acoustics Feb 6 at 7:30
  • $\begingroup$ I used your code, But I am getting some unnecessary horizontal line near 5. How to avoid this $\endgroup$ – acoustics Feb 6 at 7:38
  • 1
    $\begingroup$ @acoustics, use Epilog -> (First /@ {p4, p5, p6, p7, p8, p9}) to add your markers, and use GridLines -> {None, {0}} to remove the horizontal line at 5. $\endgroup$ – kglr Feb 6 at 7:50
  • 1
    $\begingroup$ @acoustics, try PlotLegends -> Placed[LineLegend[{"m3", "m4", "m5", "data1", "data2", "data3"}, LegendLayout -> {"Row", 1}], Top] $\endgroup$ – kglr Feb 6 at 9:38
  • 1
    $\begingroup$ @acoustics, replace Top with Scaled[{.5, 1.}] and add the option PlotRangeClipping->False. $\endgroup$ – kglr Feb 6 at 9:55

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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