Re: listplot and plot of the same function display in different scale...
- To: mathgroup at smc.vnet.net
- Subject: [mg51658] Re: listplot and plot of the same function display in different scale...
- From: "Dr. Wolfgang Hintze" <weh at snafu.de>
- Date: Wed, 27 Oct 2004 23:44:01 -0400 (EDT)
- References: <clneqo$ocd$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Using objects of the form {x-coord, y-coord} in ListPlot solves your
problem.
In[1]:=
solution = NDSolve[{Derivative[1][y][t] == -y[t],
y[0] == 1}, {y}, {t, 0, 7}];
I added red color to the curve (but even then they can hardly be
distinguished)
In[15]:=
g0 = Plot[Evaluate[y[t] /. solution], {t, 0, 7},
PlotStyle -> RGBColor[1, 0, 0], DisplayFunction ->
Identity];
Notice that I have dropped Flatten and took [[1]] here:
In[8]:=
g1 = ListPlot[Table[{t, Evaluate[y[t] /. solution][[1]]},
{t, 0, 7, 0.05}], PlotStyle -> PointSize[0.01],
DisplayFunction -> Identity];
In[16]:=
Show[g0, g1, DisplayFunction -> $DisplayFunction];
Hope this helps.
Wolfgang
sean kim wrote:
> Hello group,
>
> let's say you want to take a few points from an
> interploating function and ListPlot it. and then show
> it together with the graph object from Plot.
>
> so...
>
> solution = NDSolve[{y'[t] == -y[t], y[0] == 1}, {y},
> {t, 0, 7}];
>
> g0 = Plot[Evaluate[y[t] /. solution], {t, 0, 7},
> DisplayFunction -> Identity];
> g1 = ListPlot[Flatten[Table[Evaluate[y[t]/.solution],
> {t, 0, 7, 0.05}]],PlotStyle -> PointSize[0.015],
> DisplayFunction -> Identity];
>
> Show[g0, g1, DisplayFunction -> $DisplayFunction]
>
> will show two plots in one graph, but plots have their
> own axis scale. the Plot[] object seems to be shrunk
> in scales due to ListPlot[] object having more points.
> (due to being tabled)
>
> How do i fix this so that both Plot have same axis
> scales? ( I want to show dots from ListPlot to overlay
> on top of Plot graph. )
>
> Thanks in advance for any insights.
>
>
> sean
>
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Mail Address AutoComplete - You start. We finish.
> http://promotions.yahoo.com/new_mail
>
>