1
$\begingroup$

Question 1

How to place the legend on top of the plot, I used Placed function to put a legend on top of the plot, but it is not working.

Question 2 The moment If I export the end result of this program to eps and import this eps in latex it is very difficult to differentiate between various line styles, how to overcome this?

Question 3 How to make the plot aesthetically good for journal paper using Mathematica

ClearAll["Global`*"];
SetDirectory[NotebookDirectory[]];
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]", 30], #] & /@ mark1}];
p5 = Graphics[{Text[Style["\[EmptyCircle]", 30], #] & /@ mark2}];
p6 = Graphics[{Text[Style["\[EmptySquare]", 30], #] & /@ mark3}];
p7 = Graphics[{Text[Style["\[EmptyUpTriangle]", 30], #] & /@ mark4}];
p8 = Graphics[{Text[Style["\[EmptyCircle]", 30], #] & /@ mark5}];
p9 = Graphics[{Text[Style["\[EmptySquare]", 30], #] & /@ 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];

{if1, if2, if3} = Interpolation /@ {data1, data2, data3};
fig = Quiet@
   Plot[{m3, m4, m5, if1[x2], if2[x2], if3[x2]}, {x2, 0, L}, 
    PlotTheme -> "Monochrome", AxesStyle -> Black, PlotRange -> All, 
    PlotLegends -> 
     Placed[LineLegend[{"mode 2", "mode 3", "mode 4", 
        "\!\(\*SubscriptBox[\(\[Beta]\), \(1\)]\)", 
        "\!\(\*SubscriptBox[\(\[Beta]\), \(2\)]\)", 
        "\!\(\*SubscriptBox[\(\[Beta]\), \(3\)]\)"}, 
       LegendLayout -> {"Row", 1}], Top], ImageSize -> {1200, 1200}, 
    Frame -> True, Axes -> False, GridLines -> {None, {0, 5}}, 
    GridLinesStyle -> Directive[Gray, Dashing[{}]], 
    FrameLabel -> {{StringPadLeft["Non-dimensional \[Beta]", 35], 
       StringPadRight["Mode shapes", 38]}, {"Beam Length", None}}, 
    LabelStyle -> {FontFamily -> "Arial", 45, GrayLevel[0]}, 
    Epilog -> (First /@ {p4, p5, p6, p7, p8, p9}), 
    PlotStyle -> {Black, Thickness[0.006]}];
fig = Style[fig, GraphicsBoxOptions -> {ImageSize -> {1200, 1200}}]
$\endgroup$
  • 1
    $\begingroup$ for question 1: try changing Top to {.5,1} and PlotStyle->{Black,Thickness[0.006]} to PlotStyle -> Directive[Black, Thickness[0.006]] $\endgroup$ – kglr Feb 6 at 10:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.