Introducing new populations in mathematica graphs

In summary, the conversation discusses how to introduce different populations at different times on the same plot in Mathematica. One suggestion is to use the ListPlot function and specify both x and y coordinates in a list. Another suggestion is to use the truncate function with InterpolatingFunction objects from NDSolve to manipulate the data before plotting.
  • #1
pemb09
2
0
hi i was wondering if anyone knew how to introduce different populations at diffrent times on the same plot on mathematica?
Say i wanted population 1 have n = 10 at t=0, population 2 to have n=4 at t=0 and then introduce a new population at t=25 so that population 3 would have n= 0 initally but then n= 1 at t = 25.
Any ideas? the only way I've been gettting around it is to give population 3 really small values initially (e.g. 0.000000000001) but its not very precise.
 
Physics news on Phys.org
  • #2
What kind of plot are you using? If you are using list plot then you can specify both x and y coordinates in your list. e.g.

a = Transpose[{Range[10], 2 Range[10]}];
b = Table[{x, 13}, {x, 3, 10}];
ListPlot[{a, b}]
 
  • #3
I'm using Plot [ndsolve] of a set of differential equations. Listplot won't seem to make a list of solutions. I want one populations to have initial conditions of 0 but then at a further time stage to have a vlaue of 1 and see how that changes.
 
  • #4
If popa and popb are the InterpolatingFunction objects that return from NDSolve then you can do the following:


truncate[f_InterpolatingFunction, t_] := If[f[[1, 1, 1]] <= t <= f[[1, 1, 2]], f[t]];
Plot[{truncate[popa, t], truncate[popb, t]}, {t, -1, 6}]
 

1. How can I add a new population to a Mathematica graph?

To add a new population to a Mathematica graph, you can use the VertexAdd function. This function allows you to specify the new population as a vertex in the graph. You can also use the EdgeAdd function to add connections between the new population and existing populations in the graph.

2. Can I visualize the new population in the graph with different colors?

Yes, you can use the VertexStyle function to specify different colors for the new population in the graph. This function allows you to set the color, shape, and other visual properties of individual vertices in the graph.

3. Is it possible to add multiple new populations to a graph at once?

Yes, you can use the VertexAdd and EdgeAdd functions multiple times to add multiple new populations to the graph. Alternatively, you can use the Graph function to create a new graph with all the desired populations and connections.

4. Can I remove a population from the graph after adding it?

Yes, you can use the VertexDelete function to remove a population from the graph. This function allows you to specify the specific population you want to remove, and it will also remove any connections to that population.

5. How can I label the new population in the graph?

You can use the VertexLabels function to label the new population in the graph. This function allows you to specify the label for each vertex in the graph, including the new population. You can also use the VertexLabelStyle function to customize the appearance of the labels.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
12
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
10
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
Back
Top