# How to ask Mathematica to start $x$ axis from $1$, not $0$ in a plot with frame?

I use this code

data = Table[{x, 6/x (Csc[30 x])^2}, {x, 1, 6}];
ListLogPlot[data, Joined -> True, Mesh -> All, Frame -> True,
FrameLabel -> {"x", "f"}]


and the result is

How can I ask Mathematica to start the $$x$$ axis from $$1$$, not $$0$$?

• Add an option like PlotRange -> {{1, All}, Automatic}. And maybe PlotRangePadding -> {{Scaled[0.02], Scaled[0.02]}, {Scaled[0.02], Scaled[0.05]}} Dec 6, 2020 at 14:59
• data = Table[{x, 6/x (Csc[30 x])^2}, {x, 1, 6}]; ListLogPlot[data, Joined -> True, Mesh -> All, Frame -> True, FrameLabel -> {"x", "f"}, PlotRange -> All, PlotRangeClipping -> True, PlotRangePadding -> 0] Dec 6, 2020 at 14:59

Perhaps the easiest way (in the sense that ListLogPlot figures out the plot range automatically) is just PlotRange -> All:

ListLogPlot[data, Joined -> True, Mesh -> All, Frame -> True,
FrameLabel -> {"x", "f"}, PlotRange -> All]


Another use case (see updated question) requires overriding the default Ticks:

data = Table[{x, 6/x (Csc[30 x])^2}, {x, 1, 5999}];
ListLogPlot[data, Joined -> True, Mesh -> All, Frame -> True,
FrameLabel -> {"x", "f"},
FrameTicks -> {{Automatic,
Automatic}, {ChartingScaledTicks[{Identity,
Identity}][##] /. {0., _, s__} :> {1., 1, s} &,
ChartingScaledFrameTicks[{Identity, Identity}][##] /. {0., t_,
s__} :> {1., t, s} &}}, PlotRange -> All,
AxesOrigin -> {1, 0}]


This works with the first example, too.

• @charmin Example? Dec 6, 2020 at 23:53
• @charmin That's from the plot range padding. Do you really want the first point on the left to land on the frame? But not the last point on the right? Usually a little space around the plot is desirable. (Consider {x, 1, 5999} and looks at both ends: Do you not want to see the 6000 tick mark?) Dec 7, 2020 at 0:01
• @charmin Do you want the 6000 to show if the last data point is 5999? Dec 7, 2020 at 0:06
• @charmin See update. Dec 7, 2020 at 0:25
• @charmin They're blue in my version, too. Tricky little devils, changing version to version. They've been around for a while. Search the sight. See update. I think the new edit works in both 12.0, 12.1.1 Dec 7, 2020 at 0:58

Try PlotRange

ListLogPlot[data, Joined -> True, Mesh -> All, Frame -> True,FrameLabel -> {"x", "f"}, PlotRange -> {{1, Automatic}, Automatic}]


PlotRangePadding work.

data = Table[{x, 6/x (Csc[30 x])^2}, {x, 1, 6}]; ListLogPlot[data,
Joined -> True, Mesh -> All, Frame -> True, FrameLabel -> {"x", "f"},
PlotRange -> All, PlotRangeClipping -> True,