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

  • Context: Mathematica 
  • Thread starter Thread starter brydustin
  • Start date Start date
  • Tags Tags
    Function Mathematica
Click For Summary
SUMMARY

The discussion focuses on generating and plotting multiple Y sets in Mathematica using the ListPlot function. The user constructs a set of points Y = {y1, y2, ..., yN} and pairs them with X = {1, 2, 3, ..., N} using the Transpose function. The user seeks a method to hold the plot while generating new Y values in a loop, similar to MATLAB's HoldOn function. The solution involves using the Show function in Mathematica to overlay multiple plots without losing previous data.

PREREQUISITES
  • Familiarity with Mathematica syntax and functions
  • Understanding of ListPlot for visualizing data
  • Knowledge of the Transpose function for data manipulation
  • Basic concepts of plotting multiple datasets in a single graph
NEXT STEPS
  • Explore the Show function in Mathematica for combining plots
  • Learn about dynamic plotting techniques in Mathematica
  • Investigate the use of Manipulate for interactive visualizations
  • Review advanced data structures in Mathematica for efficient data handling
USEFUL FOR

Mathematica users, data analysts, and researchers looking to visualize multiple datasets efficiently and effectively in their projects.

brydustin
Messages
201
Reaction score
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
In[1]:= Y={1,5,4}; XY=Transpose[{Y,Range[Length[Y]]}]

Out[2]= {{1,1},{5,2},{4,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?
 

Similar threads

  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 3 ·
Replies
3
Views
7K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 3 ·
Replies
3
Views
6K
  • · Replies 4 ·
Replies
4
Views
4K