Multiple 2D plots in Mathematica

In summary, the conversation discusses the use of 1D data sets and plotting them on a 3D graph to observe their evolution. The individual data sets have the same number of entries and are represented by rows or columns. The goal is to plot each data set on a different y-axis plane. The use of ListPlot3D is explored, as well as the potential use of the interpolation function. Concrete examples are requested for further assistance.
  • #1
flemmyd
144
1
I posted this first in the homework section, but no one answered it. I figured this might be a better section...


I have multiple 1D data sets, let's call them data1, data2, data3, etc. Each data set has the same number of entries. Each one is either a row or a column (I can just use Transpose[...], so same] and when I use the ListPlot[] function, I get a graph where the vertical axis is the value in the data set and the horizontal axis is the numerical position.

i.e. if data 1 = {5 26 17 9...}, the graph would have points at (1,5), (2,26), (3,17), ...

What I want to do is plot data1, data2, etc on a 3d plot to see how the data evolves. By introducing another horizontal axis, I could plot data 1 on the y=1 plane (with the x-axis being the order and the z axis being the intensity) and data2 on the y=2 plane, etc.

When I try ListPlot3D[{data1,data2,data3...}], I end up plotting all the data points on the same y axis. I want to data1 on the y=1 plane, data2 on the y=2 plane, etc.

I tried just rewriting the entire data set as such:
data1_3D= Table[{i,1,data1[]},{i,1,Length[data1]}] *I didn't actually put an underscore. just so you could see my numbering system here.
data2_3D= Table[{i,1,data2[]},{i,1,Length[data2]}]

and just plotting these, but this didnt work.

Additionally, I'd love to use the interpolation function to connect the dots along the y-axis and x axis. There is no ListLinePlot3D function that I know of. I think {Mesh -> All} might work, although I'm trying to get this data set plotted first.
 
Physics news on Phys.org
  • #2
ListPlot3D[{{1, 2, 3}, {2, 4, 5}, {2, 5, 7}}]
looks like it plots the three data sets 1,2,3 2,4,5 and 2,5,7
in exactly the way I think you are describing..

If ListPlot3D doesn't work for you then post a simple concrete example of the actual input you used and what was wrong with the result.

ListInterpolation looks like it should do the interpolation on your data, but without actual concrete examples of a reasonably simple example it is impossible to show you that this works.
 

FAQ: Multiple 2D plots in Mathematica

How can I plot multiple 2D plots in Mathematica?

To plot multiple 2D plots in Mathematica, you can use the Plot function and specify multiple functions or data sets within the same set of brackets. For example, Plot[{x^2, Sin[x]}, {x, 0, 10}] will plot both x^2 and Sin[x] on the same graph.

Can I customize the appearance of each plot in a multiple 2D plot?

Yes, you can customize the appearance of individual plots within a multiple 2D plot by using the PlotStyle option. For example, Plot[{x^2, Sin[x]}, {x, 0, 10}, PlotStyle -> {Red, Dashed}] will plot x^2 in red and Sin[x] with a dashed line.

How can I add a legend to a multiple 2D plot?

To add a legend to a multiple 2D plot in Mathematica, you can use the PlotLegends option. For example, Plot[{x^2, Sin[x]}, {x, 0, 10}, PlotLegends -> {"x^2", "Sin[x]"}] will add a legend to the plot with the corresponding function names.

Can I combine different types of plots in a multiple 2D plot?

Yes, you can combine different types of plots, such as lines, points, and bars, in a multiple 2D plot by using the Show function. For example, you can use Show[Plot[x^2, {x, 0, 10}], ListPlot[Table[{x, x^2}, {x, 0, 10}]] to plot a line and a list of points on the same graph.

Is it possible to save a multiple 2D plot as an image file?

Yes, you can save a multiple 2D plot as an image file by using the Export function. For example, Export["myplot.png", Plot[{x^2, Sin[x]}, {x, 0, 10}]] will save the plot as a PNG image file in your current directory.

Similar threads

Replies
1
Views
2K
Replies
9
Views
22K
Replies
2
Views
11K
Replies
1
Views
1K
Replies
18
Views
4K
Replies
1
Views
1K
Replies
2
Views
1K
Replies
12
Views
3K
Replies
3
Views
7K
Back
Top