[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to draw a grayshaded box



On Thu, 11 Nov 2004, Gunnar wrote:

> I'm strugling with epix version 0.8.* and I'm trying to illustrate
> limits by plotting a function and then showing that the function can be
> fitted into a small slice (rectangle), you know what I mean.
>
> What I need some help with is to make the rectangle shaded and have a
> coordinatesystem with unmarked axes, just ----> (arrows) at the ends,
> and some small marks at the points x_0 and A, A+e, A-e at the axes, but
> no other markings on the axes
>
Hi Gunnar,

Sorry if the documentation is unclear! :)

The attached file does what you want (I think) and compiles under version
0.8.10a. Please let me know if there are problems with it. The locations
of tick marks are gathered at the top of the file, so they can be easily
modified visually.

Best regards,

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;

// symbolic constants gathered for tweaking
double x_0=3.4, A=1.2, eps=0.8;
double axis_str=0.1; // stretch axis arrows by 10%

double f(double t)
{
  double x = -0.4+(1+t*t*t+7*t*t +10*t*(ePiX::cos(4*t) )) / (t*t*t+2*t*t+2);
  if (x<0.3)
    x=x+1;
  return x;
}

int main(){
  unitlength("1mm");
  bounding_box(P(-1.3,-0.5),P(8,4));
  picture(P(80,40));

  begin();

  // draw rectangle first -- PostScript layers output :)
  gray(0.3);
  draw_rect(P(3.4,0.4),P(8,2));

  arrow(P(x_min, 0), P(x_max+axis_str*x_size));
  arrow(P(0,y_min), P(0, y_max+axis_str*y_size));

  // use constants to place tick marks and labels
  v_axis_tick(P(0,A-eps));
  v_axis_tick(P(0,A));
  v_axis_tick(P(0,A+eps));
  h_axis_tick(P(x_0,0));

  // shift label down 4pt, align below location
  label(P(x_0, 0), P(0,-4), "$x_0$", b); 

  // shift labels left 4pt, align to left of location
  label(P(0,A),    P(-4,0), "$A$", l);
  label(P(0,A-eps),P(-4,0), "$A-\\varepsilon$", l);
  label(P(0,A+eps),P(-4,0), "$A+\\varepsilon$", l);

  cropplot(f, 0.4, x_max+1, 60);

  end();
}