1
$\begingroup$

I'd like to plot a certain function where only its qualitative progession shall be emphasized. Thus, using the Ticks->None option seems to be appropriate. However, I need to place a zero at the axes origin. My first choice was to put it in the epilog.
As a toy example, consider the code

Manipulate[
  Plot[(a + x)*Sin[a*x], {x, 0, 4*Pi}, Ticks -> None, 
         Epilog -> Text[0, {-.1, .5}]
  ],{a, 1, 5}
]

As you can see, the zero gets closer to the x-axis as a increases and in my real case, the zero is striked out by the x-axis for some parameter values.

How can I place a zero to indicate the axis origin, such that it is independent of the function drawn? Ideally, the x-axis is only drawn for non negative x and a zero would be placed right left to the point (0,0).

$\endgroup$
2
  • 1
    $\begingroup$ Do you need both axes? If you don't, you could use: Manipulate[ Plot[(a + x)*Sin[a*x], {x, 0, 4*Pi}, Ticks -> {{0}}, Axes -> {True, False},PlotRange -> {{0, Automatic}}], {a, 1, 5}]. The problem is "A tick label on the axes origin is not displayed" (alternatively, you could move the AxesOrigin) $\endgroup$ Jul 26, 2013 at 9:27
  • $\begingroup$ Pinguin Dirk, nice idea! That actually solves another issue I'm having. Thanks. $\endgroup$ Jul 26, 2013 at 10:17

3 Answers 3

3
$\begingroup$

I believe what you want can be had by using Offset coordinates:

enter image description here

Manipulate[
 Plot[(a + x)*Sin[a*x], {x, 0, 4*Pi},
  Ticks -> None, 
  Epilog -> Text[0, Offset[{-8, 8}, {0, 0}]],
  PlotRangePadding -> 1],
 {a, 1, 5}
]

enter image description here

$\endgroup$
2
$\begingroup$

A fast and dirty solution would be to freeze the Plotrange. For your example try: PlotRange -> {{-.5, 10}, {-15, 15}}.

$\endgroup$
2
$\begingroup$

You can avoid any manual placement of the zero by placing a single tick at the origin, similar to Pinguin Dirk's suggestion. For it to be displayed, you moreover need to make the plotrange start from zero in the x-direction:

Manipulate[
 Plot[(a + x)*Sin[a*x], {x, 0, 4*Pi}, Ticks -> {{}, {0}}, 
  PlotRange -> {{0, Automatic}, Automatic}], {a, 1, 5}]
$\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.