| 1 |
lars |
1 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
|
|
|
2 |
<HTML>
|
|
|
3 |
<HEAD>
|
|
|
4 |
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
|
|
|
5 |
<LINK REL="Start" HREF="index.html">
|
|
|
6 |
<LINK REL="Contents" HREF="toc.html">
|
|
|
7 |
<LINK REL="Prev" HREF="719Formattingtheaxis.html">
|
|
|
8 |
<LINK REL="Next" HREF="7192Scientificstyleaxis.html">
|
|
|
9 |
<STYLE TYPE="text/css"><!--
|
|
|
10 |
BODY { font-family: serif }
|
|
|
11 |
H1 { font-family: sans-serif }
|
|
|
12 |
H2 { font-family: sans-serif }
|
|
|
13 |
H3 { font-family: sans-serif }
|
|
|
14 |
H4 { font-family: sans-serif }
|
|
|
15 |
H5 { font-family: sans-serif }
|
|
|
16 |
H6 { font-family: sans-serif }
|
|
|
17 |
SUB { font-size: smaller }
|
|
|
18 |
SUP { font-size: smaller }
|
|
|
19 |
PRE { font-family: monospace }
|
|
|
20 |
A { text-decoration: none }
|
|
|
21 |
--></STYLE>
|
|
|
22 |
</HEAD>
|
|
|
23 |
<BODY>
|
|
|
24 |
<A HREF="toc.html">Contents</A>
|
|
|
25 |
<A HREF="719Formattingtheaxis.html">Previous</A>
|
|
|
26 |
<A HREF="7192Scientificstyleaxis.html">Next</A>
|
|
|
27 |
<HR NOSHADE>
|
|
|
28 |
<H3><A NAME="7_19_1">7.19.1 Standard two axis graphs</A></H3>
|
|
|
29 |
<P> Assuming we start with the traditional two axis graph, one X and one
|
|
|
30 |
Y axis. You may then change the position of each axis by calling <A href="../ref/Axis.html#_AXIS_SETPOS">
|
|
|
31 |
Axis::SetPos($aPosition)</A> You have to remember that you need to
|
|
|
32 |
specify the position on the other axis. SO you need to specify the
|
|
|
33 |
world-coordinate for the position. By default the axis are each
|
|
|
34 |
positioned at the 0-point on the other axis, i.e. the axis will cross
|
|
|
35 |
at the 0,0 point in the graph.</P>
|
|
|
36 |
<P> In addition to the standard positioning you may also use the two
|
|
|
37 |
special position markers "min" and "max". This will position the axis
|
|
|
38 |
at the minimum (or maximum) position of the other axis.</P>
|
|
|
39 |
<P> For example, to make sure that the X-axis is always at the bottom of
|
|
|
40 |
the graph (at lowest possible Y-value) you would have to add the line</P>
|
|
|
41 |
<P><DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">
|
|
|
42 |
$graph</FONT><FONT color="#007700">-></FONT><FONT color="#0000BB">xaxis</FONT><FONT
|
|
|
43 |
color="#007700">-></FONT><FONT color="#0000BB">SetPos</FONT><FONT color="#007700">
|
|
|
44 |
(</FONT><FONT color="#DD0000">"min"</FONT><FONT color="#007700">);</FONT><FONT
|
|
|
45 |
color="#0000BB"></FONT></FONT></CODE></DIV></P>
|
|
|
46 |
<P></P>
|
|
|
47 |
<P> To change the color and width of the axis you have to make use of
|
|
|
48 |
the <A href="../ref/Axis.html#_AXIS_SETCOLOR"> Axis::SetColor()</A> and
|
|
|
49 |
<A href="../ref/Axis.html#_AXIS_SETWEIGHT"> Axis::SetWeight()</A>
|
|
|
50 |
methods.</P>
|
|
|
51 |
<HR> <SMALL><STRONG> Invisible axis</STRONG> Even though JpGraph (1.7)
|
|
|
52 |
doesn't directly support "hidden" axis where the labels are still drawn
|
|
|
53 |
it is very easy to achieve this effect by setting the colors of the
|
|
|
54 |
axis to be the same as the background. See the example barintex2.php in
|
|
|
55 |
the Example directory. To completely hide an axis you can make use of
|
|
|
56 |
the <A href="../ref/Axis.html#_AXIS_HIDE"> Hide()</A></SMALL>
|
|
|
57 |
<HR>
|
|
|
58 |
<P> You might also want to add titles to the axis. This is done through
|
|
|
59 |
the <A href="../ref/Axis.html#_AXIS_SETTITLE"> Axis::SetTitle()</A>
|
|
|
60 |
method. This is actually just a shortcut for accessing the title
|
|
|
61 |
property direct. Axis::title::Set() which also allow you to set the
|
|
|
62 |
alignment in one call.</P>
|
|
|
63 |
<P> By default the position of the title is to the far right for the
|
|
|
64 |
X-axis and in the middle (and 90 degrees rotated) for the Y-axis.</P>
|
|
|
65 |
<P> You can adjust the position of the title with the help of the second
|
|
|
66 |
argument to the <A href="../ref/Axis.html#_AXIS_SETTITLE">
|
|
|
67 |
Axis::SetTitle()</A> method.</P>
|
|
|
68 |
<P> The possible positions are "high","middle" and "low" which refers to
|
|
|
69 |
the scale values on the axis.</P>
|
|
|
70 |
<P> One common modification you might want to do to the title is to
|
|
|
71 |
increase the margin between the axis and the actual title. This is
|
|
|
72 |
often necessary to do for the Y-axis if the values displayed are large.
|
|
|
73 |
You may adjust the distance (in pixels) between the axis and the title
|
|
|
74 |
by using the method <A href="../ref/Axis.html#_AXIS_SETTITLEMARGIN">
|
|
|
75 |
Axis::SetTitleMargin()</A></P>
|
|
|
76 |
<P> So for example to increase the margin on the Y-axis you might add
|
|
|
77 |
the line</P>
|
|
|
78 |
<P><DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">
|
|
|
79 |
$graph</FONT><FONT color="#007700">-></FONT><FONT color="#0000BB">yaxis</FONT><FONT
|
|
|
80 |
color="#007700">-></FONT><FONT color="#0000BB">SetTitleMargin</FONT><FONT
|
|
|
81 |
color="#007700">(</FONT><FONT color="#0000BB">40</FONT><FONT color="#007700">
|
|
|
82 |
);</FONT><FONT color="#0000BB"></FONT></FONT></CODE></DIV></P>
|
|
|
83 |
<P></P>
|
|
|
84 |
<P> to your code.</P>
|
|
|
85 |
<P> Finally we mention something about the positioning of tick marks and
|
|
|
86 |
labels on the axis. You have the possibility to choose what side of the
|
|
|
87 |
axis the tick marks and the labels should be at. For the X-axis this
|
|
|
88 |
can be specified as either on the the top (inside the plot area) or at
|
|
|
89 |
bottom (outside of the plotarea). In the same way you can specify for
|
|
|
90 |
the Y-axis if the labels ( or ticks) should be on the left or right
|
|
|
91 |
side.</P>
|
|
|
92 |
<P> To adjust the label positioning you have to use the method <A href="../ref/Axis.html#_AXIS_SETTITLESIDE">
|
|
|
93 |
Axis::SetTitleSide()</A> and to adjust the position of the tick mark
|
|
|
94 |
you have to use the method <A href="../ref/Axis.html#_AXIS_SETTICKSIDE">
|
|
|
95 |
SetTickSide()</A><DIV class="note"><B>Note:</B> There is also an alias
|
|
|
96 |
for this method, SetTickDirection() which is deprecated from version
|
|
|
97 |
1.7 but kept for backwards compatibility.</DIV> Valid arguments for
|
|
|
98 |
these methods are</P>
|
|
|
99 |
<UL>
|
|
|
100 |
<LI> SIDE_UP</LI>
|
|
|
101 |
<LI> SIDE_DOWN</LI>
|
|
|
102 |
<LI> SIDE_LEFT</LI>
|
|
|
103 |
<LI> SIDE_RIGHT</LI>
|
|
|
104 |
</UL>
|
|
|
105 |
<P> For example, the following lines added to a script would change side
|
|
|
106 |
of the labels and tickmarks for the X-axis.</P>
|
|
|
107 |
<P><DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">
|
|
|
108 |
$graph</FONT><FONT color="#007700">-></FONT><FONT color="#0000BB">xaxis</FONT><FONT
|
|
|
109 |
color="#007700">-></FONT><FONT color="#0000BB">SetLabelPos</FONT><FONT color="#007700">
|
|
|
110 |
(</FONT><FONT color="#0000BB">SIDE_UP</FONT><FONT color="#007700">);
|
|
|
111 |
<BR></FONT><FONT color="#0000BB">$graph</FONT><FONT color="#007700">-></FONT><FONT
|
|
|
112 |
color="#0000BB">xaxis</FONT><FONT color="#007700">-></FONT><FONT color="#0000BB">
|
|
|
113 |
SetTickSide</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
|
|
|
114 |
SIDE_DOWN</FONT><FONT color="#007700">);</FONT><FONT color="#0000BB"></FONT>
|
|
|
115 |
</FONT></CODE></DIV></P>
|
|
|
116 |
<P></P>
|
|
|
117 |
<P> This technique is for example used if you position the X-axis at the
|
|
|
118 |
top of the graph as the following example shows.<DIV class="example">
|
|
|
119 |
<BR> <A href="exframes/frame_topxaxisex1.html" target="blank"><IMG border="0"
|
|
|
120 |
HEIGHT="200" src="img/img/img/img/img/img/topxaxisex1.png" WIDTH="400"></A>
|
|
|
121 |
<BR><B>Figure 97:</B> Example of both how to adjust the position of the
|
|
|
122 |
X-axis as well as adjusting the side for the tick and axis title <A href="exframes/frame_topxaxisex1.html"
|
|
|
123 |
target="blank">[src]</A>
|
|
|
124 |
<P></P>
|
|
|
125 |
</DIV></P>
|
|
|
126 |
<P></P>
|
|
|
127 |
<HR NOSHADE>
|
|
|
128 |
<A HREF="toc.html">Contents</A>
|
|
|
129 |
<A HREF="719Formattingtheaxis.html">Previous</A>
|
|
|
130 |
<A HREF="7192Scientificstyleaxis.html">Next</A>
|
|
|
131 |
</BODY>
|
|
|
132 |
</HTML>
|