1
$\begingroup$

I wanted to display all the decades (from 1 to 10^8 like 1 ,10, 10^2, 10^3 etc) in LogLinearPlot and also tried the solution of why-is-listlogplot-skipping-entire-decades.

And my code is something like this:

LogLinearPlot[Vnpre[freq], {freq, 1, 10^8}, 
 PlotStyle -> {Red, Thickness[0.004]}, 
 Frame -> {True, True, False, False}, 
 FrameLabel -> {Style["freq", Medium],Style["Vnpre[V^2/Hz]", Medium]}, 
 Axes -> True, 
 LabelStyle -> Directive[Blue, Thin, Italic] , 
 GridLines -> Automatic, 
 FrameTicks -> {Table[{10^i, Superscript[10, i]}, {i, 0, 10}], Automatic, None, None}]

And plot is like this:

enter image description here

Here, I am not able to see the all decades and also 10^3 is displayed as 1000. Can somebody please help me to correct this code.

$\endgroup$
3
$\begingroup$

You are almost there. Try the option FrameTicksas follows:

    FrameTicks -> {{Automatic, None}, {Table[{10^i, 
         Style[Superscript[10, i], 12, Italic, Blue] },
 {i, 0, 10}],  None}}

Have fun!

Edit:

To address your question of how to remove the decimal points of ticks along the y axis. Instead of the Automatic you might insert this line:

Table[{i*10^-10, 
  ToString[i] <> 
   "\[Times]\!\(\*SuperscriptBox[\(10\), \(-10\)]\)"}, {i, 1, 5}]

You may also play with the style:

Table[{i*10^-10, 
  Style[ ToString[i] <> 
    "\[Times]\!\(\*SuperscriptBox[\(10\), \(-10\)]\)", 12, Blue]}, {i,
   1, 5}]

Try this altogether:

freq = Exp[x];
LogLinearPlot[
 5*10^-10 (Tanh[(freq - 1000)/5000] + 1)/2, {freq, 1, 10^8}, 
 PlotStyle -> {Red, Thickness[0.004]}, 
 Frame -> {True, True, False, False}, 
 FrameLabel -> {Style["freq", Medium], 
   Style["Vnpre[V^2/Hz]", Medium]}, Axes -> True, 
 LabelStyle -> Directive[Blue, Thin, Italic], GridLines -> Automatic, 
 FrameTicks -> {{Table[{i*10^-10, 
      ToString[i] <> 
       "\[Times]\!\(\*SuperscriptBox[\(10\), \(-10\)]\)"}, {i, 1, 5}],
     None}, {Table[{10^i, 
      Style[Superscript[10, i], 12, Italic, Blue]}, {i, 0, 10}], 
    None}}] 

yielding

enter image description here

Have fun!

| improve this answer | |
$\endgroup$
  • $\begingroup$ Thanks a lot .. it works... But I have small problem as you can see on the y axis , I get decimal point after the number and now after updating the code with your solution I get 10.^1 ,10.^2 in x axis also... Why is that decimal point after 10? $\endgroup$ – chetan kulkarni Feb 26 at 14:03
  • $\begingroup$ I propose that instead of Automatic you put there {{1*10^-10, Style["1\[Times]\!\(\*SuperscriptBox[\(10\), \(-10\)]\)", Blue, 12]}, {2*10^-10, Style["2\[Times]\!\(\*SuperscriptBox[\(10\), \(-10\)]\)", Blue, 12]},...} just written by hand. This should solve the problem. $\endgroup$ – Alexei Boulbitch Feb 26 at 16:15
  • $\begingroup$ Thanks for the reply... I have many graphs which are generated after evaluating some function and hence I will not be knowing the range of y axis. Is there any generic way of doing this without getting a decimal point or is there any settings in mathematica application that I have to change? $\endgroup$ – chetan kulkarni Feb 28 at 8:08
  • $\begingroup$ I also observed that normal function such as: a = 1;b = 2;c = a + b give 3. as the answer (decimal point after number). I think the problem is not from the Plot and its in complete code's number format. Please help me to solve this. $\endgroup$ – chetan kulkarni Feb 28 at 8:20
  • $\begingroup$ The decimal point is the attribute of a Real number. Generally, if you define a = 1;b = 2; then c = a + b will give the Integer 3 That is, without any decimal point. In your case, most probably you have previously assigned one of these variables to a real number during the actual session, and Mma remembered it. It will be forgotten after clearing: Clear[a,b,c]; or after restarting Mma. Decimal points in your plot most probably originate from the values of the function if those are real. I do not know, if it is the case, since you did not post it. Please look at the edit to my answer. $\endgroup$ – Alexei Boulbitch Feb 28 at 9:02

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.