0
$\begingroup$

This is a simple plot.

Plot[x^2 + 1, {x, -10, 0},
  PlotPoints -> 100,
  MaxRecursion -> 0, 
  Background -> White,
  AxesLabel -> {x, y},
  PlotRange -> {-10, 10}]

Is there a way to shift the x axis to right side?

If I want to plot $x^2+1$ on the y axis and $n*x/p$ on the x axis. What to do?

$$n=4$$ $$p=30$$

$\endgroup$
3
  • $\begingroup$ Can you clarify what you mean by "multiply the x axis with a factor of n=10"? If you just want your plot to show a larger range of x values, just increase the range of {x,-10,0} to be whatever you want it to be. You'll have to change/eliminate the PlotRange option also. $\endgroup$
    – lericr
    Mar 23, 2022 at 0:39
  • $\begingroup$ @lericr. Edited the question $\endgroup$
    – Jasmine
    Mar 24, 2022 at 22:25
  • $\begingroup$ Could you please draw using "Paint" or similar, what the plot would look like with the change you are suggesting? $\endgroup$
    – Syed
    Mar 25, 2022 at 18:24

3 Answers 3

2
$\begingroup$

Something like this?

Plot[x^2 + 1, {x, -10, 0},
 AxesLabel -> {x, y},
 PlotRange -> {-10, 10},
 AxesOrigin -> {-10, 0}]
$\endgroup$
2
$\begingroup$

This is too long for a comment. I still can't figure out what you mean by multiplying the x-axis by 10. You can explore ScalingFunctions. If x-axis becomes logarithmic, you won't be able to plot on -ve x-axis though as it is being done currently. Let me know through the comments, if this (partially) works.

f[x_] := x^2 + 1;
Manipulate[
 Plot[f[x + k]
  , {x, -10, xlimit}
  , PlotStyle -> {Thick, ColorData[97][1]}
  , PlotPoints -> 100
  , MaxRecursion -> 0
  , AxesOrigin -> {aorig, 0}
  , Background -> White
  , AxesLabel -> {x, y}
  , PlotRange -> {{-10, 10}, {-12, 12}}
  , Epilog -> {
    Red, Dashed
    , Line[{{xlimit, -12}, {xlimit, 12}}]
    }
  ]
 , {{k, 0, "k"}, -3, 3, Appearance -> "Labeled"}
 , {{aorig, 0, "Axis Origin"}, -5, 5, Appearance -> "Labeled"}
 , {{xlimit, -1, "x-limit"}, -6, 6, Appearance -> "Labeled"}
 ]
$\endgroup$
1
  • $\begingroup$ I have edited the question. Can you please have a look at that now. $\endgroup$
    – Jasmine
    Mar 24, 2022 at 22:26
2
$\begingroup$

The Plot you provided puts the axis on the right side (for me on my setup anyway). But the general answer is that you can control placement of the axes by setting the axes origin:

Plot[x^2 + 1, {x, -10, 10}, PlotPoints -> 100, MaxRecursion -> 0, 
  Background -> White, AxesLabel -> {x, y}, PlotRange -> {-10, 10}, 
  AxesOrigin -> {10, 0}]

I changed {x,-10,0} to {x,-10,10} so you could see a definite difference.

Update

Based on your comment, maybe this is what you want (or maybe the inverse of this):

With[
  {n = 4, p = 30},
  Plot[(n x/p)^2 + 1, {x, -10, 10}]]

Or maybe a parametric plot?

With[
  {n = 4, p = 30},
  ParametricPlot[{t p/n, 1 + t^2}, {t, -10, 10}]]

The With isn't necessary, I was just trying to clarify and explicitly use n and p from your update.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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