MathGroup Archive 1999

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

Search the Archive

Re: Draw straight line, but display zigzag line!

  • To: mathgroup at smc.vnet.net
  • Subject: [mg17718] Re: Draw straight line, but display zigzag line!
  • From: "Allan Hayes" <hay at haystack.demon.co.uk>
  • Date: Tue, 25 May 1999 02:15:08 -0400
  • References: <7hogpn$fue@smc.vnet.net> <7i33tn$bd7@smc.vnet.net> <7i7jje$e1b$2@dragonfly.wolfram.com>
  • Sender: owner-wri-mathgroup at wolfram.com

<adam.smith at hillsdale.edu> wrote in message
news:7i7jje$e1b$2 at dragonfly.wolfram.com...
> Allan,
>
> I think what he means by zig-zag, is that on the screen display with
> the default PlotPoints setting there is a slight "wavy-ness" to the
> plot.  As I pointed out in my post, it only seems to appear on the
> display.  Setting PlotPoints -> 2 (or a similar small number) seems to
> clear up the display.

Thanks Adam,
Yes, I guess that it is due to the 25  points plotted by Mathematica interfering
with the way the computer system tries to draw a straght line using discrete
pixels - the same thing woud presumably happen with a low definition
printer.

Some experiments:


ln1=Plot[2*x+1,{x,0,10}];

which uses

Cases[ln1,Line[pts_]:> Length[pts], Infinity][[1]]

    25

points

is, as you say, wavier than

ln2=Plot[2*x+1,{x,0,10}, PlotPoints->2];

But, interestingly,  we have

ln2[[1]]

     {{Line[{{0.00001,1.00002},{9.73608,20.4722},{9.99999,21.}}]}}

compared to the "ideal"

ln3 = Show[Graphics[Line[{{0,0},{10,21}}]]];

ln3[[1]]

    Line[{{0,0},{10,21}}]

Of course, with

sn=Plot[20Sin[x^2]+1,{x,0,10}];

we need to increase the points

sn2=Plot[20Sin[x^2]+1,{x,0,10},PlotPoints->30];

We can combine the two approaches

Plot[20Sin[x^2]+1,{x,0,10},PlotPoints->30,
 Epilog->Line[{{0,0},{10,21}}]
];

without needing to do something like

Show[sn2,ln3];

But the last way may be unavoidable in some cases

Allan
---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565



> Adam Smith
> In article <7i33tn$bd7 at smc.vnet.net>,
>   "Allan Hayes" <hay at haystack.demon.co.uk> wrote:
> >
> > bickel <bickel at ms17.hinet.net> wrote in message
> > news:7hogpn$fue at smc.vnet.net...
> > > I have a problem about drawing a straight.
> > >
> > > When I draw a straight ,ex: y=2x+1.
> > >
> > > I use Plot[2*x+1,{x,0,10}], it actually draw a line.
> > >
> > > But the line is like zigzag line.
> > >
> > > Can I do about this problem, setup some graphic option
> > >
> > > or ....?
> > >
> >
> > How jagged is it? There may be a more serious problem, but the line
> can only
> > be as smooth as the pixel size on your screen will allow.
> >
> > Allan
> > ---------------------
> > Allan Hayes
> > Mathematica Training and Consulting
> > Leicester UK
> > www.haystack.demon.co.uk
> > hay at haystack.demon.co.uk
> > Voice: +44 (0)116 271 4198
> > Fax: +44 (0)870 164 0565
> >
> >
>
>
> --== Sent via Deja.com http://www.deja.com/ ==--
> ---Share what you know. Learn what you don't.---
>
>
>



  • Prev by Date: Re: Two web-based university courses using Mathematica
  • Previous by thread: Re: Draw straight line, but display zigzag line!
  • Next by thread: Re: looking for implementation of hash function