0

Say I have a function J(x,y)[x =(0,4), y= (0,20)] and I want to make a plot with different combinations of (x,y) on the same plot. Is there a way to incorporate a for-loop inside the plot() function instead of having to solve for J(x,y) before plotting? I'm thinking something like plot(for x in range(0,4)....).

Thank you!

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
BaaBaaGoof
  • 29
  • 5
  • You are trying to place list-comprehension inside the `plot()` function? Why? – OneCricketeer Apr 26 '16 at 21:26
  • What library are you using to do the plotting? That will determine whether what you want to do is possible. – kindall Apr 26 '16 at 21:27
  • Are you interested in real-time plotting / plot animation? If so, matplotlib has an animation API for that (http://matplotlib.org/api/animation_api.html). Other possible options for real-time plotting are provided in this older question: http://stackoverflow.com/questions/11874767/real-time-plotting-in-while-loop-with-matplotlib – Vladislav Martin Apr 26 '16 at 21:31
  • @cricket_007, Cause the function I want to solve takes the form of J_{x}(y) and I want to run x from 0 to 100.. Currently, the only way I know how to plot in python (using pylab) is to do it one by one plot(J_{0}(y), J_{1}(y),....), and do this for x= 100 would take a long time. Is there a better way to do this? – BaaBaaGoof Apr 26 '16 at 21:40
  • @kindall, I'm using pylab. Thanks! – BaaBaaGoof Apr 26 '16 at 21:41
  • Related? [Multiple plot on one figure](http://stackoverflow.com/questions/21254472/multiple-plot-in-one-figure-in-python/21254861) – OneCricketeer Apr 26 '16 at 21:48
  • `pylab.plot([int(i) for x in range(0,4)])` seems to work for this SO member: http://stackoverflow.com/questions/25273365/matplotlib-plot-multiple-individual-plots-in-a-loop ... is this along the lines of what you are looking to do? – Vladislav Martin Apr 26 '16 at 22:07

0 Answers0