MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Controlling the scale of x-axis in ListPlot

  • To: mathgroup at
  • Subject: [mg119388] Re: Controlling the scale of x-axis in ListPlot
  • From: Alexei Boulbitch <alexei.boulbitch at>
  • Date: Wed, 1 Jun 2011 06:54:06 -0400 (EDT)

Hi, Daniel,

Denote the vectors you want to plot: xVect and yVect. For example:

xVect = {1, 2, 10, 20};
yVect = Table[RandomInteger[{1, 5}], {Length[xVect]}]

{5, 1, 1, 2}

You did not write it explicitly, but I guess, that in your case xVect goes in the increasing order, e.g.
you cannot have something like {1,20,10,2}, can you? I assume, you cannot. Let us first
form a list (entitled lst) with points that are equidistant along Ox:

lst = Transpose[{Range[Length[yVect]], yVect}]

{{1, 5}, {2, 1}, {3, 1}, {4, 2}}

If you plot it, you will have the points with the abscisses 1,2,3 and 4.
Now it is only necessary to rename them. This may be done with the option Ticks
of the command ListPlot. Let us construct this option defining the x-projection:

xTicks = Table[{i, xVect[[i]]}, {i, 1, Length[xVect]}]

{{1, 1}, {2, 2}, {3, 10}, {4, 20}}

Now the final command takes the form:

ListPlot[lst, Ticks ->  {xTicks, Automatic}, AxesOrigin ->  {0, 0}]

Try it.

Have fun, Alexei


I need to plot two a vector {y_1,...,y_n} against a vector {x_1,...,x_n}
and I want to the latter to be distributed with equal distances between
the elements. Mathematica automatically scales the x-axis so that it is
linear with respect to the x-values, i.e. if x={1,2,10}, then the distance
between the second and third element will be eight times longer than the
distance between the second and first element. I would like the distances
to be of equal length.

Any ideas?


Alexei Boulbitch, Dr. habil.
Senior Scientist
Material Development

ZAE Weiergewan
11, rue Edmond Reuter

Tel: +352 2454 2566
Fax: +352 2454 3566
Mobile: +49 (0) 151 52 40 66 44

e-mail: alexei.boulbitch at


This e-mail may contain trade secrets or privileged, undisclosed or
otherwise confidential information. If you are not the intended
recipient and have received this e-mail in error, you are hereby
notified that any review, copying or distribution of it is strictly
prohibited. Please inform us immediately and destroy the original
transmittal from your system. Thank you for your co-operation.

  • Prev by Date: Re: Mapping to Create Nested Loops
  • Next by Date: Re: NDSolve issues with initial and boundary conditions (corrected characters)
  • Previous by thread: Re: Controlling the scale of x-axis in ListPlot
  • Next by thread: Re: Akima-Interpolation