MathGroup Archive 2005

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

Search the Archive

Re: How smooth graphs?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg61400] Re: [mg61385] How smooth graphs?
  • From: Jeff Bryant <jeffb at wolfram.com>
  • Date: Tue, 18 Oct 2005 02:44:43 -0400 (EDT)
  • References: <200510170629.CAA16338@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

   The effect you are seeing is aliasing.  This has nothing to do with 
the PlotPoints, it is is a rendering effect.  Basically, you need to 
apply a "smoothing filter" to the pixels, or anti-alias the graphic, so 
you don't get the stairstep effect.  Mathematica does not automatically 
antialias graphics, but you can write top level code to do it for you. 
You can see some example code here:

http://members.wri.com/jeffb/visualization/aa.shtml

If you decide to apply this technique, I strongly recommend that you 
drastically reduce the PlotPoints setting since I'm pretty sure they 
don't need to be very high.

Another option is to export each of the frames from Mathematica as they 
are created at about 4 times their desired final size.  Then, you can 
import the frames into an application such as Adobe Photoshop and resize 
them down to the size you want.  Photoshop, and perhaps some other 
applications, will automatically anti-alias raster graphics during this 
process.  Anti-aliasing vector graphics (such as those in Mathematica) 
is trickier than for raster images.  Photoshop only deals with raster 
images.

Of course this requires that you have such an application available to 
you.  If not, the code linked from the example above should work, but it 
will probably be slower.  The bigger the image the longer it will take, 
and both options require you to rasterize the graphic (e.g. save/store 
the graphics object as a bitmap image).  At 1024x768, this method will 
take a long time.  There's no way I know of to do this in real-time. 
You might be able to make the effect less noticeable by choosing 
different colors, but this just masks the effect, it doesn't get rid of it.

-Jeff

Murray Eisenberg wrote:
> A colleague, L.J. Moffitt, asked me how the graphs produced by the 
> following code might be smoothed so as to avoid the jaggedness, 
> especially the "staircasing".
> 
> (This is going to be projected, and at a typical projection resolution 
> of 1024 x 768, it looks even worse.)
> 
> I tried all sorts of ploys, like drastically increasing PlotPoints and 
> PlotDivision; lowering the Thickness in PlotStyle; and even breaking up 
> the domain into two subintervals, one where the graph is more level and 
> the other where the graph is rising rapidly.  Nothing seemed to help.
> 
>   p[x_, L_] := (50.*L)/((1000. - 1.*x)*(-9.025*^8 + L + 1000.*x^2))
> 
>   <<Graphics`Animation`
> 
>   Animate[
>     Plot[p[x,L],{x, 0, 950},
>        PlotStyle->{AbsoluteThickness[3]},
>        PlotRange->{.1,.7},
>        AxesLabel->{"Inspection Rate","Robustness"},
>        PlotPoints->10000, PlotDivision->50,
>        AxesStyle->{RGBColor[0,0,1],Thickness[0.02]},
>        ImageSize->600,
>        Background->RGBColor[.1,.2,.7]],
>    {L,1000000000., 1000000000.+700000000., 10000000}]
> 
> Any suggestions that I might pass along to him?
> 


  • Prev by Date: Re: formatting table with integers and floats in a column
  • Next by Date: Re: Stylesheets vs. DTDs or XML Schemas
  • Previous by thread: Re: Re: How smooth graphs?
  • Next by thread: Re: How smooth graphs?