1
$\begingroup$
 Datah7 = {{0.00005, 109142}, {0.000064, 104052}, 
 {0.0000829, 98188}, {0.000106, 91608}, {0.000137, 84447}, 
 {0.00017747, 76928}, {0.00793, 130847}, {0.0362, 131598}, 
{0.0467, 131595}, {0.060246, 131595}, {0.077618, 131594}}; 
 h7 = ListLogLinearPlot[Datah7, PlotRange -> All, Frame -> True, 
 FrameLabel -> {" \[Omega]", " \
 (\!\(\*OverscriptBox[SuperscriptBox[SubscriptBox[\(T\), \(c\)], \
 \(2\)], \(_\)]\) - \
  \!\(\*SuperscriptBox[OverscriptBox[SubscriptBox[\(T\), \(c\)], \
  \(_\)], \(2\)]\)) "}, FrameStyle -> Thickness[0.003], 
  LabelStyle -> Directive[Black, Small, Bold], PlotStyle -> Blue, 
  PlotLegends -> Placed[{"h=0.5"}, {0.75, 0.5}], 
PlotMarkers -> {"\[FilledCircle]", 9}, FrameTicks -> 
{Automatic, {xticks, Automatic}}]

In the plot, I want to specify three ticks on the $y$-axis and two ticks on the $x$-axis. I also want the $y$-axis ticks to appear in the form of powers of 10).

Please suggest how can manually specify the frame ticks.

$\endgroup$
1
  • 1
    $\begingroup$ Instead of FrameTicks->Automatic, specify them. Say ->{{10,100,1000},{10,100,1000}}. $\endgroup$
    – Nicholas G
    Mar 23 at 12:31
3
$\begingroup$

I would do it like this:

xticks = {.001, .01};
topticks = {#, ""} & /@ xticks;
yticks = Range[8.*^4, 12.*^4, 2.*^4]; 
lfticks = 
  {#, 
   NumberForm[#, 
     NumberFormat -> (Row[{#1, "×", Superscript[10, #3]}] &), 
     ExponentFunction -> (#1 &)]} & /@ yticks;
rtticks = {#, ""} & /@ yticks;

ListLogLinearPlot[Datah7,
  PlotRange -> All,
  Frame -> True,
  FrameLabel ->
    {"ω",
     Row[{OverBar[Subscript[T, c]^2], "-", OverBar[Subscript[T, c]]^2}]},
  FrameStyle -> Thickness[0.003],
  FrameTicks -> {{lfticks, rtticks}, {xticks, topticks}},
  LabelStyle -> Directive[Black, Small, Bold],
  PlotLegends -> Placed[{"h = 0.5"}, {0.75, 0.5}],
  PlotMarkers -> Style["●", 9, Blue]]

plot

Edit

It has occurred to me that above plot suffers from two deficiencies:

  • The viewer is likely to think that blue circle to the left of the annotation $h = 0.5$ is a 12th data point. I address this issue by introducing an Epilog option into code to add the annotation as a text box.
  • With so few ticks, the viewer needs more help in seeing where the data points really lie in the coordinate space. I address this issue by introducing grid lines into the plot.

With these additional features added, the plot code becomes;

xticks = {.001, .01};
yticks = Range[8.*^4, 12.*^4, 2.*^4]; 
lfticks = 
  {#, NumberForm[#, 
        NumberFormat -> (Row[{#1, "×", Superscript[10, #3]}] &), 
        ExponentFunction -> (#1 &)]} & /@ yticks;

ListLogLinearPlot[Datah7,
  PlotRange -> All,
  Frame -> True,
  FrameLabel ->
    {"ω",
     Row[{OverBar[Subscript[T, c]^2], "-", OverBar[Subscript[T, c]]^2}]},
  FrameStyle -> Thickness[0.003],
  FrameTicks -> {{lfticks, None}, {xticks, None}},
  GridLines -> {xticks, yticks},
  GridLinesStyle -> {{Black, Dashed}, {Black, Dashed}},
  LabelStyle -> Directive[Black, Medium, Bold],
  PlotMarkers -> Style["●", 9, Blue],
  Epilog ->
    Text[
      Style["h = 0.5", Bold, 12, Background -> White],
      Scaled[{.95, .5}],
      {0, 1.6}],
  ImageSize -> Large]

plot

I believe the 2nd plot presents your data more effectively then the 1st one.

Edit 2

The following is added to address an issue raised by the OP in a comment to this answer.

The important thing to keep in mind about specifying frame ticks is that they are given in the order

FrameTicks -> {{leftYTicks, rightYTicks}, {bottomXTicks, topXTicks}}

where each item on the righthand side is a list of tick specifications, which are in themselves lists. If you write each of the specifications manually, you can get completely different ticks on any of the four sides of the frame. Instructions for writing a tick specification are given in the documentation article for Ticks

The important thing to keep in mind when writing a tick specification is that the 2nd item in the specification (referred to as $label_n$ in the documentation) can be just about anything. In particular, a label can be a styled value, a string, a graphics object or a Row expression, which can combine any of the previously mentioned types of objects.

$\endgroup$
4
  • $\begingroup$ Can you also explain how to add ticks on the top of the frame but in the reverse order of the bottom x axis. say at the top I want two ticks first one value will be 0.01 and second will be 0.001. Also they should be in red color. $\endgroup$ Mar 24 at 12:29
  • $\begingroup$ @SachinKaushik. The new issue you raise doesn't make sense to me. Where would the tick showing the value 0.01 be placed if not on the vertical line $x=0.01$? $\endgroup$
    – m_goldberg
    Mar 25 at 3:31
  • $\begingroup$ sir I would like to add ticks on all four sides of the frame and the value of the ticks shall be manually entered by me. Say if I want to add multiple graphs in a single frame and top and right axes number I want to specify accordingly. is there any simple command for that? $\endgroup$ Mar 25 at 7:12
  • $\begingroup$ @SachinKaushik. I have made a 2nd edit which I believe addresses the issue you raise in the above comment. $\endgroup$
    – m_goldberg
    Mar 25 at 13:54
2
$\begingroup$

Replace your specification of FrameTicks with something like FrameTicks -> {{{.0001,"\!\(\*SuperscriptBox[\(1\), \(-10000\)]\)"}, {.001,"\!\(\*SuperscriptBox[\(1\), \(-1000\)]\)"}, .01}, {90000, 110000,130000}}. The superscript boxes are strings "1^-10000" and "1^-1000". Essentially, by adding a pair {value,string} in the tick specifications, you place that string as the tick label.

$\endgroup$

Your Answer

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

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