[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Plotting and PSTricks
On Fri, 16 Jul 2004, Ryszard Tanas wrote:
> I have tested the new release of epix and I have found a strange behavior
> of use_pstricks();
> My functions are plotted incorectly when use_pstricks() is on. If I
> comment out it, the functions are OK but filling does not work.
>
Dear Ryszard,
As you've noticed, PSTricks fills even non-closed paths unless
"fillstyle=none". (Currently ePiX sets "fillstyle=solid" by default, to
facilitate color filling.) I neglected to mention in yesterday's email
that use_pstricks() accepts a boolean argument; doing
use_pstricks(false);
before plotting will prevent PostScript from trying to fill the graph; a
sample file is attached. (There's another approach, but turning pstricks
off seems better.) Since use_pstricks() only sets an internal variable
(that is, nothing is written to the output file), you can safely toggle as
many times as you like. :)
Also, a line got deleted from yesterday's email while I was composing;
it's only necessary to do *one* of
psset("fillcolor=<color>");
- or -
fill_color("<color>");
to set the fill color. Sorry for the confusion! There's not much harm in
doing both, but each command writes a line to the output file, and the
color stack isn't infinitely large.
--Andy
Andrew D. Hwang ahwang@mathcs.holycross.edu
Department of Math and CS http://math.holycross.edu/~ahwang
College of the Holy Cross (508) 793-2458 (Office: 320 Swords)
Worcester, MA, 01610-2395 (508) 793-3530 (fax)
/* -*-ePiX-*- */
#include "epix.h"
using namespace ePiX;
double pi = M_PI; // \pi/2 to 20 decimals
double MAX=2*M_PI;
double s=1.0;
double X(double t)
{
using ePiX::cos;
return 5*cos(t);
}
double Xp(double t)
{
return X(t)+1.0;
}
double Xm(double t)
{
return X(t)-1.0;
}
main()
{
unitlength("1pt");
picture(P(400, 400));
bounding_box(P(-8.0, -8.0), P(8.0,8.0));
use_pstricks();
begin();
psset("fillcolor=lightgray");
shadeplot(Xp,Xm,-MAX,MAX,100);
psset("fillcolor=red");
ellipse(P(0,0),P(exp(-s),0),P(0,exp(s)),0,2*pi);
use_pstricks(false);
red();
plot(X,-MAX,MAX,100);
end();
}