Re: Overlaying List...Plots with other Plots?
- To: mathgroup at smc.vnet.net
- Subject: [mg103418] Re: [mg103406] Overlaying List...Plots with other Plots?
- From: Bayard Webb <bayard.webb at mac.com>
- Date: Mon, 21 Sep 2009 05:50:10 -0400 (EDT)
- References: <200909201023.GAA24315@smc.vnet.net>
One possible way is to create a single ListPlot with two data series:
the first your actual data, the second a Table generated by your
fitted function. (I created the data from the function for the
example, but you get the idea...)
f[x_] := 2 + 1/3 x;
data = Table[{x,
f[x] + InverseCDF[NormalDistribution[0, 1/3], RandomReal[]]}, {x,
0, 10, .5}];
ListPlot[{data, Table[{x, f[x]}, {x, 0, 10, .1}]},
Joined -> {False, True},
PlotRange -> Automatic,
Filling -> 1 -> {2}
]
Your data should be in {x,y} form in both tables so that you can use
lists of different lengths. The iterator for your fitted list needs to
create enough points to present a smooth curve. By doing this you can
also use the Filling option to draw stems from the points to the
fitted line. You can generalize this by setting the range of the
function iterator to be the min and max of the x values in your data,
and by specifying the step value to be (max-min)/k, where k is the
number of segments you want drawn.
Bayard
On Sep 20, 2009, at 3:23 AM, Erik Max Francis wrote:
What's the smoothest way to draw a ListPlot (or its friends,
ListLogPlot, ListLogLogPlot, etc.) with another plot of just a normal
function (which is actually a curve fit to the data) on top of the
ListPlot?
I know that I can just do two plots (which are just Graphics objects
anyway) and then show them simultaneously with show, but since it's a
ListPlot, but since I'm dealing with an arbitrary set of data I don't
know what the bounds of the plot will be, so I don't see how to easily
choose the proper limits for the second Plot to Show together.
I presume there must be a standard way of doing this since it's a pretty
common operation; what's the "proper" way to do it?
Thanks.
--
Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
San Jose, CA, USA && 37 18 N 121 57 W && AIM/Y!M/Skype erikmaxfrancis
I'll tell them that their daddy was / A good man
-- India Arie
- References:
- Overlaying List...Plots with other Plots?
- From: Erik Max Francis <max@alcyone.com>
- Overlaying List...Plots with other Plots?