ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* [NTG-context] The graph is not visible.
@ 2024-04-25 10:27 Fabrice Couvreur
  2024-04-25 11:31 ` [NTG-context] " Taco Hoekwater
  0 siblings, 1 reply; 10+ messages in thread
From: Fabrice Couvreur @ 2024-04-25 10:27 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 2071 bytes --]

Hi,
I don't know if I can explain the problem I'm having. I made a project with
14 chapters. In each of them, there are graphics embedding metapost code. I
proceed as follows : I compile each chapter alone with lmtx then I compile
the project containing the 14 chapters. I didn't encounter any problems
except with a graphic from the last chapter. It is indeed in chapter 14 but
not in the project ! I give the code for this graph.
Thanks.
Fabrice

\startMPcode

               interim linejoin := mitered;
               interim ahangle := 30;
               numeric u, pi;

               pi = 3.141592653589793;
               u = 1.5cm;

               vardef graph_of_function (suffix f) (expr xmin, xmax, xsep) =
                  for x = xmin step xsep until xmax: (x, f(x)) .. endfor
(xmax, f(xmax))
               enddef ;

               vardef vline (suffix f, g) (expr x) = (x, min(f(x), g(x)))
-- (x, max(f(x),g(x))) enddef;

               vardef area_between_functions (suffix f, g)(expr a, b, xsep)
=
                  buildcycle(graph_of_function(f, a, b, xsep), vline(f, g,
b),
                  reverse graph_of_function(g, a, b, xsep), reverse
vline(f, g, a))
               enddef;

               vardef xaxis (expr xmin, xmax) = (xmin, 0) -- (xmax, 0)
enddef ;
               vardef yaxis (expr ymin, ymax) = (0, ymin) -- (0, ymax)
enddef ;


               xmin:=-pi/2; xmax := 3*pi/2;
               ymin := -1.5; ymax := 5;


               vardef f(expr x)= exp(-x)*(-cos(x)+sin(x)+1) enddef;
               vardef g(expr x)=-exp(-x)*cos(x) enddef;
               path C_f, C_g;
               C_f = graph_of_function(f,xmin, xmax, .1);
               C_g = graph_of_function(g, xmin, xmax, .1);

               a := xpart(C_f intersectionpoint C_g);
               b := xpart(reverse C_f intersectionpoint reverse C_g);

               fill (area_between_functions(f, g, a, b, 0.1)) scaled u
withcolor 0.4[white, blue];
               draw C_f scaled u withcolor blue;
               draw C_g scaled u withcolor blue;


           \stopMPcode

[-- Attachment #1.2: Type: text/html, Size: 2843 bytes --]

[-- Attachment #2: Type: text/plain, Size: 511 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2024-04-26 10:24 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-25 10:27 [NTG-context] The graph is not visible Fabrice Couvreur
2024-04-25 11:31 ` [NTG-context] " Taco Hoekwater
2024-04-25 14:08   ` Fabrice Couvreur
2024-04-25 14:31     ` Hans Hagen
2024-04-25 14:32     ` Taco Hoekwater
2024-04-25 14:55       ` Fabrice Couvreur
2024-04-25 21:12         ` Fabrice Couvreur
2024-04-26  7:20           ` Taco Hoekwater
2024-04-26  8:32             ` Aditya Mahajan
2024-04-26 10:22               ` Fabrice Couvreur

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).