Sign up ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I am trying to create a plot using ListLinePlot in which the x-axis is represented in a logarithmic scale, and is reversed (so larger values are on the right side).

I have found that ScalingFunctions -> {"Reverse"} will reverse the axis and ScalingFunctions -> {"Log"} will scale the axis to a log scale, but the two commands will not work together.

Does anyone have any ideas?

share|improve this question
In Mathematica 8, ScalingFunctions is not an option for ListLinePlot. Are you using a different version of Mathematica? –  Carl Morris Sep 6 '12 at 4:13
@CarlMorris actually, they are not documented to do so, but they do (see also here). –  Verbeia Sep 6 '12 at 4:25
@Verbeia It seems "Reverse" does not work for ListLogLinearPlot –  belisarius is forth Sep 6 '12 at 4:53
@Verde I know, but I got tangled in my answer and hadn't posted it until now. –  Verbeia Sep 6 '12 at 5:19

3 Answers 3

If you want to stick with ScalingFunctions then you just have to use a pure function where you specify the transformation you would like to have. Simple example:

ListLinePlot[Table[{x, x^2 + 10}, {x, 0, 10, 1}],
 ScalingFunctions -> {None, {Sqrt[# - 10] &, #^2 + 10 &}}

So what you have to do is to supply a function for the x-axis which reverses and takes the log and you need to supply the inverse transformation for that.

share|improve this answer
Take a look at this : #[Table[{n, Sqrt[n]}, {n, 1000}], ScalingFunctions -> {{-Log@# &, E^-# &}, None}] & /@ {ListPlot, ListLinePlot} –  belisarius is forth Sep 6 '12 at 11:42
tick = AbsoluteOptions[ListLogLinearPlot[Table[{n, Sqrt[n]}, {n, 1000}]], Ticks][[1,2]];
t1 = {tick[[1]] /. {x_, y_, z_, w_} -> {-x, y, z, w}, tick[[2]]};
ListPlot[Table[{-Log@n, Sqrt[n]}, {n, 1000}], Ticks -> t1]

Mathematica graphics

(The usual credit to @Heike for her torn[] function)

share|improve this answer

There doesn't seem to be a way you can get both log and reversed x-axes out of the box.

Consider some data that might warrant such a presentation:

data = Sort@RandomVariate[LogNormalDistribution[0.2, 2.], {40, 2}];

ListLogLinearPlot gives a log x-axis and normal y-axis

ListLogLinearPlot[data, Joined -> True, PlotRange -> All]

enter image description here

The ScalingFunction option isn't meant to work for ListLinePlot, but it actually does.

ListLinePlot[data, Joined -> True, 
  ScalingFunctions -> {"Reverse", None}]    

enter image description here

However, it doesn't work for ListLogLinearPlot.

So, the answer is to manipulate data and ticks much in the same way as Verde's answer suggests.

You can write a custom tick function that takes the maximum and minimum data points and builds tick functions from that. I am not going to pretend this is quite the function you want (I got tangled and don't have time to fix it now), but you can see how to build a general tick function that doesn't require specific knowledge of the data upfront.

 loggedticks[min_, max_] :=
   Table[{i, ScientificForm[10^i]}, {i, Floor@Log[10, min],Ceiling@Log[10, max]}] 

ListLogLinearPlot[data, Joined -> True, 
  Ticks -> {loggedticks, Automatic}]
share|improve this answer
There is a way to get both things with ScalingFunctions. See halirutan's answer and my comment below. Really unexpected. –  belisarius is forth Sep 6 '12 at 11:46

Your Answer


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.