Plotting Multiple 2D graphs in mathematica

In summary, to plot multiple 2D graphs in Mathematica, you can use the Plot function and specify multiple functions within a single Plot command. You can also customize the appearance of each graph and add labels and legends. It is also possible to plot multiple 2D graphs on separate axes and save them as an image or PDF file using the Export function.
  • #1
flemmyd
144
1

Homework Statement


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.


Homework Equations


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.


The Attempt at a Solution


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


Thank you for sharing your question and attempts at a solution. It seems like you are trying to plot multiple 1D data sets on a 3D plot to visualize their evolution. I have a few suggestions that may help you achieve this:

1. Instead of using ListPlot3D, you can try using ListPointPlot3D. This function allows you to specify the coordinates of the data points in a 3D space, which may be more useful for your purpose.

2. To plot each data set on a different plane, you can use the option PlotRange to specify the range of values for each axis. For example, if you want data1 to be plotted on the y=1 plane, you can set the PlotRange for the y-axis to {1,1}. Similarly, you can set the PlotRange for the x-axis and z-axis for each data set to achieve the desired result.

3. To connect the data points along the y-axis, you can use the option Joined -> True in ListPointPlot3D. This will create a line connecting the data points along the y-axis for each data set.

I hope these suggestions help you plot your data sets on a 3D graph. Good luck with your research!
 

Related to Plotting Multiple 2D graphs in mathematica

1. How do I plot multiple 2D graphs in mathematica?

To plot multiple 2D graphs in mathematica, you can use the Plot function and specify multiple functions within a single Plot command. For example, Plot[{f1[x], f2[x], f3[x]}, {x, xmin, xmax}] will plot the three functions f1, f2, and f3 on the same graph.

2. Can I customize the appearance of each graph when plotting multiple 2D graphs?

Yes, you can customize the appearance of each graph by using the PlotStyle option within the Plot command. For example, Plot[{f1[x], f2[x], f3[x]}, {x, xmin, xmax}, PlotStyle -> {Red, Blue, Green}] will plot the three functions with the specified colors.

3. How can I add labels and legends to my multiple 2D graphs in mathematica?

You can add labels and legends to your graphs by using the PlotLegends option within the Plot command. For example, Plot[{f1[x], f2[x], f3[x]}, {x, xmin, xmax}, PlotLegends -> {"Function 1", "Function 2", "Function 3"}] will add a legend with the specified names to your graph.

4. Is it possible to plot multiple 2D graphs on separate axes in mathematica?

Yes, you can plot multiple 2D graphs on separate axes by using the Plot function and specifying the Axes option. For example, Plot[{f1[x], f2[x], f3[x]}, {x, xmin, xmax}, Axes -> {True, False}] will plot f1 and f2 on one axis and f3 on a separate axis.

5. Can I save my multiple 2D graphs as an image or PDF file in mathematica?

Yes, you can save your graphs as an image or PDF file by using the Export function. For example, Export["mygraphs.pdf", Plot[{f1[x], f2[x], f3[x]}, {x, xmin, xmax}]] will save the graph as a PDF file named "mygraphs".

Similar threads

  • Introductory Physics Homework Help
Replies
14
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
4K
  • Introductory Physics Homework Help
Replies
10
Views
867
  • Introductory Physics Homework Help
Replies
13
Views
2K
  • Introductory Physics Homework Help
Replies
6
Views
987
  • Introductory Physics Homework Help
Replies
3
Views
1K
  • Introductory Physics Homework Help
Replies
3
Views
2K
  • Introductory Physics Homework Help
Replies
20
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
264
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
236
Back
Top