<!–Converted with LaTeX2HTML 2022 (Released January 1, 2022) –> <HTML lang="en"> <HEAD> <TITLE>Contents of Example 4:</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8"> <META NAME="viewport" CONTENT="width=device-width, initial-scale=1.0"> <META NAME="Generator" CONTENT="LaTeX2HTML v2022">
<LINK REL="STYLESHEET" HREF="tutorial.css">
<LINK REL="next" HREF="node7_mn.html"> <LINK REL="previous" HREF="node5_mn.html"> <LINK REL="up" HREF="node2_mn.html"> <LINK REL="next" HREF="node7_mn.html"> </HEAD>
<BODY bgcolor="#ffffff" text="#000000" link="#9944EE" vlink="#0000ff" alink="#00ff00">
<H4><A ID="SECTION00020040000000000000"> Example 4:</A> </H4> In the above plots of sin(<I>x</I>), it would make more sense to label the axis in units of <I>π</I>. The position and labels of the tic labels may be specified by the user, with the <TT>set xtics</TT> and <TT>set ytics</TT> commands. This is demonstrated by the following example, shown in Figure <A HREF="node6_ct.html#eg4"><IMG ALT="[*]" SRC="crossref.png"></A>.
<P>
<PRE> set terminal latex set output "eg4.tex" set format y " setformatx"set title "This is sin(x)" set xlabel "This is the x axis" set ylabel "sin(x)" set nokey set xtics -pi, pi/4 plot [-pi:pi] [-1:1] sin(x) </PRE>
<P>
<DIV class="CENTER">
<P><A ID="eg4"></A></P>
<P>
<DIV class="CENTER"> <!– MATH
–>
<IMG
STYLE="" SRC="img4.png"
ALT="
<32>>... ... |
<P> Since <TT>pi</TT> is a predefined variable in GNUPLOT, we can use it anywhere we may use an expression. The <TT>set xtics</TT> command here specifies that the tics on the <I>x</I> axis start at - <I>π</I> and increment by <I>π</I>/4. Since no end point is given, the tics continue to the right edge. We have also turned off the key, and changed the format to restrict the <I>x</I>-axis tic labels to 2 decimal places.
<P> With a little more work, the plot can look even better. Another form of this command allows us to specify the label and position of each tic individually. Replacing the above <TT>set xtics</TT> command with the following gives us Figure <A HREF="node6_ct.html#eg5"><IMG ALT="[*]" SRC="crossref.png"></A>. We also make use of the line continuation character, the backslash (<code>/code>), to spread out this command for readability.
<P>
<PRE>
set xtics ("- π" -pi, "
- " -pi/2, "0" 0, "
" pi/2, "π" pi)
</PRE>
<P>
<DIV class="CENTER">
<P><A ID="eg5"></A></P>
<P>
<DIV class="CENTER"> <!– MATH
–>
<IMG
STYLE="" SRC="img5.png"
ALT="
<34>>... ...center |
<P>
<HR>
</BODY> </HTML>