Re: combining two plots
- To: mathgroup at smc.vnet.net
- Subject: [mg16776] Re: combining two plots
- From: dreiss at !SPAMscientificarts.com (David Reiss)
- Date: Wed, 24 Mar 1999 02:24:12 -0500
- Organization: EarthLink Network, Inc.
- References: <7d71u2$71r@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
In article <7d71u2$71r at smc.vnet.net>, "Joaquim Leitao" <quim at ideiafix.fis.ua.pt> wrote: > Hello: > > I'd like to draw in the same plot a function and some discrete > points. How can I combine the ListPlot and Plot comands in the same > figure? > > Any help will be appreciated > Joaquim Pratas Leitao > Departamento de Fisica > Universidade de Aveiro > 3810 Aveiro, Portugal > tel: +351 34 370286 > e-mail: quim at fis.ua.pt Here are two (of perhaps many) ways to do this. The first way is to surpress the plot outputs from Plot and ListPlot and then to combine them with Show. First make some data: In[1]:= data=Table[{2 Pi i/10,Cos[2 Pi i/10]+Random[]},{i,1,20}]; Now create the plots and display them through Show: In[2]:= plot1= ListPlot[data, DisplayFunction->Identity]; plot2= Plot[Sin[x],{x,0,4Pi},DisplayFunction->Identity]; Show[plot1,plot2,DisplayFunction->$DisplayFunction] Out[2]= - Graphics - An alternative way is to use graphics primitives to add the points to the graph using the Epilog option to Plot as in: In[3]:= Plot[Sin[x],{x,0,4Pi}, Epilog->Point/@data,PlotRange->{All,{-2,2}}] Out[3]= - Graphics - However, not that here I had to set the PlotRange by hand so as to display all of the points on the graph (of course this could be automated...). Cheers, David -- ---------------------------------------- Scientific Arts: Creative Services and Consultation for the Applied and Pure Sciences http://www.scientificarts.com David Reiss Email: dreiss at !SPAMscientificarts.com ---------------------------------------- Remove the !SPAM to send email