/usr/share/doc/mathgl/mathgl_en/mathgl_en_14.html is in mathgl-doc-en 2.1.3.1-4ubuntu3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
<html>
<!-- This manual is for MathGL (version 2.1.2), a collection of classes and routines for scientific plotting. Please report any errors in this manual to mathgl.abalakin@gmail.org.
Copyright C 2008-2012 Alexey A. Balakin.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.2
or any later version published by the Free Software Foundation;
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
Texts. A copy of the license is included in the section entitled "GNU
Free Documentation License."
-->
<!-- Created on December 22, 2013 by texi2html 1.82
texi2html was written by:
Lionel Cons <Lionel.Cons@cern.ch> (original author)
Karl Berry <karl@freefriends.org>
Olaf Bachmann <obachman@mathematik.uni-kl.de>
and many others.
Maintained by: Many creative people.
Send bugs and suggestions to <texi2html-bug@nongnu.org>
-->
<head>
<title>MathGL 2.1.2: 2.5 1D samples</title>
<meta name="description" content="MathGL 2.1.2: 2.5 1D samples">
<meta name="keywords" content="MathGL 2.1.2: 2.5 1D samples">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="texi2html 1.82">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.smallquotation {font-size: smaller}
pre.display {font-family: serif}
pre.format {font-family: serif}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: serif; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: serif; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.roman {font-family:serif; font-weight:normal;}
span.sansserif {font-family:sans-serif; font-weight:normal;}
ul.toc {list-style: none}
-->
</style>
</head>
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="g_t1D-samples"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="mathgl_en_13.html#Data-plotting" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#Plot-sample" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="mathgl_en_9.html#Examples" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_9.html#Examples" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_20.html#General-concepts" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="mathgl_en.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_88.html#Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="g_t1D-samples-1"></a>
<h2 class="section">2.5 1D samples</h2>
<p>This section is devoted to visualization of 1D data arrays. 1D means the data which depend on single index (parameter) like curve in parametric form {x(i),y(i),z(i)}, i=1...n. Most of samples will use the same data for plotting. So, I put its initialization in separate function
</p><pre class="verbatim">void mgls_prepare1d(mglData *y, mglData *y1=0, mglData *y2=0, mglData *x1=0, mglData *x2=0)
{
register long i,n=50;
if(y) y->Create(n,3);
if(x1) x1->Create(n); if(x2) x2->Create(n);
if(y1) y1->Create(n); if(y2) y2->Create(n);
mreal xx;
for(i=0;i<n;i++)
{
xx = i/(n-1.);
if(y)
{
y->a[i] = 0.7*sin(2*M_PI*xx) + 0.5*cos(3*M_PI*xx) + 0.2*sin(M_PI*xx);
y->a[i+n] = sin(2*M_PI*xx);
y->a[i+2*n] = cos(2*M_PI*xx);
}
if(y1) y1->a[i] = 0.5+0.3*cos(2*M_PI*xx);
if(y2) y2->a[i] = 0.3*sin(2*M_PI*xx);
if(x1) x1->a[i] = xx*2-1;
if(x2) x2->a[i] = 0.05+0.03*cos(2*M_PI*xx);
}
}
</pre><p>or using C functions
</p><pre class="verbatim">void mgls_prepare1d(HMDT y, HMDT y1=0, HMDT y2=0, HMDT x1=0, HMDT x2=0)
{
register long i,n=50;
if(y) mgl_data_create(y,n,3,1);
if(x1) mgl_data_create(x1,n,1,1);
if(x2) mgl_data_create(x2,n,1,1);
if(y1) mgl_data_create(y1,n,1,1);
if(y2) mgl_data_create(y2,n,1,1);
mreal xx;
for(i=0;i<n;i++)
{
xx = i/(n-1.);
if(y)
{
mgl_data_set_value(y, 0.7*sin(2*M_PI*xx) + 0.5*cos(3*M_PI*xx) + 0.2*sin(M_PI*xx), i,0,0);
mgl_data_set_value(y, sin(2*M_PI*xx), i,1,0);
mgl_data_set_value(y, cos(2*M_PI*xx), i,2,0);
}
if(y1) mgl_data_set_value(y1, 0.5+0.3*cos(2*M_PI*xx), i,0,0);
if(y2) mgl_data_set_value(y2, 0.3*sin(2*M_PI*xx), i,0,0);
if(x1) mgl_data_set_value(x1, xx*2-1, i,0,0);
if(x2) mgl_data_set_value(x2, 0.05+0.03*cos(2*M_PI*xx), i,0,0);
}
}
</pre>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top"><a href="#Plot-sample">2.5.1 Plot sample</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#Radar-sample">2.5.2 Radar sample</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#Step-sample">2.5.3 Step sample</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#Tens-sample">2.5.4 Tens sample</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#Area-sample">2.5.5 Area sample</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#Region-sample">2.5.6 Region sample</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#Stem-sample">2.5.7 Stem sample</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#Bars-sample">2.5.8 Bars sample</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#Barh-sample">2.5.9 Barh sample</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#Cones-sample">2.5.10 Cones sample</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#Chart-sample">2.5.11 Chart sample</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#BoxPlot-sample">2.5.12 BoxPlot sample</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#Candle-sample">2.5.13 Candle sample</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#Error-sample">2.5.14 Error sample</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#Mark-sample">2.5.15 Mark sample</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#TextMark-sample">2.5.16 TextMark sample</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#Label-sample">2.5.17 Label sample</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#Table-sample">2.5.18 Table sample</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#Tube-sample">2.5.19 Tube sample</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#Tape-sample">2.5.20 Tape sample</a></td><td> </td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#Torus-sample">2.5.21 Torus sample</a></td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<hr size="6">
<a name="Plot-sample"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#g_t1D-samples" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#Radar-sample" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="mathgl_en_9.html#Examples" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#g_t1D-samples" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_20.html#General-concepts" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="mathgl_en.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_88.html#Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Plot-sample-1"></a>
<h3 class="subsection">2.5.1 Plot sample</h3>
<p>Function <a href="mathgl_en_39.html#plot">plot</a> is most standard way to visualize 1D data array. By default, <code>Plot</code> use colors from palette. However, you can specify manual color/palette, and even set to use new color for each points by using ‘<samp>!</samp>’ style. Another feature is ‘<samp> </samp>’ style which draw only markers without line between points. The sample code is:
</p><pre class="verbatim">int sample(mglGraph *gr)
{
mglData y; mgls_prepare1d(&y); gr->SetOrigin(0,0,0);
gr->SubPlot(2,2,0,""); gr->Title("Plot plot (default)");
gr->Box(); gr->Plot(y);
gr->SubPlot(2,2,2,""); gr->Title("'!' style; 'rgb' palette");
gr->Box(); gr->Plot(y,"o!rgb");
gr->SubPlot(2,2,3,""); gr->Title("just markers");
gr->Box(); gr->Plot(y," +");
gr->SubPlot(2,2,1); gr->Title("3d variant");
gr->Rotate(50,60); gr->Box();
mglData yc(30), xc(30), z(30); z.Modify("2*x-1");
yc.Modify("sin(pi*(2*x-1))"); xc.Modify("cos(pi*2*x-pi)");
gr->Plot(xc,yc,z,"rs");
return 0;
}
</pre>
<img src="../png/plot.png" alt="Example of Plot()">
<hr size="6">
<a name="Radar-sample"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Plot-sample" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#Step-sample" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="mathgl_en_9.html#Examples" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#g_t1D-samples" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_20.html#General-concepts" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="mathgl_en.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_88.html#Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Radar-sample-1"></a>
<h3 class="subsection">2.5.2 Radar sample</h3>
<p>Function <a href="mathgl_en_39.html#radar">radar</a> plot is variant of <code>Plot</code> one, which make plot in polar coordinates and draw radial rays in point directions. If you just need a plot in polar coordinates then I recommend to use <a href="mathgl_en_11.html#Curvilinear-coordinates">Curvilinear coordinates</a> or <code>Plot</code> in parabolic form with <code>x=r*cos(fi); y=r*sin(fi);</code>. The sample code is:
</p><pre class="verbatim">int sample(mglGraph *gr)
{
mglData yr(10,3); yr.Modify("0.4*sin(pi*(2*x+y))+0.1*rnd");
gr->SubPlot(1,1,0,""); gr->Title("Radar plot (with grid, '\\#')");
gr->Radar(yr,"#");
return 0;
}
</pre>
<img src="../png/radar.png" alt="Example of Radar()">
<hr size="6">
<a name="Step-sample"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Radar-sample" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#Tens-sample" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="mathgl_en_9.html#Examples" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#g_t1D-samples" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_20.html#General-concepts" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="mathgl_en.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_88.html#Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Step-sample-1"></a>
<h3 class="subsection">2.5.3 Step sample</h3>
<p>Function <a href="mathgl_en_39.html#step">step</a> plot data as stairs. It have the same options as <code>Plot</code>. The sample code is:
</p><pre class="verbatim">int sample(mglGraph *gr)
{
mglData y; mgls_prepare1d(&y); gr->SetOrigin(0,0,0);
mglData yc(30), xc(30), z(30); z.Modify("2*x-1");
yc.Modify("sin(pi*(2*x-1))"); xc.Modify("cos(pi*2*x-pi)");
gr->SubPlot(2,2,0,""); gr->Title("Step plot (default)");
gr->Box(); gr->Step(y);
gr->SubPlot(2,2,1); gr->Title("3d variant"); gr->Rotate(50,60);
gr->Box(); gr->Step(xc,yc,z,"r");
gr->SubPlot(2,2,2,""); gr->Title("'!' style");
gr->Box(); gr->Step(y,"s!rgb");
return 0;
}
</pre>
<img src="../png/step.png" alt="Example of Step()">
<hr size="6">
<a name="Tens-sample"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Step-sample" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#Area-sample" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="mathgl_en_9.html#Examples" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#g_t1D-samples" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_20.html#General-concepts" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="mathgl_en.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_88.html#Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Tens-sample-1"></a>
<h3 class="subsection">2.5.4 Tens sample</h3>
<p>Function <a href="mathgl_en_39.html#tens">tens</a> is variant of <a href="mathgl_en_39.html#plot">plot</a> with smooth coloring along the curves. At this, color is determined as for surfaces (see <a href="mathgl_en_24.html#Color-scheme">Color scheme</a>). The sample code is:
</p><pre class="verbatim">int sample(mglGraph *gr)
{
mglData y; mgls_prepare1d(&y); gr->SetOrigin(0,0,0);
gr->SubPlot(2,2,0,""); gr->Title("Tens plot (default)");
gr->Box(); gr->Tens(y.SubData(-1,0), y.SubData(-1,1));
gr->SubPlot(2,2,2,""); gr->Title("' ' style");
gr->Box(); gr->Tens(y.SubData(-1,0), y.SubData(-1,1),"o ");
gr->SubPlot(2,2,1); gr->Title("3d variant"); gr->Rotate(50,60); gr->Box();
mglData yc(30), xc(30), z(30); z.Modify("2*x-1");
yc.Modify("sin(pi*(2*x-1))"); xc.Modify("cos(pi*2*x-pi)");
gr->Tens(xc,yc,z,z,"s");
return 0;
}
</pre>
<img src="../png/tens.png" alt="Example of Tens()">
<hr size="6">
<a name="Area-sample"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Tens-sample" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#Region-sample" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="mathgl_en_9.html#Examples" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#g_t1D-samples" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_20.html#General-concepts" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="mathgl_en.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_88.html#Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Area-sample-1"></a>
<h3 class="subsection">2.5.5 Area sample</h3>
<p>Function <a href="mathgl_en_39.html#area">area</a> fill the area between curve and axis plane. It support gradient filling if 2 colors per curve is specified. The sample code is:
</p><pre class="verbatim">int sample(mglGraph *gr)
{
mglData y; mgls_prepare1d(&y); gr->SetOrigin(0,0,0);
gr->SubPlot(2,2,0,""); gr->Title("Area plot (default)");
gr->Box(); gr->Area(y);
gr->SubPlot(2,2,1,""); gr->Title("2 colors");
gr->Box(); gr->Area(y,"cbgGyr");
gr->SubPlot(2,2,2,""); gr->Title("'!' style");
gr->Box(); gr->Area(y,"!");
gr->SubPlot(2,2,3); gr->Title("3d variant");
gr->Rotate(50,60); gr->Box();
mglData yc(30), xc(30), z(30); z.Modify("2*x-1");
yc.Modify("sin(pi*(2*x-1))"); xc.Modify("cos(pi*2*x-pi)");
gr->Area(xc,yc,z,"r");
yc.Modify("-sin(pi*(2*x-1))"); gr->Area(xc,yc,z,"b#");
return 0;
}
</pre>
<img src="../png/area.png" alt="Example of Area()">
<hr size="6">
<a name="Region-sample"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Area-sample" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#Stem-sample" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="mathgl_en_9.html#Examples" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#g_t1D-samples" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_20.html#General-concepts" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="mathgl_en.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_88.html#Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Region-sample-1"></a>
<h3 class="subsection">2.5.6 Region sample</h3>
<p>Function <a href="mathgl_en_39.html#region">region</a> fill the area between 2 curves. It support gradient filling if 2 colors per curve is specified. Also it can fill only the region y1<y<y2 if style ‘<samp>i</samp>’ is used. The sample code is:
</p><pre class="verbatim">int sample(mglGraph *gr)
{
mglData y; mgls_prepare1d(&y);
mglData y1 = y.SubData(-1,1), y2 = y.SubData(-1,2); gr->SetOrigin(0,0,0);
gr->SubPlot(2,2,0,""); gr->Title("Region plot (default)");
gr->Box(); gr->Region(y1,y2); gr->Plot(y1,"k2"); gr->Plot(y2,"k2");
gr->SubPlot(2,2,1,""); gr->Title("2 colors");
gr->Box(); gr->Region(y1,y2,"yr"); gr->Plot(y1,"k2"); gr->Plot(y2,"k2");
gr->SubPlot(2,2,2,""); gr->Title("'!' style");
gr->Box(); gr->Region(y1,y2,"!"); gr->Plot(y1,"k2"); gr->Plot(y2,"k2");
gr->SubPlot(2,2,3,""); gr->Title("'i' style");
gr->Box(); gr->Region(y1,y2,"ir"); gr->Plot(y1,"k2"); gr->Plot(y2,"k2");
return 0;
}
</pre>
<img src="../png/region.png" alt="Example of Region()">
<hr size="6">
<a name="Stem-sample"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Region-sample" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#Bars-sample" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="mathgl_en_9.html#Examples" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#g_t1D-samples" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_20.html#General-concepts" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="mathgl_en.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_88.html#Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Stem-sample-1"></a>
<h3 class="subsection">2.5.7 Stem sample</h3>
<p>Function <a href="mathgl_en_39.html#stem">stem</a> draw vertical bars. It is most attractive if markers are drawn too. The sample code is:
</p><pre class="verbatim">int sample(mglGraph *gr)
{
mglData y; mgls_prepare1d(&y); gr->SetOrigin(0,0,0);
mglData yc(30), xc(30), z(30); z.Modify("2*x-1");
yc.Modify("sin(pi*(2*x-1))"); xc.Modify("cos(pi*2*x-pi)");
gr->SubPlot(2,2,0,""); gr->Title("Stem plot (default)");
gr->Box(); gr->Stem(y);
gr->SubPlot(2,2,1); gr->Title("3d variant"); gr->Rotate(50,60);
gr->Box(); gr->Stem(xc,yc,z,"rx");
gr->SubPlot(2,2,2,""); gr->Title("'!' style");
gr->Box(); gr->Stem(y,"o!rgb");
return 0;
}
</pre>
<img src="../png/stem.png" alt="Example of Stem()">
<hr size="6">
<a name="Bars-sample"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Stem-sample" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#Barh-sample" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="mathgl_en_9.html#Examples" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#g_t1D-samples" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_20.html#General-concepts" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="mathgl_en.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_88.html#Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Bars-sample-1"></a>
<h3 class="subsection">2.5.8 Bars sample</h3>
<p>Function <a href="mathgl_en_39.html#bars">bars</a> draw vertical bars. It have a lot of options: bar-above-bar (‘<samp>a</samp>’ style), fall like (‘<samp>f</samp>’ style), 2 colors for positive and negative values, wired bars (‘<samp>#</samp>’ style), 3D variant. The sample code is:
</p><pre class="verbatim">int sample(mglGraph *gr)
{
mglData ys(10,3); ys.Modify("0.8*sin(pi*(2*x+y/2))+0.2*rnd");
gr->SetOrigin(0,0,0);
gr->SubPlot(3,2,0,""); gr->Title("Bars plot (default)");
gr->Box(); gr->Bars(ys);
gr->SubPlot(3,2,1,""); gr->Title("2 colors");
gr->Box(); gr->Bars(ys,"cbgGyr");
gr->SubPlot(3,2,4,""); gr->Title("'\\#' style");
gr->Box(); gr->Bars(ys,"#");
gr->SubPlot(3,2,5); gr->Title("3d variant");
gr->Rotate(50,60); gr->Box();
mglData yc(30), xc(30), z(30); z.Modify("2*x-1");
yc.Modify("sin(pi*(2*x-1))"); xc.Modify("cos(pi*2*x-pi)");
gr->Bars(xc,yc,z,"r");
gr->SetRanges(-1,1,-3,3);
gr->SubPlot(3,2,2,""); gr->Title("'a' style");
gr->Box(); gr->Bars(ys,"a");
gr->SubPlot(3,2,3,""); gr->Title("'f' style");
gr->Box(); gr->Bars(ys,"f");
return 0;
}
</pre>
<img src="../png/bars.png" alt="Example of Bars()">
<hr size="6">
<a name="Barh-sample"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Bars-sample" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#Cones-sample" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="mathgl_en_9.html#Examples" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#g_t1D-samples" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_20.html#General-concepts" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="mathgl_en.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_88.html#Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Barh-sample-1"></a>
<h3 class="subsection">2.5.9 Barh sample</h3>
<p>Function <a href="mathgl_en_39.html#barh">barh</a> is the similar to <code>Bars</code> but draw horizontal bars. The sample code is:
</p><pre class="verbatim">int sample(mglGraph *gr)
{
mglData ys(10,3); ys.Modify("0.8*sin(pi*(2*x+y/2))+0.2*rnd");
gr->SetOrigin(0,0,0);
gr->SubPlot(2,2,0,""); gr->Title("Barh plot (default)");
gr->Box(); gr->Barh(ys);
gr->SubPlot(2,2,1,""); gr->Title("2 colors");
gr->Box(); gr->Barh(ys,"cbgGyr");
gr->SetRanges(-3,3,-1,1);
gr->SubPlot(2,2,2,""); gr->Title("'a' style");
gr->Box(); gr->Barh(ys,"a");
gr->SubPlot(2,2,3,""); gr->Title("'f' style");
gr->Box(); gr->Barh(ys,"f");
return 0;
}
</pre>
<img src="../png/barh.png" alt="Example of Barh()">
<hr size="6">
<a name="Cones-sample"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Barh-sample" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#Chart-sample" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="mathgl_en_9.html#Examples" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#g_t1D-samples" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_20.html#General-concepts" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="mathgl_en.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_88.html#Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Cones-sample-1"></a>
<h3 class="subsection">2.5.10 Cones sample</h3>
<p>Function <a href="mathgl_en_39.html#cones">cones</a> is similar to <code>Bars</code> but draw cones. The sample code is:
</p><pre class="verbatim">int sample(mglGraph *gr)
{
mglData ys(10,3); ys.Modify("0.8*sin(pi*(2*x+y/2))+0.2*rnd");
gr->Light(true); gr->SetOrigin(0,0,0);
gr->SubPlot(2,2,0); gr->Title("Cones plot");
gr->Rotate(50,60); gr->Box(); gr->Cones(ys);
gr->SubPlot(2,2,1); gr->Title("2 colors");
gr->Rotate(50,60); gr->Box(); gr->Cones(ys,"cbgGyr");
gr->SubPlot(2,2,2); gr->Title("'#' style");
gr->Rotate(50,60); gr->Box(); gr->Cones(ys,"#");
gr->SubPlot(2,2,3); gr->Title("'a' style");
gr->SetRange('z',-2,2); // increase range since summation can exceed [-1,1]
gr->Rotate(50,60); gr->Box(); gr->Cones(ys,"a");
return 0;
}
</pre>
<img src="../png/cones.png" alt="Example of Cones()">
<hr size="6">
<a name="Chart-sample"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Cones-sample" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#BoxPlot-sample" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="mathgl_en_9.html#Examples" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#g_t1D-samples" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_20.html#General-concepts" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="mathgl_en.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_88.html#Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Chart-sample-1"></a>
<h3 class="subsection">2.5.11 Chart sample</h3>
<p>Function <a href="mathgl_en_39.html#chart">chart</a> draw colored boxes with width proportional to data values. Use ‘<samp> </samp>’ for empty box. Plot looks most attractive in polar coordinates – well known pie chart. The sample code is:
</p><pre class="verbatim">int sample(mglGraph *gr)
{
mglData ch(7,2); for(int i=0;i<7*2;i++) ch.a[i]=mgl_rnd()+0.1;
gr->SubPlot(2,2,0); gr->Title("Chart plot (default)");
gr->Light(true); gr->Rotate(50,60); gr->Box(); gr->Chart(ch);
gr->SubPlot(2,2,1); gr->Title("'\\#' style");
gr->Rotate(50,60); gr->Box(); gr->Chart(ch,"#");
gr->SubPlot(2,2,2); gr->Title("Pie chart; ' ' color");
gr->SetFunc("(y+1)/2*cos(pi*x)","(y+1)/2*sin(pi*x)","");
gr->Rotate(50,60); gr->Box(); gr->Chart(ch,"bgr cmy#");
gr->SubPlot(2,2,3); gr->Title("Ring chart; ' ' color");
gr->SetFunc("(y+2)/3*cos(pi*x)","(y+2)/3*sin(pi*x)","");
gr->Rotate(50,60); gr->Box(); gr->Chart(ch,"bgr cmy#");
return 0;
}
</pre>
<img src="../png/chart.png" alt="Example of Chart()">
<hr size="6">
<a name="BoxPlot-sample"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Chart-sample" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#Candle-sample" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="mathgl_en_9.html#Examples" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#g_t1D-samples" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_20.html#General-concepts" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="mathgl_en.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_88.html#Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="BoxPlot-sample-1"></a>
<h3 class="subsection">2.5.12 BoxPlot sample</h3>
<p>Function <a href="mathgl_en_39.html#boxplot">boxplot</a> draw box-and-whisker diagram. The sample code is:
</p><pre class="verbatim">int sample(mglGraph *gr)
{
mglData a(10,7); a.Modify("(2*rnd-1)^3/2");
gr->SubPlot(1,1,0,""); gr->Title("Boxplot plot");
gr->Box(); gr->BoxPlot(a);
return 0;
}
</pre>
<img src="../png/boxplot.png" alt="Example of BoxPlot()">
<hr size="6">
<a name="Candle-sample"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#BoxPlot-sample" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#Error-sample" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="mathgl_en_9.html#Examples" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#g_t1D-samples" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_20.html#General-concepts" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="mathgl_en.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_88.html#Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Candle-sample-1"></a>
<h3 class="subsection">2.5.13 Candle sample</h3>
<p>Function <a href="mathgl_en_39.html#candle">candle</a> draw candlestick chart. This is a combination of a line-chart and a bar-chart, in that each bar represents the range of price movement over a given time interval. The sample code is:
</p><pre class="verbatim">int sample(mglGraph *gr)
{
mglData y(30); gr->Fill(y,"sin(pi*x/2)^2");
mglData y1(30); gr->Fill(y1,"v/2",y);
mglData y2(30); gr->Fill(y2,"(1+v)/2",y);
gr->SubPlot(1,1,0,""); gr->Title("Candle plot (default)");
gr->SetRange('y',0,1); gr->Box(); gr->Candle(y,y1,y2);
return 0;
}
</pre>
<img src="../png/candle.png" alt="Example of Candle()">
<hr size="6">
<a name="Error-sample"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Candle-sample" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#Mark-sample" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="mathgl_en_9.html#Examples" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#g_t1D-samples" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_20.html#General-concepts" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="mathgl_en.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_88.html#Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Error-sample-1"></a>
<h3 class="subsection">2.5.14 Error sample</h3>
<p>Function <a href="mathgl_en_39.html#error">error</a> draw error boxes around the points. You can draw default boxes or semi-transparent symbol (like marker, see <a href="mathgl_en_23.html#Line-styles">Line styles</a>). Also you can set individual color for each box. The sample code is:
</p><pre class="verbatim">int sample(mglGraph *gr)
{
mglData y; mgls_prepare1d(&y);
mglData x0(10), y0(10), ex0(10), ey0(10);
mreal x;
for(int i=0;i<10;i++)
{
x = i/9.;
x0.a[i] = 2*x-1 + 0.1*mgl_rnd()-0.05;
y0.a[i] = 0.7*sin(2*M_PI*x)+0.5*cos(3*M_PI*x)+0.2*sin(M_PI*x)+0.2*mgl_rnd()-0.1;
ey0.a[i]=0.2; ex0.a[i]=0.1;
}
gr->SubPlot(2,2,0,""); gr->Title("Error plot (default)");
gr->Box(); gr->Plot(y.SubData(-1,0)); gr->Error(x0,y0,ex0,ey0,"ko");
gr->SubPlot(2,2,1,""); gr->Title("'!' style; no e_x");
gr->Box(); gr->Plot(y.SubData(-1,0)); gr->Error(x0,y0,ey0,"o!rgb");
gr->SubPlot(2,2,2,""); gr->Title("'\\@' style");
gr->Box(); gr->Plot(y.SubData(-1,0)); gr->Error(x0,y0,ex0,ey0,"@","alpha 0.5");
gr->SubPlot(2,2,3); gr->Title("3d variant"); gr->Rotate(50,60);
for(int i=0;i<10;i++)
gr->Error(mglPoint(2*mgl_rnd()-1,2*mgl_rnd()-1,2*mgl_rnd()-1),
mglPoint(0.2,0.2,0.2),"bo");
gr->Axis();
return 0;
}
</pre>
<img src="../png/error.png" alt="Example of Error()">
<hr size="6">
<a name="Mark-sample"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Error-sample" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#TextMark-sample" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="mathgl_en_9.html#Examples" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#g_t1D-samples" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_20.html#General-concepts" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="mathgl_en.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_88.html#Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Mark-sample-1"></a>
<h3 class="subsection">2.5.15 Mark sample</h3>
<p>Function <a href="mathgl_en_39.html#mark">mark</a> draw markers at points. It is mostly the same as <code>Plot</code> but marker size can be variable. The sample code is:
</p><pre class="verbatim">int sample(mglGraph *gr)
{
mglData y,y1; mgls_prepare1d(&y,&y1);
gr->SubPlot(1,1,0,""); gr->Title("Mark plot (default)");
gr->Box(); gr->Mark(y,y1,"s");
return 0;
}
</pre>
<img src="../png/mark.png" alt="Example of Mark()">
<hr size="6">
<a name="TextMark-sample"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Mark-sample" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#Label-sample" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="mathgl_en_9.html#Examples" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#g_t1D-samples" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_20.html#General-concepts" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="mathgl_en.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_88.html#Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="TextMark-sample-1"></a>
<h3 class="subsection">2.5.16 TextMark sample</h3>
<p>Function <a href="mathgl_en_39.html#textmark">textmark</a> like <code>Mark</code> but draw text instead of markers. The sample code is:
</p><pre class="verbatim">int sample(mglGraph *gr)
{
mglData y,y1; mgls_prepare1d(&y,&y1);
gr->SubPlot(1,1,0,""); gr->Title("TextMark plot (default)");
gr->Box(); gr->TextMark(y,y1,"\\gamma","r");
return 0;
}
</pre>
<img src="../png/textmark.png" alt="Example of TextMark()">
<hr size="6">
<a name="Label-sample"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#TextMark-sample" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#Table-sample" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="mathgl_en_9.html#Examples" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#g_t1D-samples" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_20.html#General-concepts" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="mathgl_en.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_88.html#Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Label-sample-1"></a>
<h3 class="subsection">2.5.17 Label sample</h3>
<p>Function <a href="mathgl_en_39.html#label">label</a> print text at data points. The string may contain ‘<samp>%x</samp>’, ‘<samp>%y</samp>’, ‘<samp>%z</samp>’ for x-, y-, z-coordinates of points, ‘<samp>%n</samp>’ for point index. The sample code is:
</p><pre class="verbatim">int sample(mglGraph *gr)
{
mglData ys(10); ys.Modify("0.8*sin(pi*2*x)+0.2*rnd");
gr->SubPlot(1,1,0,""); gr->Title("Label plot");
gr->Box(); gr->Plot(ys," *"); gr->Label(ys,"y=%y");
return 0;
}
</pre>
<img src="../png/label.png" alt="Example of Label()">
<hr size="6">
<a name="Table-sample"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Label-sample" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#Tube-sample" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="mathgl_en_9.html#Examples" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#g_t1D-samples" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_20.html#General-concepts" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="mathgl_en.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_88.html#Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Table-sample-1"></a>
<h3 class="subsection">2.5.18 Table sample</h3>
<p>Function <a href="mathgl_en_39.html#table">table</a> draw table with data values. The sample code is:
</p><pre class="verbatim">int sample(mglGraph *gr)
{
mglData ys(10,3); ys.Modify("0.8*sin(pi*(2*x+y/2))+0.2*rnd");
gr->SubPlot(2,2,0); gr->Title("Table plot");
gr->Table(ys,"y_1\ny_2\ny_3"); gr->Box();
gr->SubPlot(2,2,1); gr->Title("no borders, colored");
gr->Table(ys,"y_1\ny_2\ny_3","r|");
gr->SubPlot(2,2,2); gr->Title("no font decrease");
gr->Table(ys,"y_1\ny_2\ny_3","#");
gr->SubPlot(2,2,3); gr->Title("manual width, position");
gr->Table(0.5, 0.95, ys,"y_1\ny_2\ny_3","#", "value 0.7"); gr->Box();
return 0;
}
</pre>
<img src="../png/table.png" alt="Example of Table()">
<hr size="6">
<a name="Tube-sample"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Table-sample" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#Tape-sample" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="mathgl_en_9.html#Examples" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#g_t1D-samples" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_20.html#General-concepts" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="mathgl_en.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_88.html#Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Tube-sample-1"></a>
<h3 class="subsection">2.5.19 Tube sample</h3>
<p>Function <a href="mathgl_en_39.html#tube">tube</a> draw tube with variable radius. The sample code is:
</p><pre class="verbatim">int sample(mglGraph *gr)
{
mglData y,y1,y2; mgls_prepare1d(&y,&y1,&y2); y1/=20;
gr->SubPlot(2,2,0,""); gr->Title("Tube plot (default)");
gr->Light(true); gr->Box(); gr->Tube(y,0.05);
gr->SubPlot(2,2,1,""); gr->Title("variable radius");
gr->Box(); gr->Tube(y,y1);
gr->SubPlot(2,2,2,""); gr->Title("'\\#' style");
gr->Box(); gr->Tube(y,0.05,"#");
mglData yc(50), xc(50), z(50); z.Modify("2*x-1");
yc.Modify("sin(pi*(2*x-1))"); xc.Modify("cos(pi*2*x-pi)");
gr->SubPlot(2,2,3); gr->Title("3d variant"); gr->Rotate(50,60);
gr->Box(); gr->Tube(xc,yc,z,y2,"r");
return 0;
}
</pre>
<img src="../png/tube.png" alt="Example of Tube()">
<hr size="6">
<a name="Tape-sample"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Tube-sample" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#Torus-sample" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="mathgl_en_9.html#Examples" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#g_t1D-samples" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_20.html#General-concepts" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="mathgl_en.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_88.html#Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Tape-sample-1"></a>
<h3 class="subsection">2.5.20 Tape sample</h3>
<p>Function <a href="mathgl_en_39.html#tape">tape</a> draw tapes which rotate around the curve as normal and binormal. The sample code is:
</p><pre class="verbatim">int sample(mglGraph *gr)
{
mglData y; mgls_prepare1d(&y);
mglData xc(50), yc(50), z(50);
yc.Modify("sin(pi*(2*x-1))");
xc.Modify("cos(pi*2*x-pi)"); z.Fill(-1,1);
gr->SubPlot(2,2,0,""); gr->Title("Tape plot (default)");
gr->Box(); gr->Tape(y); gr->Plot(y,"k");
gr->SubPlot(2,2,1); gr->Title("3d variant, 2 colors");
gr->Rotate(50,60); gr->Light(true);
gr->Box(); gr->Plot(xc,yc,z,"k"); gr->Tape(xc,yc,z,"rg");
gr->SubPlot(2,2,2); gr->Title("3d variant, x only"); gr->Rotate(50,60);
gr->Box(); gr->Plot(xc,yc,z,"k");
gr->Tape(xc,yc,z,"xr"); gr->Tape(xc,yc,z,"xr#");
gr->SubPlot(2,2,3); gr->Title("3d variant, z only"); gr->Rotate(50,60);
gr->Box(); gr->Plot(xc,yc,z,"k");
gr->Tape(xc,yc,z,"zg"); gr->Tape(xc,yc,z,"zg#");
return 0;
}
</pre>
<img src="../png/tape.png" alt="Example of Tape()">
<hr size="6">
<a name="Torus-sample"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Tape-sample" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_15.html#g_t2D-samples" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="mathgl_en_9.html#Examples" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#g_t1D-samples" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_20.html#General-concepts" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="mathgl_en.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_88.html#Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Torus-sample-1"></a>
<h3 class="subsection">2.5.21 Torus sample</h3>
<p>Function <a href="mathgl_en_39.html#torus">torus</a> draw surface of the curve rotation. The sample code is:
</p><pre class="verbatim">int sample(mglGraph *gr)
{
mglData y1,y2; mgls_prepare1d(0,&y1,&y2);
gr->SubPlot(2,2,0); gr->Title("Torus plot (default)");
gr->Light(true); gr->Rotate(50,60); gr->Box(); gr->Torus(y1,y2);
if(mini) return;
gr->SubPlot(2,2,1); gr->Title("'x' style"); gr->Rotate(50,60);
gr->Box(); gr->Torus(y1,y2,"x");
gr->SubPlot(2,2,2); gr->Title("'z' style"); gr->Rotate(50,60);
gr->Box(); gr->Torus(y1,y2,"z");
gr->SubPlot(2,2,3); gr->Title("'\\#' style"); gr->Rotate(50,60);
gr->Box(); gr->Torus(y1,y2,"#");
return 0;
}
</pre>
<img src="../png/torus.png" alt="Example of Torus()">
<hr size="6">
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Tape-sample" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_15.html#g_t2D-samples" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="mathgl_en_9.html#Examples" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#g_t1D-samples" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_20.html#General-concepts" title="Next chapter"> >> </a>]</td>
</tr></table>
<p>
<font size="-1">
This document was generated by <em>Build Daemon user</em> on <em>December 22, 2013</em> using <a href="http://www.nongnu.org/texi2html/"><em>texi2html 1.82</em></a>.
</font>
<br>
</p>
</body>
</html>
|