RE: Some questions about plotting.
- To: mathgroup at smc.vnet.net
- Subject: [mg34164] RE: [mg34146] Some questions about plotting.
- From: "David Park" <djmp at earthlink.net>
- Date: Tue, 7 May 2002 03:54:03 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Steve, SurfaceGraphics and ListPlot3D plots are often confusing to the user because the array order is reversed from what you might think. Basically, the SurfaceGraphics array stacks rows of the matrix one on top of the other in what we think of as the y direction and spreads the column values horizontally. That is just the reverse of what is usually generated by a Table command. Here is a set of data generated by a table command. data = Table[Sin[x]*Cos[y], {x, 0., Pi/2, Pi/20}, {y, 0., Pi/2, Pi/20}] Increasing the row index corresponds to increasing x and increasing values of the function. Increasing the column index corresponds to increasing y and decreasing values of the function. Now, let's plot it using ListPlot3D. (We can set the text family and size using the TextStyle option.) ListPlot3D[data, Axes -> True, AxesLabel -> {x, y, z}, BoxRatios -> {1, 1, 1}, TextStyle -> {FontFamily -> "Helvetica", FontSize -> 12}, ImageSize -> 400]; We see that the x and y axes have been mixed up. The function is decreasing with x and increasing with y! The solution is to Transpose the data. I also changed the viewpoint here. ListPlot3D[Transpose[data], Axes -> True, AxesLabel -> {x, y, z}, BoxRatios -> {1, 1, 1}, TextStyle -> {FontFamily -> "Helvetica", FontSize -> 12}, ViewPoint -> {-2.971, -1.186, 1.104}, ImageSize -> 400]; Now the x and y axes are in the correct order. But the x and y axes are labeled by the array index numbers. We would like them to go from zero to Pi/2. That is accomplished by using the MeshRange option. I have also adjusted the edges that will be labeled with AxesEdge and put on Ticks in terms of Pi. ListPlot3D[Transpose[data], MeshRange -> {{0, Pi/2}, {0, Pi/2}}, Axes -> True, AxesLabel -> {x, y, z}, AxesEdge -> {{-1, -1}, {-1, -1}, {-1, 1}}, Ticks -> {{0, Pi/4, Pi/2}, {0, Pi/4, Pi/2}, Automatic}, BoxRatios -> {1, 1, 1}, TextStyle -> {FontFamily -> "Helvetica", FontSize -> 12}, ViewPoint -> {-2.971, -1.186, 1.104}, ImageSize -> 400]; Now consider a regular Plot3D of the same function. plot1 = Plot3D[Sin[x]Cos[y], {x, 0, Pi/2}, {y, 0, Pi/2}, PlotPoints -> 11]; The first part of plot1 is just the array that one could put into a ListPlot3D. Take a look at it. First[plot1] It is just the transpose of the data matrix we generated above using Table. To summarize: You may have to transpose the matrix, or reverse the order of the elements in the rows, or reverse the rows, or some combination of these things. You will almost always want to use MeshRange to obtain the real range of values on the axes. David Park djmp at earthlink.net http://home.earthlink.net/~djmp/ > From: Steve Gray [mailto:stevebg at adelphia.net] To: mathgroup at smc.vnet.net > > I have a modest-size matrix (up to about 31x31) whose > values I want to look at using ListPlot3D. Results are good > except for a few things: > 1. It's important to have matrix element 1,1 appear at > the upper left corner of the plot and the axes numbered > accordingly, but this is not what the plot gives by default. > I don't see a way to reverse the axis labeling. Is there one? > 2. I note that this option doesn't work for ListPlot3D: > FontFamily\[Rule]Helvetica,FontSize\[Rule]12 Is there > a way to make the axis labels bigger? When you enlarge > the plot by dragging the labels stay the same size. > 3. AxesLabel does not do anything useful, putting the > labels together but not on the two axes. Can I get > the axes labeled with for example "Row" and "Column"? > 4. Is there a way to get two ListPlot3D's side by side? > I want a stereo pair (same plot with different viewpoints). > > Thank you for any information. > > Steve Gray. > > >