Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I am trying to plot a function with specific options for the appearance of the plot. I want the X axis to not show up, and the Y axis to be labeled normally (i.e. numbers outside the plot).. Yet, I don't get any numbers in the Y axis' ticks:

The code I am using is the following (the function to be plotted is different, but still returns this behavior):

Plot[5 t + 3, {t, 0, 10},
    PlotRange -> All,
    AxesOrigin -> {10, 0},     
    LabelStyle -> {FontFamily -> "Arial", Bold, 40},
    Axes -> {False, True},
    PlotStyle -> {{Thickness[0.007], Darker[Blue, 0.5]}},     
    AxesStyle -> AbsoluteThickness[3], ImageSize -> {640, 480}
]

Could you please help me get the ticks numbered automatically?

share|improve this question
    
That doesn't help me. Either I get blank space within the plot when I change AxesOrigin, and resizing does no change to the plot :S –  Sosi May 31 '12 at 14:23

2 Answers 2

up vote 8 down vote accepted

The problem with your plot is that you are using the y-axis on the left, but positioning it on the right by shifting the origin. However, its behaviour is still that of a left-axis (i.e., ticks are to the left of the line). What you need is a right-axis, where the ticks are to the right (with the origin remaining where it should be).

You can do this by using Frame and setting only the right frame to be visible. Note that all the Axes* options will now be named Frame*.

Plot[5 t + 3, {t, 0, 10}, 
    LabelStyle -> {FontFamily -> "Arial", Bold, 40}, 
    Frame -> {{False, True}, {False, False}}, 
    FrameTicks -> {{None, All}, {None, None}}, 
    PlotStyle -> {{Thickness[0.007], Darker[Blue, 0.5]}}, 
    FrameStyle -> AbsoluteThickness[3], ImageSize -> {640, 480}, 
    PlotRange -> All
]

enter image description here

share|improve this answer
    
Oh, I see!! Thanks, I will check it out now! Looks great! Edit:Indeed, it works great! Thanks again! –  Sosi May 31 '12 at 14:31
    
AxesOrigin is unnecessary. Only nitpicking because you beat me by 1 sec :) –  István Zachar May 31 '12 at 14:33

You don't need to switch from axes to frame. And you may not be able to use a frame if the axis happens to be inside the plot instead of at the border.

So the way to get what you want with the minimum changes to your original code is this:

Plot[5 t + 3, {t, 0, 10}, 
 PlotRange -> All, 
 AxesOrigin -> {10, 0}, 
 LabelStyle -> {FontFamily -> "Arial", Bold, 40}, 
 PlotStyle -> {{Thickness[0.007], Darker[Blue, 0.5]}}, 
 AxesStyle -> {Opacity[0], AbsoluteThickness[3]}, 
 ImageSize -> {640, 480}]

All I did is to remove Axes -> {False, True}, and then modified the AxesStyle to make the x axis invisible.

To see how this differs from the solution using Frame, I'll move the axis into the middle:

Plot[5 t + 3, {t, 0, 10}, 
 PlotRange -> All, 
 AxesOrigin -> {5, 0}, 
 LabelStyle -> {FontFamily -> "Arial", Bold, 40}, 
 PlotStyle -> {{Thickness[0.007], Darker[Blue, 0.5]}}, 
 AxesStyle -> {Opacity[0], AbsoluteThickness[3]}, 
 ImageSize -> {640, 480}]

One axis

share|improve this answer
    
"... Y axis to be labeled normally (i.e. numbers outside the plot)..." That's why I used a frame. Yours still puts the numbers inside the plot. Of course, you could possibly control it with a tick function, but then it isn't minimal anymore :) –  rm -rf May 31 '12 at 19:39
    
@R.M Well, if you're going to take things literally: I could just change mine to AxesOrigin -> {0, 0}... –  Jens May 31 '12 at 20:02
    
Nah, I interpreted their question as wanting to place the axis to the right, but since they didn't know how to, they simply moved it as far right as possible. I do agree that yours is useful, since you can't have frames in arbitrary positions –  rm -rf May 31 '12 at 20:18
    
Indeed I wanted to have the axis on the right-hand side. Yet, thanks for your help Jens, I learnt something now! :) –  Sosi Jun 1 '12 at 9:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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