/usr/share/doc/pyxplot/html/ex-axislab.html is in pyxplot-doc 0.8.4-3.
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 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta name="generator" content="plasTeX" />
<meta content="text/html; charset=utf-8" http-equiv="content-type" />
<title>PyXPlot Users' Guide: Setting Axis Ranges</title>
<link href="sect0018.html" title="Interactive Help" rel="next" />
<link href="sec-pointtype.html" title="Plotting Styles" rel="prev" />
<link href="ch-first_steps.html" title="First Steps With PyXPlot" rel="up" />
<link rel="stylesheet" href="styles/styles.css" />
</head>
<body>
<div class="navigation">
<table cellspacing="2" cellpadding="0" width="100%">
<tr>
<td><a href="sec-pointtype.html" title="Plotting Styles"><img alt="Previous: Plotting Styles" border="0" src="icons/previous.gif" width="32" height="32" /></a></td>
<td><a href="ch-first_steps.html" title="First Steps With PyXPlot"><img alt="Up: First Steps With PyXPlot" border="0" src="icons/up.gif" width="32" height="32" /></a></td>
<td><a href="sect0018.html" title="Interactive Help"><img alt="Next: Interactive Help" border="0" src="icons/next.gif" width="32" height="32" /></a></td>
<td class="navtitle" align="center">PyXPlot Users' Guide</td>
<td><a href="index.html" title="Table of Contents"><img border="0" alt="" src="icons/contents.gif" width="32" height="32" /></a></td>
<td><a href="sect0255.html" title="Index"><img border="0" alt="" src="icons/index.gif" width="32" height="32" /></a></td>
<td><img border="0" alt="" src="icons/blank.gif" width="32" height="32" /></td>
</tr>
</table>
</div>
<div class="breadcrumbs">
<span>
<span>
<a href="index.html">PyXPlot Users' Guide</a> <b>:</b>
</span>
</span><span>
<span>
<a href="sect0001.html">Introduction to PyXPlot</a> <b>:</b>
</span>
</span><span>
<span>
<a href="ch-first_steps.html">First Steps With PyXPlot</a> <b>:</b>
</span>
</span><span>
<span>
<b class="current">Setting Axis Ranges</b>
</span>
</span>
<hr />
</div>
<div><h1 id="ex:axislab">3.14 Setting Axis Ranges</h1>
<p>By default, PyXPlot automatically scales axes to some sensible range which contains all of the plotted data. However, it is possible for the user to override this and set his own range.<a name="a0000000392" id="a0000000392"></a> This can be done directly from the plot command, by following the word <tt class="tt">plot</tt> with the syntax <tt class="tt">[minimum:maximum]</tt>.<a href="#a0000000393" class="footnote"><sup class="footnotemark">1</sup></a> The first specified range applies to the <tt class="tt">x</tt>-axis, and the second to the <tt class="tt">y</tt>-axis.<a href="#a0000000394" class="footnote"><sup class="footnotemark">2</sup></a> In the following example, the first three cylindrical Bessel functions are plotted in the range <img src="images/img-0047.png" alt="$0<x<10$" style="vertical-align:0px;
width:86px;
height:12px" class="math gen" />: </p><pre>
plot [0:10][-0.5:1] besselJ(0,x), besselJ(1,x), besselJ(2,x)
</pre><center>
<img src="images/img-0049.png" alt="\includegraphics[width=8cm]{examples/eps/ex_intro_bessel}" style="width:8cm" /> </center><p>Any of the values can be omitted, as in the following plot of three Legendre polynomials: </p><pre>
set key xcentre
plot [-1:1][:] legendreP(2,x), legendreP(4,x), legendreP(6,x)
</pre><center>
<img src="images/img-0052.png" alt="\includegraphics[width=8cm]{examples/eps/ex_intro_legendre}" style="width:8cm" /> </center><p>Here, we have used the <tt class="tt">set key</tt> command to specify that the plot’s legend should be horizontally aligned in the centre of the plot, to complement the symmetry of the Legendre polynomials. This command will be described more fully in Section <a href="sec-legends.html">1.7</a>. </p><p>Alternatively, ranges can be set before the <tt class="tt">plot</tt> statement, using the <tt class="tt">set xrange</tt> command<a name="a0000000395" id="a0000000395"></a>, as in the examples: </p><pre>
set xrange [-2:2]
set yrange [a:b]
</pre><p>If an asterisk is supplied in place of either of the limits in this command, then any limit which had previously been set is switched off, and the axis returns to its default autoscaling behaviour: </p><pre>
set xrange [-2:*]
</pre><p>A similar effect may be obtained using the <tt class="tt">set autoscale</tt> command<a name="a0000000396" id="a0000000396"></a>, which takes a list of the axes to which it is to apply. Both the upper and lower limits of these axes are set to scale automatically. If no list is supplied, then the command is applied to all axes. </p><pre>
set autoscale x y
set autoscale
</pre><p>The range supplied to the <tt class="tt">set xrange</tt> can be followed by the word <tt class="tt">reverse</tt> to indicate that the axis should run from right-to-left, or from top-to-bottom. In practice, this is of limited use when an explicit range is specified, as the following two commands are equivalent: </p><pre>
set xrange [-2:2] reverse
set xrange [2:-2] noreverse
</pre><p>However, this is useful when axes are set to autoscale: </p><pre>
set xrange [*:*] reverse
</pre><p>Axes can be set to have logarithmic scales by using the <tt class="tt">set logscale</tt> command<a name="a0000000397" id="a0000000397"></a>, which also takes a list of axes to which it should apply. Its converse is <tt class="tt">set nologscale</tt><a name="a0000000398" id="a0000000398"></a>: </p><pre>
set logscale
set nologscale y x x2
</pre><p>Further discussion of the configuration of axes can be found in Section <a href="sec-multiple_axes.html">1.8.1</a>. </p><p> <span class="upshape"><span class="mdseries"><span class="rm">A diagram of the trajectories of projectiles fired with different initial velocities.</span></span></span></p><div>
<table cellspacing="0" class="tabular">
<tr>
<td style="border-top-style:solid; border-left:1px solid black; border-right:1px solid black; border-top-color:black; border-top-width:1px; text-align:left"><p> In this example we produce a diagram of the trajectories of projectiles fired by a cannon at the origin with different initial velocities <img src="images/img-0054.png" alt="$v$" style="vertical-align:0px;
width:9px;
height:8px" class="math gen" /> and different angles of inclination <img src="images/img-0055.png" alt="$\theta $" style="vertical-align:0px;
width:9px;
height:12px" class="math gen" />. According to the equations of motion under constant acceleration, the distance of such a projectile from the origin after time <img src="images/img-0056.png" alt="$t$" style="vertical-align:0px;
width:6px;
height:12px" class="math gen" /> is given by </p><table id="a0000000399" cellpadding="7" width="100%" cellspacing="0" class="eqnarray">
<tr id="a0000000400">
<td style="width:40%"> </td>
<td style="vertical-align:middle; text-align:right"><img src="images/img-0057.png" alt="$\displaystyle x(t) $" style="vertical-align:-4px; width:30px; height:18px" class="math gen" /></td>
<td style="vertical-align:middle; text-align:center"><img src="images/img-0058.png" alt="$\displaystyle = $" style="vertical-align:2px; width:12px; height:4px" class="math gen" /></td>
<td style="vertical-align:middle; text-align:left"><img src="images/img-0059.png" alt="$\displaystyle vt\cos \, \theta $" style="vertical-align:0px; width:58px; height:12px" class="math gen" /></td>
<td style="width:40%"> </td>
<td style="width:20%" class="eqnnum"> </td>
</tr><tr id="a0000000401">
<td style="width:40%"> </td>
<td style="vertical-align:middle; text-align:right"><img src="images/img-0060.png" alt="$\displaystyle h(t) $" style="vertical-align:-4px; width:29px; height:18px" class="math gen" /></td>
<td style="vertical-align:middle; text-align:center"><img src="images/img-0058.png" alt="$\displaystyle = $" style="vertical-align:2px; width:12px; height:4px" class="math gen" /></td>
<td style="vertical-align:middle; text-align:left"><img src="images/img-0061.png" alt="$\displaystyle vt\sin \, \theta + \nicefrac {1}{2}gt^2 $" style="vertical-align:-5px; width:122px; height:22px" class="math gen" /></td>
<td style="width:40%"> </td>
<td style="width:20%" class="eqnnum"> </td>
</tr>
</table><p> where <img src="images/img-0062.png" alt="$x(t)$" style="vertical-align:-4px;
width:30px;
height:18px" class="math gen" /> is the horizontal displacement of the projectile and <img src="images/img-0063.png" alt="$h(t)$" style="vertical-align:-4px;
width:29px;
height:18px" class="math gen" /> the vertical displacement. Eliminating <img src="images/img-0056.png" alt="$t$" style="vertical-align:0px;
width:6px;
height:12px" class="math gen" /> from these equation gives the expression </p><table id="a0000000402" class="equation" width="100%" cellspacing="0" cellpadding="7">
<tr>
<td style="width:40%"> </td>
<td><img src="images/img-0064.png" alt="\[ h(x) = x\tan \, \theta - \frac{gx^2}{2v^2\cos ^2\, \theta }. \]" style="width:220px;
height:40px" class="math gen" /></td>
<td style="width:40%"> </td>
<td class="eqnnum" style="width:20%"> </td>
</tr>
</table></td>
</tr><tr>
<td style="text-align:left; border-right:1px solid black; border-left:1px solid black"><p>In the script below, we plot this function for five different values of <img src="images/img-0054.png" alt="$v$" style="vertical-align:0px;
width:9px;
height:8px" class="math gen" /> and <img src="images/img-0055.png" alt="$\theta $" style="vertical-align:0px;
width:9px;
height:12px" class="math gen" />. </p></td>
</tr><tr>
<td style="text-align:left; border-right:1px solid black; border-left:1px solid black"><p><small class="footnotesize"><tt class="tt">g = 9.81 # Acceleration due to gravity</tt><br /><tt class="tt">d2r = pi/180 # Convert degrees to radians</tt><br /><tt class="tt"></tt><br /></small></p></td>
</tr><tr>
<td style="text-align:left; border-right:1px solid black; border-left:1px solid black"><p><small class="footnotesize"><tt class="tt"># The mathematical equation of a trajectory</tt><br /><tt class="tt">h(x,theta,v) = x*tan(theta*d2r) - 0.5*g*x**2/(v**2*cos(theta*d2r)**2)</tt><br /><tt class="tt"></tt><br /></small></p></td>
</tr><tr>
<td style="text-align:left; border-right:1px solid black; border-left:1px solid black"><p><small class="footnotesize"><tt class="tt"># Plot configuration</tt><br /><tt class="tt">set xlabel "$x/<img src="images/img-0006.png" alt="$\backslash $" style="vertical-align:-5px;
width:7px;
height:18px" class="math gen" />rm m$"</tt><br /><tt class="tt">set ylabel "$h/<img src="images/img-0006.png" alt="$\backslash $" style="vertical-align:-5px;
width:7px;
height:18px" class="math gen" />rm m$"</tt><br /><tt class="tt">set xrange [0:20]</tt><br /><tt class="tt">set yrange [0:]</tt><br /><tt class="tt">set key below</tt><br /><tt class="tt">set title ’Trajectories of projectiles fired with speed $v$ and angle $<img src="images/img-0006.png" alt="$\backslash $" style="vertical-align:-5px;
width:7px;
height:18px" class="math gen" />theta$’</tt><br /><tt class="tt">plot h(x,30,10) title "$<img src="images/img-0006.png" alt="$\backslash $" style="vertical-align:-5px;
width:7px;
height:18px" class="math gen" />theta=30<img src="images/img-0024.png" alt="\^{}" style="vertical-align:9px; width:5px; height:4px" class="accent gen" /><img src="images/img-0006.png" alt="$\backslash $" style="vertical-align:-5px;
width:7px;
height:18px" class="math gen" />circ;<img src="images/img-0006.png" alt="$\backslash $" style="vertical-align:-5px;
width:7px;
height:18px" class="math gen" />qquad v=10<img src="images/img-0006.png" alt="$\backslash $" style="vertical-align:-5px;
width:7px;
height:18px" class="math gen" />,{<img src="images/img-0006.png" alt="$\backslash $" style="vertical-align:-5px;
width:7px;
height:18px" class="math gen" />rm m<img src="images/img-0006.png" alt="$\backslash $" style="vertical-align:-5px;
width:7px;
height:18px" class="math gen" />,s<img src="images/img-0024.png" alt="\^{}" style="vertical-align:9px; width:5px; height:4px" class="accent gen" />{-1}}$", <img src="images/img-0006.png" alt="$\backslash $" style="vertical-align:-5px;
width:7px;
height:18px" class="math gen" /></tt><br /><tt class="tt">h(x,45,10) title "$<img src="images/img-0006.png" alt="$\backslash $" style="vertical-align:-5px;
width:7px;
height:18px" class="math gen" />theta=45<img src="images/img-0024.png" alt="\^{}" style="vertical-align:9px; width:5px; height:4px" class="accent gen" /><img src="images/img-0006.png" alt="$\backslash $" style="vertical-align:-5px;
width:7px;
height:18px" class="math gen" />circ;<img src="images/img-0006.png" alt="$\backslash $" style="vertical-align:-5px;
width:7px;
height:18px" class="math gen" />qquad v=10<img src="images/img-0006.png" alt="$\backslash $" style="vertical-align:-5px;
width:7px;
height:18px" class="math gen" />,{<img src="images/img-0006.png" alt="$\backslash $" style="vertical-align:-5px;
width:7px;
height:18px" class="math gen" />rm m<img src="images/img-0006.png" alt="$\backslash $" style="vertical-align:-5px;
width:7px;
height:18px" class="math gen" />,s<img src="images/img-0024.png" alt="\^{}" style="vertical-align:9px; width:5px; height:4px" class="accent gen" />{-1}}$", <img src="images/img-0006.png" alt="$\backslash $" style="vertical-align:-5px;
width:7px;
height:18px" class="math gen" /></tt><br /><tt class="tt">h(x,60,10) title "$<img src="images/img-0006.png" alt="$\backslash $" style="vertical-align:-5px;
width:7px;
height:18px" class="math gen" />theta=60<img src="images/img-0024.png" alt="\^{}" style="vertical-align:9px; width:5px; height:4px" class="accent gen" /><img src="images/img-0006.png" alt="$\backslash $" style="vertical-align:-5px;
width:7px;
height:18px" class="math gen" />circ;<img src="images/img-0006.png" alt="$\backslash $" style="vertical-align:-5px;
width:7px;
height:18px" class="math gen" />qquad v=10<img src="images/img-0006.png" alt="$\backslash $" style="vertical-align:-5px;
width:7px;
height:18px" class="math gen" />,{<img src="images/img-0006.png" alt="$\backslash $" style="vertical-align:-5px;
width:7px;
height:18px" class="math gen" />rm m<img src="images/img-0006.png" alt="$\backslash $" style="vertical-align:-5px;
width:7px;
height:18px" class="math gen" />,s<img src="images/img-0024.png" alt="\^{}" style="vertical-align:9px; width:5px; height:4px" class="accent gen" />{-1}}$", <img src="images/img-0006.png" alt="$\backslash $" style="vertical-align:-5px;
width:7px;
height:18px" class="math gen" /></tt><br /><tt class="tt">h(x,30,15) title "$<img src="images/img-0006.png" alt="$\backslash $" style="vertical-align:-5px;
width:7px;
height:18px" class="math gen" />theta=30<img src="images/img-0024.png" alt="\^{}" style="vertical-align:9px; width:5px; height:4px" class="accent gen" /><img src="images/img-0006.png" alt="$\backslash $" style="vertical-align:-5px;
width:7px;
height:18px" class="math gen" />circ;<img src="images/img-0006.png" alt="$\backslash $" style="vertical-align:-5px;
width:7px;
height:18px" class="math gen" />qquad v=15<img src="images/img-0006.png" alt="$\backslash $" style="vertical-align:-5px;
width:7px;
height:18px" class="math gen" />,{<img src="images/img-0006.png" alt="$\backslash $" style="vertical-align:-5px;
width:7px;
height:18px" class="math gen" />rm m<img src="images/img-0006.png" alt="$\backslash $" style="vertical-align:-5px;
width:7px;
height:18px" class="math gen" />,s<img src="images/img-0024.png" alt="\^{}" style="vertical-align:9px; width:5px; height:4px" class="accent gen" />{-1}}$", <img src="images/img-0006.png" alt="$\backslash $" style="vertical-align:-5px;
width:7px;
height:18px" class="math gen" /></tt><br /><tt class="tt">h(x,60,15) title "$<img src="images/img-0006.png" alt="$\backslash $" style="vertical-align:-5px;
width:7px;
height:18px" class="math gen" />theta=60<img src="images/img-0024.png" alt="\^{}" style="vertical-align:9px; width:5px; height:4px" class="accent gen" /><img src="images/img-0006.png" alt="$\backslash $" style="vertical-align:-5px;
width:7px;
height:18px" class="math gen" />circ;<img src="images/img-0006.png" alt="$\backslash $" style="vertical-align:-5px;
width:7px;
height:18px" class="math gen" />qquad v=15<img src="images/img-0006.png" alt="$\backslash $" style="vertical-align:-5px;
width:7px;
height:18px" class="math gen" />,{<img src="images/img-0006.png" alt="$\backslash $" style="vertical-align:-5px;
width:7px;
height:18px" class="math gen" />rm m<img src="images/img-0006.png" alt="$\backslash $" style="vertical-align:-5px;
width:7px;
height:18px" class="math gen" />,s<img src="images/img-0024.png" alt="\^{}" style="vertical-align:9px; width:5px; height:4px" class="accent gen" />{-1}}$"</tt> </small> </p></td>
</tr><tr>
<td style="text-align:left; border-right:1px solid black; border-left:1px solid black"><p>The resulting plot is shown below: </p></td>
</tr><tr>
<td style="text-align:left; border-right:1px solid black; border-left:1px solid black"><center> <img src="images/img-0066.png" alt="\includegraphics{examples/eps/ex_trajectories}" style="width:530px; height:517px" />
</center></td>
</tr><tr>
<td style="border-bottom-style:solid; border-bottom-width:1px; border-left:1px solid black; border-right:1px solid black; text-align:left; border-bottom-color:black"><p>In the next chapter, we will meet various ways in which this script could be improved. Here, we have used to numerical constants, <tt class="tt">g</tt> being the acceleration due to gravity, and <tt class="tt">d2r</tt> being a factor for converting angles between degrees and radians. The former is, in fact, already defined within PyXPlot as a numerical constant, and the latter conversion can be made using PyXPlot’s automatic ability to convert numbers between different physical units. </p></td>
</tr>
</table>
</div></div>
<div id="footnotes">
<p><b>Footnotes</b></p>
<ol>
<li id="a0000000393">An alternative valid syntax is to replace the colon with the word <tt class="tt">to</tt>: <tt class="tt">[minimum to maximum]</tt>.</li><li id="a0000000394">As will be discussed in Section <a href="sec-multiple_axes.html">1.8.1</a>, if further ranges are specified, they apply to the <tt class="tt">x2</tt>-axis, then the <tt class="tt">y2</tt>-axis, and so forth.</li>
</ol>
</div>
<div class="navigation">
<table cellspacing="2" cellpadding="0" width="100%">
<tr>
<td><a href="sec-pointtype.html" title="Plotting Styles"><img alt="Previous: Plotting Styles" border="0" src="icons/previous.gif" width="32" height="32" /></a></td>
<td><a href="ch-first_steps.html" title="First Steps With PyXPlot"><img alt="Up: First Steps With PyXPlot" border="0" src="icons/up.gif" width="32" height="32" /></a></td>
<td><a href="sect0018.html" title="Interactive Help"><img alt="Next: Interactive Help" border="0" src="icons/next.gif" width="32" height="32" /></a></td>
<td class="navtitle" align="center">PyXPlot Users' Guide</td>
<td><a href="index.html" title="Table of Contents"><img border="0" alt="" src="icons/contents.gif" width="32" height="32" /></a></td>
<td><a href="sect0255.html" title="Index"><img border="0" alt="" src="icons/index.gif" width="32" height="32" /></a></td>
<td><img border="0" alt="" src="icons/blank.gif" width="32" height="32" /></td>
</tr>
</table>
</div>
<script language="javascript" src="icons/imgadjust.js" type="text/javascript"></script>
</body>
</html>
|