TransWikia.com

Please help me designing my graph

Mathematica Asked by Kristina on May 11, 2021

Please, help moving the digits up to the φ-axis like on the second screenshot. Thank you in advance.

Plot[
 With[{z = 1.1*E^(I u) + 0.908*E^(-I u)}, 
  Re[z] + 0.78*Log[Abs[z - 2]] + 0.64*Log[Abs[z - 1]] + 
   0.254*Log[Abs[z^2 - z - 1]] + 0.173*Log[Abs[z]]], {u, -15, 15},
 PlotStyle -> {Black},
 PlotRange -> {{-8, 8}, {-2, 1}},
 AspectRatio -> 1,
 AxesLabel -> (Style[#, 14] & /@ {"[CurlyPhi]", "f"}),
 GridLines -> {Range[-8, 8, .5], Range[-2, 1, .2]},
 Frame -> True,
 FrameTicks -> {{Range[-2, 1, .2], Automatic}, {Range[-8, 8, .5], 
    Automatic}}, 
 PlotLabel -> 
  Style[TraditionalForm[
    HoldForm[
     Re[z] + 0.78*ln[Abs[z - 2]] + 0.64*ln[Abs[z - 1]] + 
       0.254*ln[Abs[z^2 - z - 1]] + 0.173*ln[Abs[z]] <= 0.3999]], 
   "TR", Black, 14],
 ImageSize -> Large]

enter image description here

enter image description here

2 Answers

Ticks and Frame don't play well together. This get's you part of the way (Note edited 1 Dec 11:20 PM EST) ...

    Plot[
 With[{z = 1.1*E^(I u) + 0.908*E^(-I u)}, 
  Re[z] + 0.78*Log[Abs[z - 2]] + 0.64*Log[Abs[z - 1]] + 
   0.254*Log[Abs[z^2 - z - 1]] + 0.173*Log[Abs[z]]], {u, -15, 15},
 PlotStyle -> {Black},
 PlotRange -> {{-8, 8}, {-2, 1}},
 AspectRatio -> 1,
 AxesLabel -> (Style[#, 14] & /@ {"[CurlyPhi]", "f"}),
 GridLines -> {Range[-8, 8, .5], Range[-2, 1, .2]},
 
 AxesOrigin -> {-8, 0},
 Ticks -> {Range[-8, 8, .5], Range[-2, 1, .2]},
 
 (* Frame->True, *)
 (* FrameTicks->{{Range[-2,1,.2],Automatic},None}, *)
 
 PlotLabel -> 
  Style[TraditionalForm[
    HoldForm[
     Re[z] + 0.78*ln[Abs[z - 2]] + 0.64*ln[Abs[z - 1]] + 
       0.254*ln[Abs[z^2 - z - 1]] + 0.173*ln[Abs[z]] <= 0.3999]], 
   "TR", Black, 14],
 ImageSize -> Large]

enter image description here

The solution does not have a Frame as your original solution did, perhaps someone can suggest how to add one (See new edit below).

I'll give it some more thought.

After some more thought a bit of a funky solution messing around with GridLines to give the Plot a pseudo Frame. I welcome any more elegant suggestions ;-) ...

Plot[
 With[{z = 1.1*E^(I u) + 0.908*E^(-I u)}, 
  Re[z] + 0.78*Log[Abs[z - 2]] + 0.64*Log[Abs[z - 1]] + 
   0.254*Log[Abs[z^2 - z - 1]] + 0.173*Log[Abs[z]]], {u, -15, 15},
 PlotStyle -> {Black},
 PlotRange -> {{-8, 8}, {-2, 1}},
 AspectRatio -> 1,
 AxesLabel -> (Style[#, 14] & /@ {"[CurlyPhi]", "f"}),
 GridLines -> {AppendTo[
    Range[-8, 7.5, .5], {8, {Thickness[0.0025], Black}}],
   AppendTo[
    AppendTo[
     Range[-2, 
      0.8, .2], {1, {Thickness[0.0005], Black}}], {-2, {Thickness[
       0.0005], Black}}]},
 AxesOrigin -> {-8, 0},
 Ticks -> {Range[-8, 8, .5], Range[-2, 1, .2]},
 PlotLabel -> 
  Style[TraditionalForm[
    HoldForm[
     Re[z] + 0.78*ln[Abs[z - 2]] + 0.64*ln[Abs[z - 1]] + 
       0.254*ln[Abs[z^2 - z - 1]] + 0.173*ln[Abs[z]] <= 0.3999]], 
   "TR", Black, 14],
 ImageSize -> Large]

enter image description here

Answered by Jagra on May 11, 2021

Define a function that constructs ticks and labels from a list of horizontal tick positions and a value for the vertical position:

ClearAll[newTicks]
newTicks[lst_, y_: 0] := {AbsoluteThickness[0.5], GrayLevel[.4], 
   Line[{#, Offset[{0, 5}, #]}],
   Text[Framed[Style[#[[1]], GrayLevel[.4]], FrameMargins -> 0, 
      FrameStyle -> None, Background -> White], Offset[{0, -5}, #], {0, 1}]} & /@ 
   Thread[{lst, y}];

Use newTicks[Rest[Range[-8, 8, .5]]] as Epilog in your plot and add the option FrameTicksStyle to make the tick labels in lower frame invisible (FontOpacity -> 0):

Plot[With[{z = 1.1*E^(I u) + 0.908*E^(-I u)}, 
  Re[z] + 0.78*Log[Abs[z - 2]] + 0.64*Log[Abs[z - 1]] + 
   0.254*Log[Abs[z^2 - z - 1]] + 0.173*Log[Abs[z]]], {u, -15, 15}, 
 PlotStyle -> {Black}, PlotRange -> {{-8, 8}, {-2, 1}}, 
 AspectRatio -> 1, 
 AxesLabel -> (Style[#, 14] & /@ {"φ", "f"}), 
 GridLines -> {Range[-8, 8, .5], Range[-2, 1, .2]}, Frame -> True, 
 FrameTicks -> {{Range[-2, 1, .2], Automatic}, {Range[-8, 8, .5], Automatic}},
 FrameTicksStyle -> {{Automatic, Automatic}, {FontOpacity -> 0, Automatic}},
 Epilog -> newTicks[Rest[Range[-8, 8, .5]]], 
 PlotLabel -> Style[TraditionalForm[HoldForm[
     Re[z] + 0.78*ln[Abs[z - 2]] + 0.64*ln[Abs[z - 1]] + 
       0.254*ln[Abs[z^2 - z - 1]] + 0.173*ln[Abs[z]] <= 0.3999]], 
   "TR", Black, 14], ImageSize -> 700]

enter image description here

Use Epilog -> newTicks[Rest[Range[-8, 8, .5]], -1] and add the option AxesOrigin -> {-4, -1} to get:

enter image description here

Answered by kglr on May 11, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP