How Can I Generate and Plot Multiple Y Sets in Mathematica?

In summary, the conversation discusses the need to plot a set of Y points against a set of X points, and how to construct a list YX in a simple manner for this purpose. The question also explores the possibility of generating multiple sets of Y values and plotting them together while keeping the same X values. The solution in Mathematica involves using the Transpose function to create a list of paired values and using the HoldOn function to hold the plot and add new plots without clearing the previous ones.
  • #1
brydustin
205
0
Suppose that I had a set of Y points Y = {y1,y2,...yN} and I want to plot them again a set X = {1,2,3,...,N}

Naturally, I would like to do something like:
YX = { {y1, 1} , {y2,2} , ... , {yN,N} }
followed by
ListPlot[YX,PlotJoined->True]


My question is: How can I construct YX in a very simple manner?
 
Physics news on Phys.org
  • #2
In[1]:= Y={1,5,4}; XY=Transpose[{Y,Range[Length[Y]]}]

Out[2]= {{1,1},{5,2},{4,3}}
 
  • #3
Thanks...
But what if the set Y was generated in a loop by some arbitrary means, and I wanted to plot Y, and then trash its values, hold the plot, rerun the calculation generating a new Y, and then plot it along with the first Y, keeping the same domain (X).
I know in MATLAB we would use the HoldOn function, but is there something like this in mathematica?
 

Related to How Can I Generate and Plot Multiple Y Sets in Mathematica?

1. What is the purpose of the ListPlot function in Mathematica?

The ListPlot function in Mathematica is used to create a graphical representation of data points in a list. It is commonly used for visualizing data and identifying any patterns or trends within the data.

2. How do I plot multiple lists using the ListPlot function?

To plot multiple lists, simply include all the lists as arguments within the ListPlot function. For example, ListPlot[{list1, list2, list3}] will plot all three lists on the same graph.

3. Can I customize the appearance of the plot created by the ListPlot function?

Yes, the ListPlot function allows for customization of various plot elements such as colors, axes labels, and plot styles. This can be done by using the options available within the function or by using the PlotStyle option to specify a specific plot style for each list.

4. How can I add a legend to my ListPlot?

To add a legend to your ListPlot, you can use the PlotLegends option within the ListPlot function. This allows you to specify a label for each list and have them displayed in a legend box on the plot.

5. Can I export my ListPlot as an image or a file?

Yes, the ListPlot function allows for exporting the plot as an image or a file. This can be done by using the Export function and specifying the desired file format. The plot can also be copied and pasted into other programs such as Microsoft Word or PowerPoint for further use.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
815
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
994
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
7K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
6K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
1K
Back
Top