# How can I move these numbers to the right side of the y axis?

How can I move these numbers to the right side of the y axis?
(preferably not using frame)

Plot[1 + x^2, {x, -5, 0}]


Here is my orginal problem. I tried my best to create a simple minimal working example for this.
It would be nice if there is a way to move the numbers with minimal changes as I did use a lot of style settings for axes and numbers.

polygon = {{0, 0}, {0, 1.5}, {-2, 1}, {-2, 0}, {0, 0}};
myfunc[myfunctions_, polygon_, {xmin_, xmax_, ymin_, ymax_}] :=
Module[{plot1, plot2, points},

plot1 =
ListLinePlot[polygon,
GridLines -> {Range[xmin, xmax, 1/2], Range[ymin, ymax, 1/2]},
PlotRange -> {{xmin, xmax}, {ymin, ymax}},
Filling -> {1 -> Axis},
FillingStyle -> Directive[Opacity[0.2], Pink],
AxesLabel -> {MaTeX["X", Magnification -> 3],
MaTeX["Y", Magnification -> 3]},
Ticks -> {({#1,
MaTeX[#1, "DisplayStyle" -> False,
Magnification -> 3]} &) /@
Range[xmin,
xmax], ({#1,
MaTeX[#1, "DisplayStyle" -> False,
Magnification -> 3]} &) /@ Range[ymin, ymax, 1]},
TicksStyle -> Directive[Black, Bold, 20],
GridLines -> {Range[xmin, xmax, 1], Range[xmin, xmax, 1]},
ImageSize -> 800] /. _Line -> Sequence[];
plot2 =
Plot[myfunctions, {x, xmin, xmax},
PlotRange -> {{xmin, xmax}, {ymin, ymax}},
PlotStyle -> Directive[Thickness[0.01], CapForm["Round"]],
AxesLabel -> {MaTeX["X", Magnification -> 2],
MaTeX["Y", Magnification -> 2]},
TicksStyle -> Directive[Black, Bold, 20], ImageSize -> 800];
Show[plot1, plot2, AspectRatio -> 1]
]


Now if you excute this:

myfunc[{-x, -((1 + x^2)/(x - 3)), 2 - x}, polygon, {-3, 0, 0, 5}]


• You need to use a frame rather than axes. This should be as simple as changing all axis references to "frame". For instance, FrameTicks instead of Ticks, FrameLabel instead of AxesLabel, etc. Commented Jun 23, 2022 at 17:17
• @MarcoB I just tried but the numbers are much smallers and look bad. I can increase the size manually but I don't know how to keep it exactly the same as before. I want to keep everything same, just moving the numbers to the right.
– hana
Commented Jun 23, 2022 at 17:21
• After all of this, I decided to export the image and numbers, titles and add it in visio which is much easier to do!
– hana
Commented Jun 24, 2022 at 6:42

Clear["Global*"]


Assuming that your objection to Frame is just to avoid frames to the left and above:

Plot[1 + x^2, {x, -5, 0},
Frame -> {{None, Automatic}, {Automatic, None}},
FrameTicks -> All]


EDIT: The optional argument type with any value other then "Axes" will switch to a Frame

Needs["MaTeX"];


EDIT 2: Placing labels on the axes instead of frames

myfunc[myfunctions_, polygon_, {xmin_, xmax_, ymin_, ymax_},
type_ : "Axes"] := Module[
{plot1, plot2, points, xticks, yticks},
{xticks, yticks} = {
({#1, MaTeX[#1, "DisplayStyle" -> False,
Magnification -> 3]} &) /@ Range[xmin, xmax],
({#1, MaTeX[#1, "DisplayStyle" -> False,
Magnification -> 3]} &) /@ Range[ymin, ymax]};
plot1 = ListLinePlot[polygon,
GridLines ->
{Range[xmin, xmax, 1/2], Range[ymin, ymax, 1/2]},
PlotRange -> {{xmin, xmax}, {ymin, ymax}},
Filling -> {1 -> Axis},
FillingStyle -> Directive[Opacity[0.2], Pink],
AxesLabel -> {
MaTeX["X", Magnification -> 3],
MaTeX["Y", Magnification -> 3]},
FrameLabel -> None,
Ticks -> {xticks, yticks},
FrameTicks -> {{None, yticks}, {xticks, None}},
TicksStyle -> Directive[Black, Bold, 20],
GridLines ->
{Range[xmin, xmax, 1], Range[ymin, ymax, 1]},
ImageSize -> 500,
If[type === "Axes",
{Axes -> True, Frame -> False},
{Axes -> False, Frame -> {{False, True}, {True, False}}}]] /.
_Line -> Sequence[];
plot2 =
Plot[myfunctions, {x, xmin, xmax},
PlotStyle -> Directive[Thickness[0.01], CapForm["Round"]]];
axesLabels = Graphics[{
Text[MaTeX["X", Magnification -> 3], Scaled[{1.1, 0}]],
Text[MaTeX["Y", Magnification -> 3], Scaled[{1, 1.07}]]}];
Show[plot1, plot2,
If[type === "Axes", {}, axesLabels], AspectRatio -> 1,
ImagePadding -> {{25, 70}, {50, 50}},
PlotRangeClipping -> False]]


Example,

myfunc[{-x, -((1 + x^2)/(x - 3)), 2 - x}, polygon,
{-3, 0, 0, 5}, "Frame"]


• I did set a lot of styles for axies and these numbers so I don't want to use frame so I'll have to do it again for frame.
– hana
Commented Jun 23, 2022 at 15:53
• Edit your question to reflect the actual problem you are trying to resolve. In is not clear why the solution involves more than additionally changing one word. Commented Jun 23, 2022 at 15:58
• I just updated it.
– hana
Commented Jun 23, 2022 at 16:22
• How can I keep "X" and "Y" on the corners as the orginal? This is very nice but I just want to keep it consistent with many images I did previously.
– hana
Commented Jun 24, 2022 at 5:35

Applying Mr.Wizard's method from here

p = Plot[1 + x^2, {x, -5, 0}];
ticks = Ticks /. AbsoluteOptions[p];
{yticks, labels} = Replace[ticks[[2]], {a_, b_, {c_, x_}} :>
{a, Sow@Text[b, {0.2, a}];, {-c, x}}, 1] // Reap;
Show[p, Graphics[labels /. "0" -> ""], Ticks -> {ticks[[1]], yticks},

• There are no brackets around {c_, x_} and {-c, x} in Mr.Wizard original code, so omitting them might get it working in 12. Commented Jun 24, 2022 at 7:03