MathGroup Archive 2004

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: listplot and plot of the same function display in different scale...

  • To: mathgroup at smc.vnet.net
  • Subject: [mg51647] Re: listplot and plot of the same function display in different scale...
  • From: Bill Rowe <readnewsciv at earthlink.net>
  • Date: Wed, 27 Oct 2004 23:43:09 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

On 10/27/04 at 1:54 AM, sean_incali at yahoo.com (sean kim) wrote:

>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. )

A simple solution would be to retain the value of the independent variable for the ListPlot, i.e., redefine g1 as:

g1 = ListPlot[Flatten/@Table[{t,Evaluate[y[t]/.solution]}, ...

An alternative solution would be to replace ListPlot with the ScaledListPlot function in Graphics`Graphics`. Then g1 would become

g1 = ScaledListPlot[Flatten[Table[Evaluate[y[t]/.solution],
{t, 0, 7, 0.05}]],PlotStyle -> PointSize[0.015],
DisplayFunction -> Identity, ScaleFunction->{.05(#-1)&, #&}];
--
To reply via email subtract one hundred and four


  • Prev by Date: Re: Inverse of "PowerExpand"
  • Next by Date: Re: Applying StyleForm to String plus Table?
  • Previous by thread: Re: listplot and plot of the same function display in different scale...
  • Next by thread: Re: listplot and plot of the same function display in different scale...