Open-Notes.net - a free, fast, convenient way to store notes online!
Select your style     Blue Style     Black Style     Let there be snow!     Disable snow
[CNW:Counter]

Graphing with HC

Graphing support was introduced with version 0.6 of HC, in 0.7, I added 3D graph support, and in 0.9.2, I added support for multiple functions displayed on one graph.
HC uses the plplot library to generate the graphs, and uses the PNG driver on Linux et. al, or wingcc if on Windows.

This is now supported both in the CLI and GUI versions.

Example usage for 2D graphs
Usage is simple; fire up your copy of hc and type something according to the following syntax:
graph(expr[,xmin,xmax,ymin,ymax])
(xmin, etc., are optional, the last will be used if none will be entered)
and of course replace expr with the expression you want to use for your graph (for example x^2), and xmin, xmax, ymin and ymax with the coordinates of the "window" of the graph.
If on Linux/*nix, you will then be prompted to enter a filename to save the graph to; enter something ending in .png, for example graph.png.
Afterwards, simply open the newly generated graph.png with your favorite image viewer.
If on Windows, the graph should be displayed right away, using the wingcc driver.

Example generated 2D graph

As you can see, hc also properly handles discontinuities (both for 2D and 3D).



If you want to graph multiple functions in one graph, use the gmul() function, which takes an arbitrary number of function expressions as its argument.
For example, to graph the functions x, x^2, x^3 and x^4 on the same graph, you would use:
gmul(x,x^2,x^3,x^4)
(note : to set xmin, xmax, ymin, ymax, call graph() first with one of the functions and the corresponding xmin, etc.)
Which would show:


Example usage for 3D graphs
Usage is very similar to 2D graphs; only you have to use the graph3() function, instead of graph().
Not surprisingly, the syntax for this function is:
graph3(expr[,xmin,xmax,ymin,ymax,zmin,zmax])
(xmin, etc., are again optional)
Again, replace expr with a valid expression you want to use for your graph (for example (x^3*y-y^3*x)/390 (you could also use implied multiplication from version 0.9.3)), and xmin, xmax, ymin, ymax, zmin and zmax with the appropriate coordinates.
Example generated 3D graph

Back to HC's main page



Creative Commons License
This work by Jan Dlabal is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.