summaryrefslogtreecommitdiff
path: root/graphics/epix/samples/cropplot.xp
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /graphics/epix/samples/cropplot.xp
Initial commit
Diffstat (limited to 'graphics/epix/samples/cropplot.xp')
-rw-r--r--graphics/epix/samples/cropplot.xp35
1 files changed, 35 insertions, 0 deletions
diff --git a/graphics/epix/samples/cropplot.xp b/graphics/epix/samples/cropplot.xp
new file mode 100644
index 0000000000..b470d90497
--- /dev/null
+++ b/graphics/epix/samples/cropplot.xp
@@ -0,0 +1,35 @@
+/* -*-ePiX-*- */
+#include "epix.h"
+using namespace ePiX;
+
+double f(double t) { return 2*t*(1-t)*(1-t); }
+double g(double t) { return 1/(1-t*t); }
+
+int main()
+{
+ picture(P(-2,-4), P(2,4), "200x200pt");
+
+ begin();
+
+ set_crop();
+ // Vertical asymptotes
+ dashed();
+ line(P(-1, ymin()), P(-1, ymax()));
+ line(P( 1, ymin()), P( 1, ymax()));
+ solid();
+
+ // Axes
+ h_axis(8);
+ v_axis(8);
+
+ h_axis_labels(4, P(-1, 2), tl); // align top-left
+ v_axis_labels(4, P(-1, 2), tl);
+
+ // Graphs
+ plot(f, xmin(), xmax(), 80);
+
+ bold();
+ plot(g, xmin(), xmax(), 80); // N.B. poles are sample points
+
+ end();
+}