# How to show decimal points on the axes frames in mathematica?

I have a set of data g1 and when plot using n1, i got the plot shown in figure below. I need to change the x-axis label from (1,2,3,4,5...) to (1.0,2.0,3.0,4.0,5.0) and y-axis label from (50000,100000,150000,200000..) to 5.0*10^4,1.0*10^5,1.5*10^5.....).

ClearAll[g1, n1]
g1 = {{0.82, 234946}, {0.98, 161961}, {1.54, 66395}, {1.64, 57980}, {1.76,
50441}, {1.95, 41107}, {2.06, 36881}, {2.24, 30890}, {2.47, 25453}, {2.74,
20549}, {3.09, 16209}, {4.59, 8286}, {4.94, 8049}, {5.26, 8651}, {5.62,
12012}, {5.83, 20244}, {5.97, 43136}, {6.03, 90541}, {6.18, -2.29*10^-11 -
124787*I}, {6.51, -8.099*10^-13 - 4408*I}, {6.87,-1.47*10^-13 - 803*I}};
n1 = ListLinePlot[g1, PlotStyle -> {Blue}, Axes -> True,FrameLabel ->
{{"kx",None}, {"Photon energy (eV)",None}}, PlotRange -> {{0, 7},
{-30000,250000}}, Frame -> True, LabelStyle -> {12, GrayLevel[0]}]


I tried to solve it based on the below code suggested by some friends here but still not able to get what i wants. The code i wrote are as below

ClearAll[g1, n1]
g1 = {{0.82, 234946}, {0.98, 161961}, {1.54, 66395}, {1.64, 57980}, {1.76,
50441}, {1.95, 41107}, {2.06, 36881}, {2.24, 30890}, {2.47, 25453}, {2.74,
20549}, {3.09, 16209}, {4.59, 8286}, {4.94, 8049}, {5.26, 8651}, {5.62,
12012}, {5.83, 20244}, {5.97, 43136}, {6.03, 90541}, {6.18, -2.29*10^-11 -
124787*I}, {6.51, -8.099*10^-13 - 4408*I}, {6.87,-1.47*10^-13 - 803*I}};
fm=FrameTicks/.AbsoluteOptions[n1,FrameTicks]
(fm[[2, #, 2]] = EngineeringForm[fm[[2, #, 2]]]) & /@ Range[6]

(fm[[1, #, 2]] = AccountingForm[fm[[1, #, 2]], {1, 0},
NumberPadding -> {"", "0"}]) & /@ Range[8]
ListLinePlot[g1,PlotStyle->{Blue},
FrameLabel->{{"kx",None},{"Photon energy (eV)",None}},
PlotRange->{{0,7},{-30000,250000}},Frame->True,
LabelStyle->{12,GrayLevel[0]},
FrameTicks->{{fm[[2]],Automatic},{fm[[1]],Automatic}}]


Please someone help me for this one.

• Please use the search function before making a new question - You should be able to answer all your questions by looking at other answers on this site. Also, only ask one question be post – Lukas Lang May 20 '18 at 15:51
• @Mathe172, I am sorry for multiple questions. Now i make it only one question. I searched about showing decimal points on the axes frame but doesn't show anything. – rabink May 20 '18 at 16:34
• How about this? That and the documentation of FrameTicks should get you started – Lukas Lang May 20 '18 at 16:38
• @Mathe172, I go through FrameTicks and tried many ways but couldn't get succeed. If you or anyone knows, please give me the idea. Thanks – rabink May 20 '18 at 17:55

I need to change the x-axis label from (1,2,3,4,5...) to (1.0,2.0,3.0,4.0,5.0) and y-axis label from (50000,100000,150000,200000..) to 5.0*10^4,1.0*10^5,1.5*10^5.....).

This is something to get you started. First obtain the FrameTicks used

n1=ListLinePlot[g1,PlotStyle->{Blue},
Axes->True,
FrameLabel->{{"kx",None},{"Photon energy (eV)",None}},
PlotRange->{{0,7},{-30000,250000}},
Frame->True,
LabelStyle->{12,GrayLevel[0]}
]
fm=FrameTicks/.AbsoluteOptions[n1,FrameTicks]


Now do

(*adjust major tick labels on the y axis. You might need to adjust this*)
(* more to get the exact engineering format you wanted *)
(fm[[2, #, 2]] = EngineeringForm[fm[[2, #, 2]]]) & /@ Range[6]

(fm[[1, #, 2]] = AccountingForm[fm[[1, #, 2]], {1, 0},
NumberPadding -> {"", "0"}]) & /@ Range[8]


And replot again

ListLinePlot[g1,PlotStyle->{Blue},
FrameLabel->{{"kx",None},{"Photon energy (eV)",None}},
PlotRange->{{0,7},{-30000,250000}},
Frame->True,
LabelStyle->{12,GrayLevel[0]},
FrameTicks->{{fm[[2]],Automatic},{fm[[1]],Automatic}}
]


To use the above, there is known bug in using AbsoluteOptions[..., FrameTicks] and that bug is still in 11.3 more-ticksticks-errors-in-absoluteoptions-in-v10 so I used Answer above by Carl Woll and loaded the code shown there to fix the bug, so that the above code will work. So you need to load the code in the above link first for this to work.

• Hi Naseer, I copy your code above but it gives different than yours fm = FrameTicks /. AbsoluteOptions[n1, FrameTicks]; (fm[[1, #, 2]] = AccountingForm[fm[[1, #, 2]], {1, 0}, NumberPadding -> {"", "0"}]) & /@ Range[8]; (fm[[2, #, 2]] = EngineeringForm[fm[[2, #, 2]]]) & /@ Range[6]; ListLinePlot[g1, PlotStyle -> {Blue}, FrameLabel -> {{"kx", None}, {"Photon energy (eV)", None}}, PlotRange -> {{0, 7}, {-30000, 250000}}, Frame -> True, LabelStyle -> {12, GrayLevel[0]}, FrameTicks -> {{fm[[2]], Automatic}, {Automatic, Automatic}}]. Where did i goes wrong – rabink May 21 '18 at 15:17

I now understand to get the decimal places along the axis. For that, it requires slight changes in the FrameTicks as shown below.

ListLinePlot[g1,PlotStyle->{Blue},FrameLabel->{{"kx",None},{"Photon energy
(eV)",None}},PlotRange->{{0,7},{-30000,250000}},Frame->True,LabelStyle->
{12,GrayLevel[0]},FrameTicks -> {{Automatic,Automatic}, {Transpose[{#,
Map[PaddedForm[#, {2, 1}] &, #]}] &[Range[0, 7, 1.0]], Automatic}}]


Still no idea about the y-axis labeling in scientific notations.

This is closest I can get.

    xTick = Transpose[{#, Map[PaddedForm[#, {2, 1}] &, #]}] &[
Range[0, 7, 1.0]];

yTick = {{0, PaddedForm[0., {2, 1}]}, {50 10^3,
PaddedForm[5., {2, 1}] Superscript[10, 4]}, {10 10^4,
PaddedForm[1., {2, 1}] Superscript[10, 5]}, {15 10^4,
PaddedForm[1.5, {2, 1}] Superscript[10, 5]}, {20 10^4,
PaddedForm[2., {2, 1}] Superscript[10, 5]}, {25 10^4,

ListLinePlot[g1, PlotStyle -> {Blue},
FrameLabel -> {{"kx", None}, {"Photon energy
(eV)", None}}, PlotRange -> {{0, 7}, {-30000, 250000}},
Frame -> True, LabelStyle -> {12, GrayLevel[0]},
FrameTicks -> {{yTick,
Automatic}, {Transpose[{#, Map[PaddedForm[#, {2, 1}] &, #]}] &[
Range[0, 7, 1.0]], Automatic}}]


Here is what you want

xTick = Transpose[{Range[0, 7], {Style["0.0"], Style["1.0"],
Style["2.0"], Style["3.0"], Style["4.0"], Style["5.0"],
Style["6.0"], Style["7.0"]}}];

yTick = {{0, Style["0.0"]}, {50 10^3,
Style["5.0\[Times]\!$$\*SuperscriptBox[\(10$$, $$4$$]\)"]}, {10 \
10^4, Style[
"1.0\[Times]\!$$\*SuperscriptBox[\(10$$, $$5$$]\)"]}, {15 10^4,
Style["1.5\[Times]\!$$\*SuperscriptBox[\(10$$, $$5$$]\)"]}, {20 \
10^4, Style[
"2.0\[Times]\!$$\*SuperscriptBox[\(10$$, $$5$$]\)"]}, {25 10^4,
Style["2.5\[Times]\!$$\*SuperscriptBox[\(10$$, $$5$$]\)"]}};

ListLinePlot[g1, PlotStyle -> {Blue},
FrameLabel -> {{"kx", None}, {"Photon energy
(eV)", None}}, PlotRange -> {{0, 7}, {-30000, 250000}},
Frame -> True, LabelStyle -> {12, GrayLevel[0]},
FrameTicks -> {{yTick,
Automatic}, {Transpose[{#, Map[PaddedForm[#, {2, 1}] &, #]}] &[
Range[0, 7, 1.0]], Automatic}}]