RE: How to transform x axis on ListPlot?
- To: mathgroup at smc.vnet.net
- Subject: [mg33165] RE: [mg33140] How to transform x axis on ListPlot?
- From: "David Park" <djmp at earthlink.net>
- Date: Wed, 6 Mar 2002 01:55:48 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
Rob, You didn't say how your got your original list. x = Table[Sin[z], {z, 0, 3.0, 0.01}]; (One of the problems with ListPlot using this kind of array is that the x-axis goes from 1 to the length of the list. You would probably prefer that it start at zero.) If you generated your list the following way, you would get the x-scale you desired. xx = Table[{z, Sin[z/200]}, {z, 0, 600.0, 2}]; ListPlot[xx]; You could create a similar list from the original list by x2 = Transpose[Join[{2Range[0, Length[x] - 1]}, {x}]]; ListPlot[x2]; Or you could generate your own tick labels this way. ListPlot[x, Ticks -> {Table[{i, 2(i - 1)}, {i, 1, 301, 50}], Automatic}]; But it is more work to get the minor, unlabeled, ticks. Or, if you have my DrawGraphics package from my web site, you can use CustomTicks to conveniently obtain any tick scale that you want. It would be done this way. Needs["DrawGraphics`DrawingMaster`"] Draw2D[ {ListDraw[x]}, Axes -> True, Ticks -> {CustomTicks[#/2 + 1 &, {0, 600, 100, 5}], Automatic}]; This says that we want ticks going from 0 to 600 in steps of 100 with 5 subdivisions. The pure function tells how to go from the labeled values to the actual plot coordinate (which went from 1 to 301). David Park djmp at earthlink.net http://home.earthlink.net/~djmp/ > From: 1.156 [mailto:rob at piovere.com] To: mathgroup at smc.vnet.net > > Greetings cypherists, I have another problem that I bring up only > after a long time of putting up with no solution. I have a list > which I plot but the integer x axis of the plot is not scaled to > suit me. Each position in the list results from some > increment of a variable which I'd like to represent on the graph. > About all I've been able to do so far is to rig up the list so > that each entry in the array/list being plotted represents some > integer multiple of the actual variable so things don't get > too confusing. For example: > > x=Table[Sin[z],{z, 3.0, 0.01}]; > ListPlot[x] > > The plot looks nice but the x axis goes from 0 to 300 and I'd > like it to go from say, 0 to 600 (MHz). Surely this is easily > done but I haven't found a single example of this in the books or > in reviewing the posts on this ng. > > Options[ListPlot] doesn't help me either. > > This is no problem when using Plot[] on a continuous variable. > > Help appreciated as usual. Thanks. > > Rob > >