tag:blogger.com,1999:blog-19537122644599448192024-03-13T16:37:11.217-07:00How to PstricksLearn Pstricks by examples!数声风笛离亭晚,我想潇湘君想秦!http://www.blogger.com/profile/08963583502168321534noreply@blogger.comBlogger24125tag:blogger.com,1999:blog-1953712264459944819.post-18365677526222114182012-12-30T00:29:00.000-08:002012-12-30T00:31:18.101-08:00Pstricks custom graphic objectsPstricks contains a large number of graphics object, but sometimes they are not enough, and you need something very special. This can be realized using command "\pscustom[prameters]{commands}".<br />
<br />
Consider this problem. We would like to draw a ribbon like this:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-ipAUJeXM9dk/UN_4OLeqzTI/AAAAAAAAAdg/W-LfvGEqU4o/s1600/pscustom_ribbon_pstricks.jpg"><img border="0" src="http://3.bp.blogspot.com/-ipAUJeXM9dk/UN_4OLeqzTI/AAAAAAAAAdg/W-LfvGEqU4o/s1600/pscustom_ribbon_pstricks.jpg" height="96" width="200" /></a></div>
Of course, properly using the line, polygon or curve commands, we can draw it. But I would say "\pscustom" will make the task very simple. Carefully examine the graph, we find that it is something enclosed by two sine curve. So can we draw such a graph object by simply plotting two sine curve? Let us have a try.<br />
<br />
<div class="codes">
<pre>\documentclass{article}
\usepackage{pstricks}
\usepackage{pst-plot}
\begin{document}
\begin{pspicture}*(-1,-1.5)(7,1.5)
\psgrid
\psset{xunit=0.015cm}
\psplot{0}{360}{x sin 0.25 sub}
\psline(360,0.25)(360,-0.25)
\psplot{360}{0}{x sin 0.25 add}
\psline(0,-0.25)(0,0.25)
\end{pspicture}
\end{document}
</pre>
</div>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://2.bp.blogspot.com/-yzOH9XLAAeA/UN_4OVukp0I/AAAAAAAAAdo/APnFnLHiT-s/s1600/pscustom_preparation_pstricks.jpg" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://2.bp.blogspot.com/-yzOH9XLAAeA/UN_4OVukp0I/AAAAAAAAAdo/APnFnLHiT-s/s1600/pscustom_preparation_pstricks.jpg" height="132" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Fig.1 Custom graphic objects --- preparation</td></tr>
</tbody></table>
<br />
We have successfully draw two sine curves and two lines to join them togethre. The problem is how to fill the area enclosed by the two curve. This is where "\pscustom" steps in. Try the following codes (which is very simillar to the upper ones, except that the lines are enclosed in "\pscustom" command and fill parameters is set.)<br />
<br />
<div class="codes">
<pre>\documentclass{article}
\usepackage{pstricks}
\usepackage{pst-plot}
\begin{document}
\begin{pspicture}*(-1,-1.5)(7,1.5)
\psset{xunit=0.015cm}
\pscustom[fillstyle=solid,fillcolor=red]
{
\psplot{0}{360}{x sin 0.25 sub}
\psline(360,0.25)(360,-0.25)
\psplot{360}{0}{x sin 0.25 add}
\psline(0,-0.25)(0,0.25)
}
\end{pspicture}
\end{document}
</pre>
</div>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://3.bp.blogspot.com/-ipAUJeXM9dk/UN_4OLeqzTI/AAAAAAAAAdg/W-LfvGEqU4o/s1600/pscustom_ribbon_pstricks.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://3.bp.blogspot.com/-ipAUJeXM9dk/UN_4OLeqzTI/AAAAAAAAAdg/W-LfvGEqU4o/s1600/pscustom_ribbon_pstricks.jpg" height="154" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Fig.2 Custom graphic objects --- ribbon</td></tr>
</tbody></table>
<br />
And you get a graph just like what you asked to draw. Now we have successfully creat the ribbon object. You may have a try by using line or curve command to finish the same task, and compare which method is simpler.<br />
<br />
"Practice makes perfect", one more example will be shown.<br />
<br />
<div class="codes">
<pre>\documentclass{article}
\usepackage{pstricks}
\usepackage{pst-plot}
\begin{document}
\begin{pspicture}*(-3.5,-3.5)(3.5,3.5)
\pscustom[fillstyle=solid,fillcolor=red,
linestyle=none]
{
\psplot{-1.414}{1.414}{2 x 2 exp sub}
\psplot{-1.414}{1.414}{-2 x 2 exp add}
}
\psset{linewidth=2pt,linecolor=blue}
\psplot{-3}{3}{2 x 2 exp sub}
\psplot{-3}{3}{-2 x 2 exp add}
\psset{linecolor=black}
\psaxes{->}(0,0)(-3.5,-3.5)(3.5,3.5)
\end{pspicture}
\end{document}
</pre>
</div>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://4.bp.blogspot.com/-f2dHWuiKF4s/UN_4OLTDrbI/AAAAAAAAAdk/6mAeZmYnslI/s1600/pscustom_filledcurves_pstricks.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://4.bp.blogspot.com/-f2dHWuiKF4s/UN_4OLTDrbI/AAAAAAAAAdk/6mAeZmYnslI/s1600/pscustom_filledcurves_pstricks.jpg" height="302" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Fig.3 Custom graphic objects --- filled curves</td></tr>
</tbody></table>
Files Download: <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gVlV4a0pBR245cG8" target="_blank">tex</a> <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gdFFhZDcwWXdpZ1k" target="_blank">ps</a> <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gVFBfUWtjWE44bGs" target="_blank">pdf</a>数声风笛离亭晚,我想潇湘君想秦!http://www.blogger.com/profile/08963583502168321534noreply@blogger.com0tag:blogger.com,1999:blog-1953712264459944819.post-89016056255272117922012-11-30T04:21:00.000-08:002012-11-30T04:21:35.289-08:00Deal with repetitive work in pstricks efficiently (2) --- multidoLast time we talked about doing repetitive work in postricks using command "\multirput", and this time "\multido" will be introduced. "\multido" is a much more general loop macro than "\multirput". You can use it like this "\multido {\loop_indication = start_value + increment} {loop_nums} {loop_content}", very simillar to loop in programming language. Some examples are shown below.<br />
<br />
<div class="codes">
<pre>\documentclass{article}
\usepackage{multido}
\usepackage{pstricks}
\begin{document}
\begin{pspicture}*(-0.5,0.5)(5.5,5.5)
\multido{\ix=0+1}{6}
{
\multido{\iy=0+1}{6}
{
\rput(\ix,\iy){(\ix,\iy)}
}
}
\end{pspicture}
\end{document}
</pre>
</div>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://1.bp.blogspot.com/-DWkeljdKlLs/ULigp-xsq1I/AAAAAAAAAc4/iLyM0ly8b10/s1600/pstricks_multido_coordinate.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://1.bp.blogspot.com/-DWkeljdKlLs/ULigp-xsq1I/AAAAAAAAAc4/iLyM0ly8b10/s1600/pstricks_multido_coordinate.jpg" height="238" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Fig.1 Deal with repetitive work in efficiently (2) --- multido</td></tr>
</tbody></table>
<br />
Files Download: <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gVnhxbEJfVXVaZkE" target="_blank">tex</a> <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gN0o1MTQ3UFpES2M" target="_blank">ps</a> <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gZlZSQzh4UjVLRkU" target="_blank">pdf</a><br />
<br />
<div class="codes">
<pre>\documentclass{article}
\usepackage{multido}
\usepackage{pstricks}
\begin{document}
\begin{pspicture}(2,2)
\pscircle*[linecolor=yellow](1,1){0.707}
\psset{linecolor=red}
\multido{\ix=0+15}{24}
{
\rput{\ix}(1,1){\psline(0.5,0.5)(1,1)}
}
\end{pspicture}
\end{document}</pre>
</div>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://4.bp.blogspot.com/-0x_UwpHKAKs/ULigp1Ag2wI/AAAAAAAAAc0/zw0_61pzDvg/s1600/pstricks_multido_sun.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://4.bp.blogspot.com/-0x_UwpHKAKs/ULigp1Ag2wI/AAAAAAAAAc0/zw0_61pzDvg/s1600/pstricks_multido_sun.jpg" height="300" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Fig.2 Deal with repetitive work in efficiently (2) --- multido </td></tr>
</tbody></table>
<br />
Files Download: <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gQy01dk5PZ3lPTW8" target="_blank">tex</a> <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gbXJrZFlnTzFnam8" target="_blank">ps</a> <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gT0t6SnR6bWZQcG8" target="_blank">pdf</a>数声风笛离亭晚,我想潇湘君想秦!http://www.blogger.com/profile/08963583502168321534noreply@blogger.com0tag:blogger.com,1999:blog-1953712264459944819.post-59525957797935870862012-10-31T06:13:00.000-07:002012-10-31T06:13:06.376-07:00Deal with repetitive work in pstricks efficiently (1) --- multirputComputer makes the repetitive work simple. And in pstricks command "\multirput" and "\multido" is designed to deal with the repetitive work.<br />
This time we will talk about command "\multirput", and in the next post "\multido" will also be talked.<br />
<br />
"\multirput" as its literal meaning, archive the utility of multi "\rput" commands. The complete form of this command is "\multirput [refpoint] {rotation} (x0,y0) (dx,dy) {nums} {stuff}". The argument "refpoint", "rotation" and "stuff" have the same meaning as the corresponding arguments in command "\rput". (x0,y0) is the starting rput position and (dx,dy) is the increasement, and "nums" is the repetation times. In the following example we use this command to create a simple geometry pattern.<br />
<br />
<div class="codes">
<pre>\documentclass{article}
\usepackage{pst-plot}
\usepackage{pstricks}
\begin{document}
\begin{pspicture}(0,0)(8,5)
%horizontal loop
\multirput[bl](0,0)(1,0){5}
{
%vertical loop
\multirput[bl](0,0)(0.5,0.866){5}
{
\psline(0,0)(1,0)(0.5,0.866)(0,0)
%Draw a equilateral triangle
}
}
\psline(2.5,4.33)(7.5,4.33) %top line
\psline(7.5,4.33)(5,0) %right line
\end{pspicture}
\end{document}
</pre>
</div>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://4.bp.blogspot.com/-lmGVmaK7hkk/UJEjMoVOQ3I/AAAAAAAAAcU/uO6sUZcGcAg/s1600/multirput_pstricks.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://4.bp.blogspot.com/-lmGVmaK7hkk/UJEjMoVOQ3I/AAAAAAAAAcU/uO6sUZcGcAg/s1600/multirput_pstricks.jpg" height="208" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Fig.1 Deal with repetitive work in efficiently (1) --- multirput</td></tr>
</tbody></table>
<br />
Files Download: <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gTk1XbVdWN1RHYjA" target="_blank">tex</a> <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gaGc4Mm1PeG8zNkk" target="_blank">ps</a> <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gZzFQckpvcTUzT0E" target="_blank">pdf</a>数声风笛离亭晚,我想潇湘君想秦!http://www.blogger.com/profile/08963583502168321534noreply@blogger.com0tag:blogger.com,1999:blog-1953712264459944819.post-79280699104889406822012-09-12T23:03:00.000-07:002012-09-12T23:07:48.593-07:00rput --- a most offen used pstricks command"rput" is a most offen used pstricks command. It gives you the ability to place and rotate whatever you want. We have used this command before, and this time we come to examine it carefully.<br />
The common useage of this command is "\rput[refpoint]{rotation}(x,y){stuff}". <br />
"refpoints" determines the reference point of stuff. It take value of the combination of "t,b,B"(for vertical refpoint, means "top","bottom" and "Baseline" respectively) and "l,r"(for horizontal refpoint, means "left" and "right" respectively). <br />
<br />
"rotation" is the angle "stuff" will be rotated. "(x,y)" is the position where "stuff" will be placed. And "stuff" is what you want to place at position (x,y), for example, some words, some pstricks element and so on. Note that the coordinates appear in "stuff" are coordinates relative to (x,y).<br />
<br />
In the following example the usage of this command is shown practically.<br />
<br />
<div class="codes">
<pre>\documentclass{article}
\usepackage{pst-plot}
\usepackage{pstricks}
\begin{document}
\begin{pspicture}(0,0)(5,5)
\psgrid[gridcolor=gray,
subgridcolor=lightgray](0,0)(5,5)
\rput[bl](0,1){bottom left (0,1)}
\rput[tr](5,1){top right (5,1)}
\rput[Bl](0,2){Baseline left (0,2)}
\rput{45}(1,4){rotate $45^{\circ}$}
\rput{45}(3.5,3.5)
{
\psframe[linecolor=red](-1,-1)(1,1)
}
\end{pspicture}
\end{document}
</pre>
</div>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://1.bp.blogspot.com/-Ey1H6MMzLxA/UFF2uFwEKsI/AAAAAAAAAbI/jyZBZ9BSN3o/s1600/rput_pstricks.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="300" src="http://1.bp.blogspot.com/-Ey1H6MMzLxA/UFF2uFwEKsI/AAAAAAAAAbI/jyZBZ9BSN3o/s1600/rput_pstricks.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Fig.1 rput --- a most offen used pstricks command </td></tr>
</tbody></table>
Files Download: <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gQ3cwRC1nVnpGLVk" target="_blank">tex</a> <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gb3A4bVNtdk16ZFE" target="_blank">ps</a> <a href="https://docs.google.com/open?id=0B5wSAiwiTq4geXc4SmduNFJWaEE" target="_blank">pdf</a>数声风笛离亭晚,我想潇湘君想秦!http://www.blogger.com/profile/08963583502168321534noreply@blogger.com1tag:blogger.com,1999:blog-1953712264459944819.post-13495822018958735782012-07-05T01:31:00.000-07:002012-07-05T01:35:58.433-07:00Pie Chart --- Optional arguments of "\psChart"Now we come to examine the optional arguments of command "\psChart". The following table lists the special options belong to "\psChart".<br />
<br />
<table border="1" style="color: #66aaaa;"><tbody>
<tr style="background-color: #0099cc; color: #cccc66; font-weight: bold;"> <td>name</td> <td>description</td> <td>default value</td> </tr>
<tr style="background-color: #ffccaa;"> <td>chartSep</td> <td>distance from the pie chart center to an outraged pie piece</td> <td>10pt</td> </tr>
<tr style="background-color: #ffccaa;"> <td>chartColor</td> <td>gray or color</td> <td>gray</td> </tr>
<tr style="background-color: #ffccaa;"> <td>usercolor</td> <td>a comma separated list of user defined colors for the pie pieces encloed with { }</td> <td>{ } </td> </tr>
<tr style="background-color: #ffccaa;"> <td>chartNodeI</td> <td>the position of the inner node, relative to the radius</td> <td>0.75</td> </tr>
<tr style="background-color: #ffccaa;"> <td>chartNodeO</td> <td>the position of the outer node, relative to the radius</td> <td>1.5</td> </tr>
</tbody> </table><br />
With these arguments we can plot a outstanding pie chart.<br />
<br />
<div class="codes"><pre>\documentclass{article}
\usepackage{pstricks}
\usepackage{pstricks-add}
\usepackage{pst-plot}
\begin{document}
\begin{figure}
\centering
\begin{pspicture}(-5,-5)(8,5)
%Pie chart
\psChart[chartSep=15pt,chartColor=color,
chartNodeO=1.15,shadow=true,
shadowsize=5pt]{15,20,30,20,15}
{3}{4.75}
%The Label for the outraged piece
\ncline[linecolor=-chartFillColor3]
{psChartI3}{psChartO3}
\uput[l](psChartO3){\textcolor{chartFillColor3}
{\large The Most}
}
%The legends
\psframe[fillcolor=chartFillColor1,fillstyle=solid]
(5.25,-5)(6.5,-4.5)
\uput[r](6.5,-4.75){Traffic}
\psframe[fillcolor=chartFillColor2,fillstyle=solid]
(5.25,-4)(6.5,-3.5)
\uput[r](6.5,-3.75){Clothes}
\psframe[fillcolor=chartFillColor3,fillstyle=solid]
(5.25,-3)(6.5,-2.5)
\uput[r](6.5,-2.75){Food}
\psframe[fillcolor=chartFillColor4,fillstyle=solid]
(5.25,-2)(6.5,-1.5)
\uput[r](6.5,-1.75){Rent}
\psframe[fillcolor=chartFillColor5,fillstyle=solid]
(5.25,-1)(6.5,-0.5)
\uput[r](6.5,-0.75){Others}
\end{pspicture}
\end{document}
</pre></div><br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://4.bp.blogspot.com/-hY1M_W3vQhk/T_VN8dvpZdI/AAAAAAAAAZk/TEy076csu1A/s1600/pie_chart_optionalarg.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="200" src="http://4.bp.blogspot.com/-hY1M_W3vQhk/T_VN8dvpZdI/AAAAAAAAAZk/TEy076csu1A/s320/pie_chart_optionalarg.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Fig.1 An advanced practical example of pie chart plotting</td></tr>
</tbody></table><br />
Files downloads: <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gY1J5LWFUcXluc1k" target="_blank">tex</a> <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gRXNpdHhZRUFXRGc" target="_blank">ps</a> <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gNXd5UDBnclViZkU" target="_blank">pdf</a><br />
<br />
<br />数声风笛离亭晚,我想潇湘君想秦!http://www.blogger.com/profile/08963583502168321534noreply@blogger.com0tag:blogger.com,1999:blog-1953712264459944819.post-71714838788842043152012-06-09T00:06:00.000-07:002012-07-05T01:33:20.353-07:00Pie Chart --- three useful nodes defined by command "\psChart"The macro \psChart defines for every value three nodes at the half angle and in distances from chartNodeI (default 0.75), 1 and chartNodeO(default 1.25) times of the radius from the origin (chartNodeI and chartNodeO will be discussed in the next post). The nodes are named as psChartInum, psChartnum and psChartOnum, where num is the number of the pie pieces (num have a value between 1 to the numbers of pie pieces, Letter I stands for Inner and O stands for Outer). These nodes will be very usefull when you add labels to the pie pieces. The following shows these nodes visually.<br />
<br />
<div class="codes">
<pre>\documentclass{article}
\usepackage{pstricks}
\usepackage{pstricks-add}
\usepackage{pst-plot}
\begin{document}
\begin{pspicture}(-5,-5)(5,5)
\psChart{2,2,3,2}{}{3}
\psdot[linecolor=red](psChart2)
\uput[r](psChart2){\textcolor{red}{psChart2}}
\psdot[linecolor=green](psChartI2)
\uput[r](psChartI2){\textcolor{green}{psChartI2}}
\psdot[linecolor=blue](psChartO2)
\uput[r](psChartO2){\textcolor{blue}{psChartO2}}
\psdot[linecolor=red](psChart3)
\uput[r](psChart3){\textcolor{red}{psChart3}}
\psdot[linecolor=green](psChartI3)
\uput[r](psChartI3){\textcolor{green}{psChartI3}}
\psdot[linecolor=blue](psChartO3)
\uput[r](psChartO3){\textcolor{blue}{psChartO3}}
\end{pspicture}
\end{document}
</pre>
</div>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://1.bp.blogspot.com/-yYV2lK36NfE/T9L0_3mMsiI/AAAAAAAAAY0/z6OGNl13qAY/s1600/pie_chart_pschartnode.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="312" src="http://1.bp.blogspot.com/-yYV2lK36NfE/T9L0_3mMsiI/AAAAAAAAAY0/z6OGNl13qAY/s320/pie_chart_pschartnode.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Fig.1 Three useful nodes defined by command \psChart.</td></tr>
</tbody></table>
<br />
Files Downloads: <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gMndtam1KYi1IZWM" target="_blank">tex</a> <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gendVQTdKa0hnWEk" target="_blank">ps</a> <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gY3NhS0VJV2lFcnc" target="_blank">pdf</a><br />
<br />
Now a practical example of plotting a pie chart will be presented.<br />
<br />
<div class="codes">
<pre>\documentclass{article}
\usepackage{pstricks}
\usepackage{pstricks-add}
\usepackage{pst-plot}
\begin{document}
\begin{pspicture}(-5,-5)(5,5)
\psChart{5,4,4,3,3}{}{3}
\rput(psChartI1){\textcolor{red}{5}}
\rput(psChartI2){\textcolor{red}{4}}
\rput(psChartI3){\textcolor{red}{4}}
\rput(psChartI4){\textcolor{red}{3}}
\rput(psChartI5){\textcolor{red}{3}}
\psset{nodesepA=5pt,nodesepB=-10pt}
\rput(psChartO1){{US}}
\rput(psChartO2){{EU}}
\rput(psChartO3){{China}}
\rput(psChartO4){{Japan}}
\rput(psChartO5){{Others}}
\end{pspicture}
\end{document}
</pre>
</div>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://1.bp.blogspot.com/-5LbKIvCFl_U/T9L0_3fLtTI/AAAAAAAAAY4/gQG9LvYjcNY/s1600/pie_chart_pschartnode_practical.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="264" src="http://1.bp.blogspot.com/-5LbKIvCFl_U/T9L0_3fLtTI/AAAAAAAAAY4/gQG9LvYjcNY/s320/pie_chart_pschartnode_practical.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Fig.2 A practical example of pie chart plotting.</td></tr>
</tbody></table>
<br />
In this example, we put the labels using the nodes which have been defined by "\psChart".<br />
<br />
Files Downloads: <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gTVlQcmllRl9FRk0" target="_blank">tex</a> <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gVGZ5UUl1WE50aVE" target="_blank">ps</a> <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gVnB3YjQzUlZCcms" target="_blank">pdf </a>数声风笛离亭晚,我想潇湘君想秦!http://www.blogger.com/profile/08963583502168321534noreply@blogger.com1tag:blogger.com,1999:blog-1953712264459944819.post-65756711114839579672012-06-03T03:31:00.000-07:002012-06-03T03:31:25.750-07:00Pie chart --- the simplest use of command "\psChart"Command "\psChart" in package pstricks-add makes plot a pie chart very simple. The syntax of this command is "\psChart[options]{values1}{values2}{radius}". "values1" is the list of date to be plotted. "vaules2" is a list of outraged pieces. For example, if you want the 1st and 5-th sector to be outraged, you can specify this parameter as "{1,5}". "radius" is the radius of the pie chart. The color used to paint the num-th pie piece is named internally as "chartFillColornum". <br />
<br />
Now let us have a try of this command.<br />
<br />
<div class="codes">
<pre> \begin{pspicture}(-5,-5)(8,5)
%Pie chart
\psChart{1,2,2,3,1,4}{1,5}{4.75}
%The legends
\psframe[fillcolor=chartFillColor1,
fillstyle=solid](5.25,-5)(6.5,-4.5)
\uput[r](6.5,-4.75){Pie 1}
\psframe[fillcolor=chartFillColor2,
fillstyle=solid](5.25,-4)(6.5,-3.5)
\uput[r](6.5,-3.75){Pie 2}
\psframe[fillcolor=chartFillColor3,
fillstyle=solid](5.25,-3)(6.5,-2.5)
\uput[r](6.5,-2.75){Pie 3}
\psframe[fillcolor=chartFillColor4,
fillstyle=solid](5.25,-2)(6.5,-1.5)
\uput[r](6.5,-1.75){Pie 4}
\psframe[fillcolor=chartFillColor5,
fillstyle=solid](5.25,-1)(6.5,-0.5)
\uput[r](6.5,-0.75){Pie 5}
\psframe[fillcolor=chartFillColor6,
fillstyle=solid](5.25,0)(6.5,0.5)
\uput[r](6.5,0.25){Pie 6}
\end{pspicture}
</pre>
</div>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZ3DkvlYlWk-hNVYIPyQ7w2ExZjebYNnfkTfhoDmvqDDV-KyFQc8p158TpMJYZEZcmTfHV7dBKjYC2Uu2hnTKt2uN29h02gm-iDIbVJ0NrcLtkX4j-i7gVozjR6zY5iogAKtfkZB9kDuYD/s1600/pie_chart_pstricks.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="246" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZ3DkvlYlWk-hNVYIPyQ7w2ExZjebYNnfkTfhoDmvqDDV-KyFQc8p158TpMJYZEZcmTfHV7dBKjYC2Uu2hnTKt2uN29h02gm-iDIbVJ0NrcLtkX4j-i7gVozjR6zY5iogAKtfkZB9kDuYD/s320/pie_chart_pstricks.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Fig.1 Pie chart plots in Pstricks</td></tr>
</tbody></table>
<br />
In the upper example, we see that a pie chart with radius "5" is plotted accroding to data "{1,2,2,3,1,4}", and the 1-st and 5-th pie pieces is outraged. This is exactly what we expected. And with the help of variable "chartFillColornum" we produced the legends.<br />
<br />
Files Downloads: <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gSTBWMWRlQkV3R1U" target="_blank">tex</a> <a href="https://docs.google.com/open?id=0B5wSAiwiTq4ga2hWcFhReG5yOFU" target="_blank">ps</a> <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gUlZFeWdnTXRhVk0" target="_blank">pdf </a>数声风笛离亭晚,我想潇湘君想秦!http://www.blogger.com/profile/08963583502168321534noreply@blogger.com0tag:blogger.com,1999:blog-1953712264459944819.post-67176228330945460132012-05-22T19:31:00.000-07:002012-05-22T19:42:05.086-07:00Bar plotsIn package pstricks-add (Maybe in a new version of pstrick this plotstyle have been moved to package pstrick) there is a new plotstyle named bar defined. Use this plotstyle a bar chart can be plotted easily. The parameters closely related to this plotstyle includes "barwidth","fillstyle" and so on. The usage of this plotstyle is very simple. Let us learn it by an example.<br />
<br />
<div class="codes">
<pre>\documentclass{article}
\usepackage{pstricks}
\usepackage{pstricks-add}
\usepackage{pst-plot}
\begin{document}
\begin{psgraph}(-1,0)(6,5){5cm}{5cm}
\savedata{\mydata}[{0,1},{1,3},
{2,2}{3,4},{4,1},{5,2}]
\dataplot[linecolor=blue,plotstyle=bar,
barwidth=0.5cm,fillcolor=red,
fillstyle= solid]{\mydata}
\end{psgraph}
\end{document}
</pre>
</div>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://1.bp.blogspot.com/-zJSY6ymXKss/T7xLP6WZkMI/AAAAAAAAAYE/HnhH3ZUT-gY/s1600/barplot_pstricks.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="309" src="http://1.bp.blogspot.com/-zJSY6ymXKss/T7xLP6WZkMI/AAAAAAAAAYE/HnhH3ZUT-gY/s320/barplot_pstricks.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Fig.1 Bar plot using pstricks </td></tr>
</tbody></table>
Files Download: <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gU2JocUtrSDhaRXM" target="_blank">tex</a> <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gUHpubHVFeXc3S28" target="_blank">ps</a> <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gVXVFa0RmQXZKQmM" target="_blank">pdf</a>数声风笛离亭晚,我想潇湘君想秦!http://www.blogger.com/profile/08963583502168321534noreply@blogger.com0tag:blogger.com,1999:blog-1953712264459944819.post-7213266607764156922012-04-08T05:16:00.000-07:002012-04-08T05:19:39.753-07:00Parametric plotsBesides the usual Cartesian coordinate plots and polar plots, Pstricks also can realize parametric plots. The command is "\psparametricplot[options]{t0}{t1}{x(t) y(t)}". "t0" and "t1" are the begin and end value of variable t. "x(t)" and "y(t)" are interpreted as the parametric plot functions.<br />
<br />
Now we come to practice on this command.<br />
<br />
<div class="codes">
<pre>\documentclass{article}
\usepackage{pstricks}
\usepackage{pstricks-add}
\usepackage{pst-plot}
\psset{unit=3cm}
\begin{document}
\psset{plotpoints=500}
\begin{psgraph}(-1,-1)(1,1){5cm}{5cm}
\psparametricplot{0}{360}
{2 t mul sin 3 t mul cos}
%sin(2t),cos(3t)
\end{psgraph}
\end{document}
</pre>
</div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://1.bp.blogspot.com/-QsFFcQqhFvY/T4GAhGjFkdI/AAAAAAAAAWE/R4yCMhlr6As/s1600/parametricplot_pstricks.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="320" src="http://1.bp.blogspot.com/-QsFFcQqhFvY/T4GAhGjFkdI/AAAAAAAAAWE/R4yCMhlr6As/s320/parametricplot_pstricks.jpg" width="319" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Fig.1 parametric plots in pstricks</td></tr>
</tbody></table>
<br />
Files Download: <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gNU40b2ZpbnNSei1tbzRHY1hFaHN6dw" target="_blank">tex</a> <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gcmxpTHlLZkxUbU81bERxM1VzZHpNdw" target="_blank">ps</a> <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gUy1TWjdyTDZRaHkwRV9UNWlvMFpDUQ" target="_blank">pdf</a>数声风笛离亭晚,我想潇湘君想秦!http://www.blogger.com/profile/08963583502168321534noreply@blogger.com0tag:blogger.com,1999:blog-1953712264459944819.post-35610861803343132022012-03-27T23:27:00.000-07:002012-04-01T22:35:07.971-07:00Plot in polar coordinate --- polarplotWith the option "polarplot=true", it is possible to use command "\psplot" to create a polar plot. The syntax is the same as usual --- "\psplot[polarplot=true,...]{x0}{x1}{function}" where "x0" and "x1" are the start and end angle. "function" is interpreted as a function r=f(theta) in the polar plotting. So if a circle with radius 1 is to be plotted, command "\psplot[polarplot=true]{0}{360}{1}" can be used. <br />
Now we come to draw a cardioid. The function of a cardioid in polar coordinate reads "r=a(1+sin(x))". And we take a=1.5.<br />
<br />
<div class="codes"><pre>\documentclass{article}
\usepackage{pstricks}
\usepackage{pstricks-add}
\usepackage{pst-plot}
\begin{document}
\psset{plotpoints=500}
\begin{psgraph}{->}(0,0)(-0.5,-2)(3.5,2.5){5cm}{5cm}
\psplot[polarplot=true]{0}{360}
{x cos 1 add 1.5 mul}
\end{psgraph}
\end{document}
</pre></div><br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://4.bp.blogspot.com/-tbsRBNJGBkA/T3Ktx-A31rI/AAAAAAAAAVA/Yruvbj3ca7c/s1600/polarplot_cardioid.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="310" src="http://4.bp.blogspot.com/-tbsRBNJGBkA/T3Ktx-A31rI/AAAAAAAAAVA/Yruvbj3ca7c/s320/polarplot_cardioid.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Fig.1 Plot in polar coordinate --- cardioid.</td></tr>
</tbody></table><br />
The axesstyle can also be set to polar. The only thing need to do is setting "axesstyle=polar". This time we use a three-leaved rose curve (r=a*sin(3x),a=3.5) to shown it.<br />
<br />
<div class="codes"><pre>\documentclass{article}
\usepackage{pstricks}
\usepackage{pstricks-add}
\usepackage{pst-plot}
\begin{document}
\psset{plotpoints=500}
\begin{pspicture}(-4,-4)(4,4)
\psaxes[axesstyle=polar,xAxisLabel=some,
subticks=2,tickcolor=red,tickwidth=1pt,
subtickcolor=green]{->}(0,0)(-4,4)(4,4)
\psplot[polarplot=true,linewidth=2pt,
linecolor=blue]{0}{360}
{3 x mul sin 3.5 mul}
\end{pspicture}
\end{document}</pre></div><br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://2.bp.blogspot.com/-b_NL2eyOGqs/T3Ku5D8A7HI/AAAAAAAAAVQ/6n5MGma0RSo/s1600/polarplot_three_leaved_rose_curve.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="278" src="http://2.bp.blogspot.com/-b_NL2eyOGqs/T3Ku5D8A7HI/AAAAAAAAAVQ/6n5MGma0RSo/s320/polarplot_three_leaved_rose_curve.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Fig.2 Plot in polar coordinate — three leaved rose curve. </td></tr>
</tbody></table><pre> </pre><pre>Files Download: <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gNkJEeG5hb0pTc1dSOFpmTDNvUHhNQQ" target="_blank">tex</a> <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gWUpNck5xOEFRSUtJeWlfS1ZXRG8wdw" target="_blank">ps</a> <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gZHpTcWNNN1JRYWVod0hjcjF5NkRrdw" target="_blank">pdf</a> </pre><br />数声风笛离亭晚,我想潇湘君想秦!http://www.blogger.com/profile/08963583502168321534noreply@blogger.com2tag:blogger.com,1999:blog-1953712264459944819.post-36366231193366365342012-02-26T03:46:00.000-08:002012-02-26T03:55:39.304-08:00Pstricks defined plotting suitable environment --- psgraphExcept allocating spaces for the pstricks elements just as what pspicture does, this new environment also does the scaling and draws the axes. It means that the axes drawing and transformation from physical coordinate to mathematical coordinate will be done automatically. The syntax is:<br />
<br />
<div class="codes">
<pre>\begin{psgraph}[options]{arrowstyle}%
(xorigin,yorigin)(xmin,ymin)(xmax,ymax){width}{height}
...
\end{psgraph}
</pre>
</div>
<br />
where the options are similar to those of "\psaxes" macro. "arrowstyle" controls the arrwostyle of axes. "(xorigin,yorigin)", "(xmin,ymin)" and "(xmax,ymax)" define the coordinate system. "width" and "height" determine the physical width and height of the graph. Now we show the advantage of this new environment by the following example.<br />
<br />
<div class="codes">
<pre>\documentclass{article}
\usepackage{pstricks}
\usepackage{pstricks-add}
\usepackage{pst-plot}
\begin{document}
\psset{
axesstyle=frame,ysubticks=2,
xsubticks=4,subticksize=0.5,
subtickcolor=black,xAxisLabel=Time(s),
xAxisLabelPos={c,-1cm},
yAxisLabel=Voltage(mV),
yAxisLabelPos={-1cm,c}
}
\begin{psgraph}[Dx=2,Dy=10,Ox=-2,Oy=-10]
{->}(-2,-10)(6,75){8cm}{5cm}
\psplot[linecolor=red]{-2}{6}{2 x exp}
\psplot[plotpoints=500,linecolor=blue]
{-2}{6}{2 x exp 500 x mul sin add}
\rput(-1.5,65){\psline[linecolor=red]
(0,0)(0.75cm,0)}
\rput[l](-0.5,65){Original Theory}
\rput(-1.5,55){\psline[linecolor=blue]
(0,0)(0.75cm,0)}
\rput[l](-0.5,55){Improved Theory}
\end{psgraph}
\end{document}
</pre>
</div>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://1.bp.blogspot.com/-xvDDe--49SY/T0oakwQpO1I/AAAAAAAAAUU/quFuKvUjQoY/s1600/psgraph_pstricks.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="205" src="http://1.bp.blogspot.com/-xvDDe--49SY/T0oakwQpO1I/AAAAAAAAAUU/quFuKvUjQoY/s320/psgraph_pstricks.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Fig.1 Pstricks defined plotting suitable environment --- psgraph</td></tr>
</tbody></table>
<br />
Isn't it more convinient than pspicture?<br />
<br />
Downloads: <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gbVJ5TTZ3V21RUVdralB4cmx1anpkQQ" target="_blank">tex</a> <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gYU12V2lWeWJSMW1vT0FHUjlYMGhfUQ" target="_blank">ps</a> <a href="https://docs.google.com/open?id=0B5wSAiwiTq4ganYyQ3daMVFSeG1MWm5LYVpnYlBKdw" target="_blank">pdf </a><br />
<br />数声风笛离亭晚,我想潇湘君想秦!http://www.blogger.com/profile/08963583502168321534noreply@blogger.com0tag:blogger.com,1999:blog-1953712264459944819.post-55156223721521907422012-02-04T02:12:00.000-08:002012-02-04T02:12:20.509-08:00More options on pstricks plotting (2)When a Logarithmic scale graph is plot, "x(y)logBase=num|empty", and "logLines=none|x|y|all" are useful. The first one controls the logBse of corresponding axes. The later one controls the log grid line.<br />
<br />
Let us plot a logarithmic scale graph to shown how these options are used.<br />
<br />
<div class="codes">
<pre>\documentclass{article}
\usepackage{pstricks}
\usepackage{pstricks-add}
\usepackage{pst-plot}
\begin{document}
\begin{pspicture}(0,0)(6,5)
\psaxes[axesstyle=frame,ylogBase=10,
subticks=5,logLines=y](0,0)(6,5)
\psplot[linecolor=red]{0}{5}{x}
\psplot[linecolor=blue,linestyle=dotted,
linewidth=1.5pt,dotsep=1pt]
{0}{6}{0.5 x mul}
\psplot[linecolor=green,linestyle=dashed]
{1}{6}{x log 4 mul}
\rput(3.5,4.25){\color{red}$y=10^{x}$}
\rput(3,2.25){\color{green}$y=x^{4}$}
\rput(3.5,1.25){\color{blue}$y=10^{x/2}$}
\rput(3,-0.75){$x$}
\rput(-1,2.5){$y$}
\end{pspicture}
\end{document}
</pre>
</div>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://2.bp.blogspot.com/-lnFI_ChSsok/Ty0CKF2G19I/AAAAAAAAASQ/DCpaoWqzvRI/s1600/logplot_pstricks.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="255" src="http://2.bp.blogspot.com/-lnFI_ChSsok/Ty0CKF2G19I/AAAAAAAAASQ/DCpaoWqzvRI/s320/logplot_pstricks.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Fig.1 Plotting Logarithmic scale graph using Pstricks.</td></tr>
</tbody></table>
<br />
Options "nStep, nStart, nEnd, xStep, XStart, xEnd, yStart, yEnd" controls the plot range.<br />
<br />
By default the plot macros expect x|y data records, but when data files contains more than one y value, like:<br />
<div class="codes">
<pre>x y1 y2 ... yMax
x y1 y2 ... yMax
...
</pre>
</div>
one can select the column to be plotted using "plotNo" and "PlotNoMax". "plotNo=num" tells pst-plot to plot the num-th y-column. "plotNoMax" tells pst-plot how many y-column are present.<br />
<br />
Files: <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gZWQ5MzFjM2EtYWE2OC00NDRjLTg2MTUtZWU2YzQ3NDc5ZWJl" target="_blank">tex</a> <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gODBiNDhiZGItMjhhNy00OTUyLTgwYTctM2FjN2U3YjdmNjE1" target="_blank">ps</a> <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gZGIyYzllM2ItMmQzNy00NzI4LWFlMGMtMGNhMDQzMzgxYjUx" target="_blank">pdf</a><br />
<br />数声风笛离亭晚,我想潇湘君想秦!http://www.blogger.com/profile/08963583502168321534noreply@blogger.com0tag:blogger.com,1999:blog-1953712264459944819.post-79606707115731150312012-01-06T03:58:00.000-08:002012-02-04T01:45:35.251-08:00More options on pstricks plotting (1)In package pst-plot there are only some basic options for a plot. To control the appearance of a plot more finely a new package called pstricks-add should be used.(In the new version of pst-plot, the options are greatly flourished, and you may also find these options in pst-plot.) In this package a great amount of new options have been introduced. In this posts only some of them will be covered, and to get a whole list of these options you may refer to the official document.<br />
<br />
We know that by default the function of "\psplot" should be written in postscript code. And it is hard for a fresh man to understand the meaning of a long line postscript mathematical expression. With package "pstricks-add", you may get rid of the unfriendly postscript codes. Setting "algebraic=true", common algebraic notations can be used. For example you instead of using "x cos x 2 exp mul", you can write it "cos(x)*x^2".<br />
<br />
To change the font size of the labels "labelFontSize" may be used. You can set "labelFontSize = \footnotesize", so that the font size of the labels will be smaller.<br />
<br />
There are some options used to control the ticks and subticks. "subticks=num" set num subtics between two main ticks. "(x)(y)(sub)ticklinestyle", "(x)(y)(sub)tickcolor", "(x)(y)(sub)tickwidth", and "(x)(y)(sub)ticksize" control the linestyle, color, width and size of corresponding ticks.<br />
<br />
There is an example on these options.<br />
<br />
<div class="codes">
<pre>\documentclass{article}
\usepackage{pstricks}
\usepackage{pst-plot}
\usepackage{pstricks-add}
\begin{document}
\psset{yunit=0.2cm,xunit=0.5cm}
\begin{pspicture}(-5,0)(5,25)
\psaxes[linecolor=blue,axesstyle=frame,
tickstyle=bottom,Dx=2,Dy=5,
xsubticks=4,ysubticks=5,
tickcolor=blue,subtickcolor=cyan,
subticksize=0.5,ticksize=2mm,
tickwidth=1.5pt,subtickwidth=0.75pt,
](-5,0)(5,25)
\psset{algebraic=true}
\psplot[linecolor=red]{-5}{5}{0.9*x^2}
\end{pspicture}
\end{document}
</pre>
</div>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://3.bp.blogspot.com/-wh8Jq8GYDWI/TwbiRRhQJTI/AAAAAAAAARs/iRjNVKCt0Sg/s1600/more_options_on_pstricks_plotting_pstricks.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="290" src="http://3.bp.blogspot.com/-wh8Jq8GYDWI/TwbiRRhQJTI/AAAAAAAAARs/iRjNVKCt0Sg/s320/more_options_on_pstricks_plotting_pstricks.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Fig.1 More options on Pstricks plotting </td></tr>
</tbody></table>
Files Download: <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gYjgwNmQxM2ItY2RjNS00Mzk2LTg3NTYtNmU5ODM4ODFhNTYz" target="_blank">tex</a> <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gYTVkZjAzZDgtMmQ4ZS00NGM5LThlNTMtODhkZDU1MWY2YWQ3" target="_blank">ps</a> <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gMWY2NDQwY2QtZjYwOC00MWQ3LTk4ZDYtMDVmYzY0Y2NlY2E5" target="_blank">pdf</a>数声风笛离亭晚,我想潇湘君想秦!http://www.blogger.com/profile/08963583502168321534noreply@blogger.com0tag:blogger.com,1999:blog-1953712264459944819.post-47611294863327896852011-12-28T04:13:00.000-08:002011-12-28T04:13:40.406-08:00How to plot using pstricks(3) --- plot a data fileThe second data plotting command is "\dataplot[parameters]{command}". <br />
<br />
Before you use "\dataplot", you have to read the data in using either command "\savedata {command} [data]" or "\readdata {command} [datafile]". At this time someone may ask "dataplot have to take two steps to finish the thing which fileplot takes only one step. Is there the necessity of its existance?" The answer is "yes". Because if you reuse the data, the combination of "\readdata" and "\dataplot" is much faster as the data file is read only one time.<br />
<br />
<br />
Now let us come to an example of "\dataplot".<br />
<br />
<div class="codes"><pre>\documentclass{article}
\usepackage{pstricks}
\usepackage{pst-plot}
\begin{document}
\psset{xunit=2cm,yunit=1.5cm}
\begin{pspicture}(-1.25,-1)(3.25,1.25)
\savedata{\mydatasinexp}%
[{0.,0.},{0.05,0.456044},{0.1,0.761394},
{0.15,0.858552},{0.2,0.74447},{0.25,0.466091},
{0.3,0.104544},{0.35,-0.247193},{0.4,-0.5073},
{0.45,-0.623301},{0.5,-0.581617},{0.55,-0.407061},
{0.6,-0.153346},{0.65,0.112302},{0.7,0.32625},
{0.75,0.44308},{0.8,0.444547},{0.85,0.341285},
{0.9,0.167555},{0.95,-0.029064},{1.,-0.200134},
{1.05,-0.307839},{1.1,-0.332868},{1.15,-0.2772},
{1.2,-0.161613},{1.25,-0.0190015},{1.3,0.114509},
{1.35,0.208373},{1.4,0.244281},{1.45,0.219299},
{1.5,0.145099},{1.55,0.0438223},{1.6,-0.0581267},
{1.65,-0.136698},{1.7,-0.175631},{1.75,-0.169538},
{1.8,-0.124137},{1.85,-0.0538507},{1.9,0.0224169},
{1.95,0.0861526},{2.,0.123554},{2.05,0.128327},
{2.1,0.102454},{2.15,0.0549385},{2.2,-0.000980753},
{2.25,-0.0513478},{2.3,-0.0848411},
{2.35,-0.0951862},{2.4,-0.0821522},{2.45,-0.0510304},
{2.5,-0.0108641},{2.55,0.0280359},{2.6,0.0566379},
{2.65,0.0691928},{2.7,0.0642737},{2.75,0.0447009},
{2.8,0.0164738},{2.85,-0.012943},{2.9,-0.0365153},
{2.95,-0.0492533},{3.,-0.0491912},{3.05,-0.0375617},
{3.1,-0.0182016}]
\readdata{\mydataexp}{dataexp.dat}
\psaxes{->}(0,0)(0,-1)(3.25,1.25)
\dataplot[plotstyle=curve,linecolor=red]
{\mydatasinexp}
\dataplot[plotstyle=dots,linecolor=blue,
dotsize=2.5pt]{\mydatasinexp}
\dataplot[plotstyle=curve,linecolor=cyan]
{\mydataexp}
\end{pspicture}
\end{document}
</pre></div><br />
And data file "mydataexp.dat" contains the following datas:<br />
<br />
<div class="codes"><pre>[{0.,1.},{0.05,0.951229},{0.1,0.904837},
{0.15,0.860708},{0.2,0.818731},{0.25,0.778801},
{0.3,0.740818},{0.35,0.704688},{0.4,0.67032},
{0.45,0.637628},{0.5,0.606531},{0.55,0.57695},
{0.6,0.548812},{0.65,0.522046},{0.7,0.496585},
{0.75,0.472367},{0.8,0.449329},{0.85,0.427415},
{0.9,0.40657},{0.95,0.386741},{1.,0.367879},
{1.05,0.349938},{1.1,0.332871},{1.15,0.316637},
{1.2,0.301194},{1.25,0.286505},{1.3,0.272532},
{1.35,0.25924},{1.4,0.246597},{1.45,0.23457},
{1.5,0.22313},{1.55,0.212248},{1.6,0.201897},
{1.65,0.19205},{1.7,0.182684},{1.75,0.173774},
{1.8,0.165299},{1.85,0.157237},{1.9,0.149569},
{1.95,0.142274},{2.,0.135335},{2.05,0.128735},
{2.1,0.122456},{2.15,0.116484},{2.2,0.110803},
{2.25,0.105399},{2.3,0.100259},{2.35,0.0953692},
{2.4,0.090718},{2.45,0.0862936},{2.5,0.082085},
{2.55,0.0780817},{2.6,0.0742736},{2.65,0.0706512},
{2.7,0.0672055},{2.75,0.0639279},{2.8,0.0608101},
{2.85,0.0578443},{2.9,0.0550232},{2.95,0.0523397},
{3.,0.0497871},{3.05,0.0473589},{3.1,0.0450492}]
</pre></div><br />
The plotted picture looks like this one:<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://1.bp.blogspot.com/-vxmf8BE-vvg/TvsF_Q6rpbI/AAAAAAAAARg/4xvYomfXmog/s1600/psplot3_pstricks.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="178" src="http://1.bp.blogspot.com/-vxmf8BE-vvg/TvsF_Q6rpbI/AAAAAAAAARg/4xvYomfXmog/s320/psplot3_pstricks.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Fig.1 An example of dataplot</td><td class="tr-caption" style="text-align: center;"><br />
</td><td class="tr-caption" style="text-align: center;"><br />
</td><td class="tr-caption" style="text-align: center;"><br />
</td></tr>
</tbody></table><br />
The last data plotting command is "\listplot[parameters]{list}". And it has a similar usage as "dataplot", so no example of this command is provided. When using this command data can only delimited by white space.<br />
<br />
Files download: <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gOTNmOTYxODktODEwZC00N2NjLTgyZDYtNmQwZjIxN2EzZmU5" target="_blank">tex</a> <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gNjBiYmU4YmMtMjBlNi00MzU1LTk5ZWQtYjNiN2E1NzA5OTQ0" target="_blank">ps</a> <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gYjYwZDY1MTctYWU3NS00NmEyLWE1NjAtNjVlNThjZDY2YWRl" target="_blank">pdf</a>数声风笛离亭晚,我想潇湘君想秦!http://www.blogger.com/profile/08963583502168321534noreply@blogger.com0tag:blogger.com,1999:blog-1953712264459944819.post-48868478880425881942011-12-20T03:49:00.000-08:002011-12-20T03:49:40.282-08:00How to plot using pstricks(2) --- plot a data fileFunction plotting have been talked last time, and today data file plotting will be introduced. <br />
<br />
There are three fundamental data file plotting commands in pstricks, and we will show them one by one.<br />
<br />
The first one is "\fileplot[parameters]{datafile}". The datafile should contain a list of coordinates. And the data can be delimited by "{}", "()", "," and one or more white space. If something is following "%", it will be interpreted as comments and will be omitted. It is advised to bracket all the data with "[]", this will significantly speed up the rate at which the data is read. So files like the following ones are all legal.<br />
<br />
<div class="codes">
<pre>%mydata
[(0,0),(1,1),(2,2),(3,3),(4,4)] %mydata
</pre>
</div>
<br />
<div class="codes">
<pre>[{0,0},{1,1},{2,2},{3,3},{4,4}]
</pre>
</div>
<br />
<div class="codes">
<pre>[{0 0} {1 1} {2 2} {3 3} {4 4}]
</pre>
</div>
<br />
<div class="codes">
<pre>[0 0 1 1 2 2 3 3 4 4]
</pre>
</div>
<br />
Now a simple practice on this command will be shown.<br />
<br />
<div class="codes">
<pre>\documentclass{article}
\usepackage{pst-plot}
\usepackage{pstricks}
\begin{document}
\begin{pspicture}(-1,-1)(5.5,5.5)
\psgrid[gridcolor=red,subgridcolor=green,
gridlabels=0](0,0)(5,5)
\psaxes{->}(0,0)(5.5,5.5)
\fileplot[linecolor=blue,plotstyle=dots,
dotstyle=*,dotsize=5pt]{mydata.dat}
\end{pspicture}
\end{document}
</pre>
</div>
<br />
File mydata.dat is shown below:<br />
<br />
<div class="codes">
<pre>[{0.,0.},{0.25,1.},{0.5,1.41421},{0.75,1.73205},
{1.,2.},{1.25,2.23607},{1.5,2.44949},{1.75,2.64575},
{2.,2.82843},{2.25,3.},{2.5,3.16228},{2.75,3.31662},
{3.,3.4641},{3.25,3.60555},{3.5,3.74166},
{3.75,3.87298},{4.,4.},{4.25,4.12311},{4.5,4.24264},
{4.75,4.3589},{5.,4.47214}]
</pre>
</div>
<br />
And the output picutre looks like this:<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://3.bp.blogspot.com/-L1ZzRsVnJsk/TvB0vNp9mjI/AAAAAAAAARU/HS7l95DOZSM/s1600/fileplot_pstricks.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="305" src="http://3.bp.blogspot.com/-L1ZzRsVnJsk/TvB0vNp9mjI/AAAAAAAAARU/HS7l95DOZSM/s320/fileplot_pstricks.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Fig.1 Plot data file with command fileplot.</td></tr>
</tbody></table>
<br />
Files Download: <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gZTI1MTNhNTUtYTRjZi00OWZhLWJlYjItMTYzYWIyNTA1NDFj" target="_blank">tex</a> <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gZmEwYTA1YWMtYjliNi00MTJiLTkyZmItNjk1YTU0MGM1NTg0" target="_blank">ps</a> <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gZGZjODk0NGQtYmRhMC00YTFmLWE2YjctZDdhYjkzNTczYmIz" target="_blank">pdf</a><br />
<br />
Other file plot commands will be talked next time.<br />
<br />数声风笛离亭晚,我想潇湘君想秦!http://www.blogger.com/profile/08963583502168321534noreply@blogger.com1tag:blogger.com,1999:blog-1953712264459944819.post-83611376644860038232011-12-13T00:12:00.000-08:002011-12-13T00:27:46.574-08:00How to plot using pstricks(1)----plot a functionAfter the previous posts, now we have the ability to deal with the plotting problems using pstricks. And this time we will talk about how to plot a function using pstricks.<br />
<br />
The command used to plot a function in pstricks is "\psplot{xmin}{xmax}{function}". "xmin" and "xmax" determine the plot range and "function" is the function to be plotted. "function" should be written in postscript code. Since this blog is not about postscript, how to write a function in postscript code will not be talked in detail, only when it is used some simple explanation will be given.<br />
<br />
There are also some optional parameters to control the appearance of the plot. "plotstyle=line,polygon,dots,curve..." controls the plotstyle, "plotpoints=int" controls how many points be plotted and other parameters such as "showpoints", "linestyle", "linecolor", "dotstyle"... have the same meaning as we have talked before.<br />
<br />
Now we come to some examples.<br />
<br />
<div class="codes">
<pre>\documentclass{article}
\usepackage{pst-plot}
\usepackage{pstricks}
\begin{document}
\begin{pspicture}*(-1,-1)(5.5,5.5)
\psgrid[gridlabels=0,gridcolor=gray,
subgridcolor=lightgray](0,0)(5,5)
\psaxes{->}(0,0)(0,0)(5.5,5.5)
\psplot[linecolor=blue,plotstyle=dots,
plotpoints=15,dotstyle=x,dotsize=4pt]
{0}{5}{x}
\rput{45}(2.5,3){\color{blue}$y=x$}
\psplot[linecolor=red,plotstyle=dots,
plotpoints=15,dotstyle=+,dotsize=4pt]
{0}{5}{x 2 exp 5 div} %(x^2)/5
\psplot[linecolor=red,plotstyle=line]
{0}{5}{x 2 exp 5 div} %(x^2)/5
\rput{55}(4,2.25)
{\color{red}$y=\frac{x^{2}}{5}$}
\rput(0.25,5.25){$y$}
\rput(5.25,0.25){$x$}
\end{pspicture}
\end{document}
</pre>
</div>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://1.bp.blogspot.com/-3smAkZ7dEko/TucKGy-zE-I/AAAAAAAAAPU/wUROfwMmqtY/s1600/psplot1_pstricks.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="296" src="http://1.bp.blogspot.com/-3smAkZ7dEko/TucKGy-zE-I/AAAAAAAAAPU/wUROfwMmqtY/s320/psplot1_pstricks.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">2<br />
Fig.1 An example of Psplot—Plot function y = x and y = x /5.</td></tr>
</tbody></table>
<br />
<div class="codes">
<pre>\documentclass{article}
\usepackage{pst-plot}
\usepackage{pstricks}
\begin{document}
\begin{pspicture}*(-1.25,-1.25)(4.5,1.25)
\psgrid[gridlabels=0,gridcolor=red,
subgridcolor=green](0,-1)(4,1)
\psaxes[labels=y,tickstyle=bottom]
{->}(0,0)(0,-1.25)(4.5,1.25)
\rput(0.25,1){$y$}
\rput(4.25,0.25){$x$}
\psset{xunit=0.0111cm} %xuni=4cm/360
\psplot[plotstyle=curve,
linecolor=blue]{0}{360}{x sin}
%"x sin" is postscript code
%with meaing sin(x)
\psplot[plotstyle=curve,linecolor=brown,
linestyle=dashed]{0}{360}{x cos}
%"x cos" is postscript code
%with meaing cos(x)
\uput[-90](90,0){$\frac{\pi}{2}$}
\uput[-90](180,0){\scriptsize $\pi$}
\uput[-90](270,0){$\frac{3\pi}{2}$}
\uput[-90](360,0){\scriptsize $2\pi$}
\end{pspicture}
\end{document}
</pre>
</div>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://3.bp.blogspot.com/-PhNkVV2rIXA/TucKGCBzZeI/AAAAAAAAAPM/SxV-AnMWVlU/s1600/psplot2_pstricks.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="166" src="http://3.bp.blogspot.com/-PhNkVV2rIXA/TucKGCBzZeI/AAAAAAAAAPM/SxV-AnMWVlU/s320/psplot2_pstricks.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Fig.2 Another example of Psplot—Plot function y = sin(x) and y =<br />cos(x).</td></tr>
</tbody></table>
<br />
Files Dowload: <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gMTk2ZDQ0ZGMtOTk3ZC00YzhiLTkzMjQtYzc2M2FiNDNkM2Uz" target="_blank">tex</a> <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gMWU3NjE2NjQtYmE2Yi00YjA0LWIzYjktYmYzN2E3MjRiNDBi" target="_blank">ps</a> <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gY2QxMzUzMTctOWRhZS00OTc1LWIwMTYtNzYyNDFhZTMwNjRh" target="_blank">pdf</a>数声风笛离亭晚,我想潇湘君想秦!http://www.blogger.com/profile/08963583502168321534noreply@blogger.com1tag:blogger.com,1999:blog-1953712264459944819.post-4959692439615513292011-12-11T03:16:00.001-08:002011-12-11T03:53:39.872-08:00Axes of coordinatesThis posts will talk about making axes. Axes is an essential part in a plotting. And after this posts, I think we have gained enough knowledge to take over the subject of plotting. So in the next posts plotting will be talked about.<br />
<br />
The command for drawing axes in pstricks is "\psaxes(x0,y0)(x1,y1)(x2,y2)" in package "pst-plot" (so do remember to include this package). (x0,y0) is the position of the origin. (x1,y1) is the lower left corner of the coordinate and (x2,y2) is the upper right corner. If (x0,y0) is not specified, (x1,y1) will be used. And if both (x0,y0) and (x1,y1) is not specified, then the origin of the current coordinate will be used. It is to say that "\psaxes(x1,y1)(x2,y2)" is equivalent to "\psaxes(x1,y1)(x1,y1)(x2,y2)" and "\psaxes(x2,y2)" is equivalent to "\psaxes(0,0)(0,0)(x2,y2)". Isn't it very similar to the command "\psgrid"?<br />
<br />
As axes is in fact a line, the command "\psaxes" can take almost all the parameters a line can take. And there are also some parameters specially for it.<br />
<br />
"Ox(y)=num" is the label at origin with default value 0. "Dx(y)=num" is the label increment with default value 1. "dx(y)=num" is the distance between labels. If it takes value 0, Dx*\psunit will be used, and the default value is 0. "labels/ticks=all/x/y/none" controls which labels/ticks will appear. "showorigin=true/false" controls whether the origin label will be drawn. "tickstyle" can take values "full","top" and "bottom". If "top" is chosen, the ticks are only on the side of the axes away from the label. "Bottom" is just the opposite. And "full" gives ticks on both sides of the axes. The size of the ticks can be set using parameter "ticksize". Another mostly used parameter is "axesstyle", its legal values include "axes","frame" and "none".<br />
<br />
In the following example the using of "\psaxes" is illustrated.<br />
<br />
<div class="codes"><pre>\documentclass{article}
\usepackage{pst-plot}
\usepackage{pstricks}
\begin{document}
\begin{pspicture}(5,5)
\psaxes[axesstyle=frame,Ox=0,Oy=100](4,4)
\end{pspicture}
\hspace{1.5cm}
\begin{pspicture}(5,5)
\psframe[linecolor=lightgray](0,0)(5,5)
\psaxes[Dx=1,Dy=0.5,linewidth=1pt,
ticksize=4pt]{->}(2,2)(0.5,0.5)(4.5,4.5)
\end{pspicture}
\vspace{1cm}
\begin{pspicture}(5,5)
\psframe[linecolor=lightgray](0,0)(5,5)
\psgrid[gridcolor=red,subgridcolor=green,
gridlabels=0](1,1)(1,1)(4,4)
\psaxes[showorigin=false,
tickstyle=bottom]{->}(1,1)(4.5,4.5)
\end{pspicture}
\hspace{1.5cm}
\begin{pspicture}(5,5)
\psframe[linecolor=lightgray](0,0)(5,5)
\psaxes[axesstyle=frame,
showorigin=false](5,5)(5,5)(1,1)
\end{pspicture}
\end{document}
</pre></div><br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://3.bp.blogspot.com/-kZQ44EZ475Y/TuSSpvdrPoI/AAAAAAAAAPA/9r_4OUW2hhM/s1600/psaxes_pstricks.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="268" src="http://3.bp.blogspot.com/-kZQ44EZ475Y/TuSSpvdrPoI/AAAAAAAAAPA/9r_4OUW2hhM/s320/psaxes_pstricks.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Fig.1 The usage of Psaxes</td></tr>
</tbody></table>Files Download: <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gMjZhMjY4YmYtNTc4Zi00Y2I3LTlkOGQtMjhhMDk3YWE0MGMx" target="_blank">tex</a> <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gZTM4MzI4OTgtNDE0My00NWRjLWJiMzgtNTU5N2Y5NjBjNmUw" target="_blank">ps</a> <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gOGI4MTQ0OGEtZmI3NS00Mzk0LWFlMTItMDcyNzk4ZmI3YWVi" target="_blank">pdf</a>数声风笛离亭晚,我想潇湘君想秦!http://www.blogger.com/profile/08963583502168321534noreply@blogger.com4tag:blogger.com,1999:blog-1953712264459944819.post-64151590692008344012011-12-08T01:59:00.001-08:002012-06-12T04:29:51.535-07:00A Powerful Pstricks Tool ---- PsgridMaking grid with pstricks is very easy. You can just include "\psgrid" in your pspicture environment (note that psgrid can also used outside pspicture environment), then a beautiful grid will be drawn, just like the following:<br />
<br />
<div class="codes">
<pre>\documentclass{article}
\usepackage{pstricks}
\begin{document}
\begin{pspicture}(5,4)
\psgrid
\end{pspicture}
\end{document}
</pre>
</div>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://2.bp.blogspot.com/-MjFPBd3xUVo/TuCOb4D23sI/AAAAAAAAAOs/UaIy2xav2vA/s1600/psgrid_pstricks.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="251" src="http://2.bp.blogspot.com/-MjFPBd3xUVo/TuCOb4D23sI/AAAAAAAAAOs/UaIy2xav2vA/s320/psgrid_pstricks.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Fig.1 The simplest usage of psgrid</td></tr>
</tbody></table>
<br />
Command "\psgrid" can be followed with three arguments, i.e., "\psgrid(x0,y0)(x1,y1)(x2,y2)". (x1,y1) and (x2,y2) are the opposing corner of the grid area. The dedault value of (x1,y1) is (0,0). If (x1,y1) and (x2,y2) are both not specified, in a pspicture environment the coordinate of the current pspicture will be used, and outside a pspicture environment (10,10) will be used. By default, the intervals are labeled. The horizontal labels will be placed at positions (*,y0) and the vertical labels will be placed at positions (x0,*). If (x0,y0) is omitted, (x1,y1) will be used.<br />
<br />
The appearance of the grid can be changed if some parameters are applied."(sub)gridwidth","(sub)gridcolor" can be used to change the width and color of the main grid and sub grid. When (sub)griddots=num and num is a positive value , the (sub)grid lines are dotted with num dots per division. gridlabels and gridlabelcolor can used to control the size and color of the grid lables, and the default value of these two parameters is 10pt and black. If a positive int number(num) is set to parameter subgriddiv, then the main grid will be divided into num parts, and the default value is 5.<br />
<br />
In the following example we will examine "\psgrid" in detail.<br />
<br />
<div class="codes">
<pre>\documentclass{article}
\usepackage{pstricks}
\begin{document}
\begin{pspicture}(9,9)
\psgrid[gridcolor=red,subgridcolor=green]
(1,5)(1,5)(4,8)
\psgrid[gridcolor=blue,subgridcolor=yellow,
gridlabels=5pt](6,6)(5,5)(8,8)
\newrgbcolor{mycolor1}{0.5 0.3 0.3}
\newrgbcolor{mycolor2}{0.3 0.5 0.5}
\psgrid[gridcolor=mycolor1,
subgridcolor=mycolor2,subgriddiv=2,
subgridwidth=0.8pt,subgriddots=15,
gridlabels=0](1,1)(4,4)
\psgrid[griddots=10,subgriddots=3,
gridlabelcolor=red](5,1)(8,4)
\end{pspicture}
\end{document}
</pre>
</div>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://1.bp.blogspot.com/-y_vUPgxPOCQ/TuCOb6ColAI/AAAAAAAAAOw/jiz75eSjyj8/s1600/psgrid_advanced.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="313" src="http://1.bp.blogspot.com/-y_vUPgxPOCQ/TuCOb6ColAI/AAAAAAAAAOw/jiz75eSjyj8/s320/psgrid_advanced.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Fig.2 Psgrid with some options</td></tr>
</tbody></table>
<pre>Files Download: <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gMzdiMTVhOTktMDE0ZS00MjI2LTk4ZTUtYzQ5ZDMxODhlZmEx" target="_blank">tex</a> <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gNjViMjE4ZjctODg1Zi00NmNlLWJiYzctYmMyYjc1NDJkZGVh" target="_blank">ps</a> <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gM2UwZWE2ZDEtNTBlYy00NGI2LThkMzMtY2ViYjJmMDNhN2Rm" target="_blank">pdf</a>
</pre>数声风笛离亭晚,我想潇湘君想秦!http://www.blogger.com/profile/08963583502168321534noreply@blogger.com0tag:blogger.com,1999:blog-1953712264459944819.post-18419605566013928252011-12-06T02:14:00.001-08:002012-05-22T06:15:22.870-07:00Some basic graph objects in pstricks (4) ---- CurvesThere are several commands for curve drawing in Pstricks. "\psbezier" draws a Bezier curve, "\parabola" draws a parabola, and "\pscurve", "psecurve", "psccurve" interpolate curves through the given points. In the following they will be introduced one by one.<br />
<br />
Bezier curve is really a set of curves (Linear Bezier curve, Quadratic Bezier curve, Cubic bezier curve ...). The Bezier curve in Pstricks is cubic Bezier curve. And to to determine a cubic Bezier curve four control points are needed ("How to draw a cubic Bezier curve according to four given points" can be found in Wikipedia). So the complete form of "\psbezier" is "\psbezier [parameters] {arrowtype} (x0,y0)(x1,y1)(x2,y2),(x2,y3)".<br />
<br />
"\parabola [parameters] {arrowtype} (x0,y0)(x1,y1)" draws a parabola with maximum or minimum (x1,y1) staring from (x0,y0).<br />
<br />
"\pscurve [parameters] {arrowtype} (x1,y1)...(xn,yn)" interpolates an open curve through the given points. "\psecurve" is similar to "\pscurve" except that the curve is not extend to the first and last points. "\psccurve" draws a closed curve.<br />
<br />
The curvature of a curve is controlled by the parameter "curvature". <br />
<br />
Now we use these commands to draw several curves.<br />
<br />
<div class="codes">
<pre>\documentclass{article}
\usepackage{pstricks}
\begin{document}
\begin{pspicture}(5,5)
\psset{showpoints=true}
\psbezier[linecolor=green]
(0,0)(0,3)(5,1)(5,5)
\parabola[arrowsize=10pt]
{->}(5,5)(2.5,0)
\pscurve[linecolor=red]
(0,4)(1.25,5)(2.5,4)(3.75,3)(5,4)
\pscurve[linecolor=blue,
curvature=0.5 0.1 0]
(0,1)(1.25,0)(2.5,1)(3.75,2)(5,1)
\psccurve[fillstyle=solid,
fillcolor=yellow]
(3,4)(4.5,4)(4.5,4.5)(3,4.5)
\end{pspicture}
\end{document}
</pre>
</div>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://3.bp.blogspot.com/--5hxMrdgMRY/Tt3sw2ESsQI/AAAAAAAAAOg/KJlwbuIcwO4/s1600/curves_pstricks.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="298" src="http://3.bp.blogspot.com/--5hxMrdgMRY/Tt3sw2ESsQI/AAAAAAAAAOg/KJlwbuIcwO4/s320/curves_pstricks.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Fig.1 Draw Curves using Pstricks</td></tr>
</tbody></table>
Files Download: <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gYTE2OTMyZDAtMTg2Zi00MzI5LTgyNDAtZmJhMzhjNjQ1ODE0" target="_blank">tex</a> <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gNjJhOTg5ODEtZTlmOC00OGQwLWFmM2EtYjA1ODczYWE1ZmU2" target="_blank">ps</a> <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gNmNjN2Q2OTMtMTk0My00ZDFiLWE0NjQtMTg2OWNlZjlkMGNj" target="_blank">pdf</a>数声风笛离亭晚,我想潇湘君想秦!http://www.blogger.com/profile/08963583502168321534noreply@blogger.com0tag:blogger.com,1999:blog-1953712264459944819.post-84288266035313497602011-12-04T21:15:00.001-08:002012-04-12T00:32:46.524-07:00Some basic graph objects in pstricks (3) ---- Circles,Arc,Wedge,Ellipses,Elliptic Arc,Rectangle and so on"\pscircle[parameters](x0,y0){r}" draws a circle whose center is located at (x0,y0) and that has radius r.<br />
<br />
"\pswedge[parameters](x0,y0){r}{ang1}{ang2}" draws a wedge whose center is located at (x0,y0), that has radius r and extened counterclockwise from ang1 to ang2.<br />
<br />
"\psarc[parameters]{arrowstyle}(x,y){r}{angA}{angB}" clockwisely draws an arc form angA to angB. (x,y) and r are the center and radius of the circle ( a arc curve is always a part of a circle).<br />
<br />
"\psellipse[parameters](x0,y0)(h_r,v_r)" draws a ellipse. (x0,y0) is the center, h_r is the horizontal radius and v_r is the vertical radius.<br />
<br />
"\psellipticarc[par]{arrow}(x0,y0)(x1,y1){angA}{angB}" which is very similar to "\psarc" draws an elliptic.<br />
<br />
"\psframe[parameters](x0,y0)(x1,y1)" draws a rectangle with lower left corner at (xo,y0), upper right corner at (x1,y1).<br />
<br />
There are also command like "\pstriangle","\psdiamond" to draw triangle and diamond. But we can use "\pspolygon" to realize the utility of all these commands. So we will not talk about them here.<br />
<br />
For all these commands a star can be followed (for example, "\pscircle*"). This determine the fill the object.<br />
<br />
Now let we have a practice on these commands.<br />
<br />
<br />
<div class="codes">
<pre>\documentclass{article}
\usepackage{pstricks}
\begin{document}
\begin{pspicture}(-2.5,2.5)(2.5,2.5)
\psframe[linestyle=none,framearc=0.25,%
fillstyle=solid,fillcolor=green]
(-2.5,-2.5)(2.5,2.5)
\pscircle[linecolor=red](0,0){2.5}
\pswedge[fillstyle=solid,
fillcolor=red](0,0){2.5}{0}{45}
\psarc{->}(0,0){1.5}{0}{45} %draw arc
\uput{1.5}[22.5]
(0,0){$45^{\circ}$} %put a label
\psellipse(0,-1.25)(2.5,1.25)
\end{pspicture}
\end{document}
</pre>
</div>
<br />
This practice draw something like this:<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://3.bp.blogspot.com/-8dxslQoumR4/TtxVoJ8KdaI/AAAAAAAAAOU/pUj-zMhzAWs/s1600/circles_and_so_on_pstricks.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="316" src="http://3.bp.blogspot.com/-8dxslQoumR4/TtxVoJ8KdaI/AAAAAAAAAOU/pUj-zMhzAWs/s320/circles_and_so_on_pstricks.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Fig.1 Draw circle,arc,ellipse,rectangle... uisng Pstricks</td></tr>
</tbody></table>
Files download: <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gNTQ0NGRmZmYtNzA1Yi00NTg4LWEwZjUtYWMwYWYyMTlkYjhm" target="_blank">tex</a> <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gMDY2NDVmNGEtMDJhNy00ZjUzLTkwNDMtNTk2ZjM3YzViZDlm" target="_blank">ps</a> <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gZDcyMzAyODEtZWI4OC00Y2YwLWE0OWUtNzRkNmYyZjU3ZDk3" target="_blank">pdf</a>数声风笛离亭晚,我想潇湘君想秦!http://www.blogger.com/profile/08963583502168321534noreply@blogger.com1tag:blogger.com,1999:blog-1953712264459944819.post-32247836586018223802011-12-01T17:58:00.001-08:002012-04-10T04:45:39.144-07:00Some basic graph objects in pstricks (2) ---- LinesCommand "\psline[parameters]{arrowstyle}(x1,y1)(x2,y2)...(xn,yn)" draws a line through points (x1,x2),(x2,y2)...(xn,yn).<br />
<br />
Command "\pspolygon" is similar to "\psline", except that it draws a closed path and when a star is added, the closed area is filled with linecolor.<br />
<br />
Arrowstyle can be specified to tell pstricks which type of arrowhead the line terminated. The most used parameters include "linecolor", "linewidth", "linestyle" "linearc" and "cornersize". Linecolor and linewidth have the its literal meanings. Linestyle can take values "none,solid,dashed,dotted". When "dashed" is used, paramter "dash=len1 len2" can be used to specify the dash pattern. And when "dotted" is used, paramete "dotsep=len" can be used to specify the distance between the nearest two dots. If you want the line have round corners, parameter "linearc" is very useful. This parameter specifies the radius of arcs drawn at the corners. To show the points on the line, "showpoints=true" can be useful. To show how these commands and parameters are used, there is an example.<br />
<br />
<div class="codes">
<pre>\documentclass{article}
\usepackage{pstricks}
\begin{document}
\begin{pspicture}(5,5)
\pspolygon(0,0)(5,0)(5,5)(0,5)
\pspolygon*[linestyle=none,linecolor=blue,
linearc=4pt](0,0)(1,0)(1,1)(0,1)
\psline[linecolor=red,linestyle=solid]
{<->}(1,1) (4,4)
\psline[linewidth=5pt,linestyle=dashed,
dash=3pt 3pt]{->}(1,4) (4,1)
\psline[showpoints=true]
(0,0)(1,5)(2,0)(3,5)(4,0)(5,5)
\psline[linearc=5pt,linecolor=green]
(0,5)(1,0)(2,5)(3,0)(4,5)(5,0)
\end{pspicture}
\end{document}
</pre>
</div>
<br />
The lines looks like this:<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://2.bp.blogspot.com/-xTKQrpxnjyI/Ttgx1PHxYwI/AAAAAAAAANQ/3OzOrmrFX08/s1600/lines_pstricks.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="318" src="http://2.bp.blogspot.com/-xTKQrpxnjyI/Ttgx1PHxYwI/AAAAAAAAANQ/3OzOrmrFX08/s320/lines_pstricks.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Fig.1 Lines drawn using Pstricks</td></tr>
</tbody></table>
Files Download: <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gNDE2OTZhMzEtZmU1OS00NjliLWJkMjktZGYwNGRlMDY0NTIw" target="_blank">tex</a> <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gNjg5YmM1ZmMtZGZkZC00ZjMwLWFhYWEtNzJmYzM3MDdmMjQx" target="_blank">ps</a> <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gYmI1MTk4MjYtZGUwZi00OTU4LTkwZDAtMDI1Mzk2ZTYxMmQx" target="_blank">pdf</a><br />
<br />
<br />数声风笛离亭晚,我想潇湘君想秦!http://www.blogger.com/profile/08963583502168321534noreply@blogger.com1tag:blogger.com,1999:blog-1953712264459944819.post-12972005047919315102011-11-29T20:56:00.001-08:002012-04-10T20:04:36.886-07:00Some basic graph objects in pstricks (1) ---- DotsIn this and the next few posts some basic graph objects will be introduced. And the first one to be talked is "dots".<br />
<br />
Commands "\psdot[parameters](x1,y1)" and "\psdots[parameters](x1,y1)(x2,y2)...(xn,yn)" both draw dots on the canvas. The only difference is that the first one draw only one dot each time, while the second one can draw more than one. <br />
<br />
What the dots looks like is depend on the parameters used. The most used parameters are "dotstyle","dotsize","linecolor","fillcolor". Dotstyle determine the style of the dots, for example "*" for a solid circle, "o" for a hollow circle, "x" for a x symbol,"square" for a square and so on. For a complete set of dotstyles you may refer to the official documents. The dotsize determine the size of the dots. The color of the dots is determined by linecolor. If the dots is with a hollow center, the center is colored with fillcolor except for dotstyle "diamond". There are also some other parameters, you can find them in the official document. And at last an example is shown below:<br />
<br />
<div class="codes">
<pre>\documentclass{article}
\usepackage{pstricks}
\begin{document}
\begin{pspicture}(5,5)
\psdot[linecolor=red,dotstyle=*,
dotsize=24pt](1,4)
\psdot[linecolor=blue,fillcolor=red,
dotstyle=o,dotsize=24pt](1,3)
\psdots[fillcolor=blue,dotstyle=square,
dotsize=12pt](1,2)(2,2)(3,2)
\psset{dotsize=24pt,linecolor=yellow}
\psdots[dotstyle=x](2.5,4)
\psdot[dotstyle=+](2.5,3)
\end{pspicture}
\end{document}
</pre>
</div>
<br />
The picture these code draw looks like this:<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://4.bp.blogspot.com/-EZafpZ-RIbE/TtW8xgH5nWI/AAAAAAAAAM4/fIT0J2pkx0k/s1600/dots.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="285" src="http://4.bp.blogspot.com/-EZafpZ-RIbE/TtW8xgH5nWI/AAAAAAAAAM4/fIT0J2pkx0k/s320/dots.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Fig.1 Draw dots using Pstricks</td></tr>
</tbody></table>
<br />
Files Download: <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gMGY1Yjc5NDAtZmEzMi00MmJmLTgzNDctZjk1OGRkOTA0MTA0" target="_blank">tex</a> <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gOTMwOTAyMWQtZTcxOC00Njc2LTlkNTMtMzg2OWI0NWIwNDU2" target="_blank">ps</a> <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gZDk0NzM3NmMtM2NmNy00OThhLThjNjMtMTI5YTMxNTQ0YTU3" target="_blank">pdf</a>数声风笛离亭晚,我想潇湘君想秦!http://www.blogger.com/profile/08963583502168321534noreply@blogger.com1tag:blogger.com,1999:blog-1953712264459944819.post-36726674183632704102011-11-26T04:43:00.001-08:002012-04-06T03:21:00.565-07:00pspicture--an easy way to allocate space for pstricks elementspspicture is a latex environment which can make the allocation of space for pstricks elements very easy. To show its utility, now we come to fix the second example in the previous posts. <br />
<br />
<div class="codes"><pre>\documentclass{article}
\usepackage{pstricks}
\begin{document}
Pstricks Hello world! Pstricks Hello world!
Hello,world!
\begin{pspicture}(13ex,1ex)
\rput(6ex,0.5ex){\color{red} Hello,world!}
\end{pspicture}
Hello,World!
Pstricks Hello world! Pstricks Hello world!
\end{document}
</pre></div><br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://3.bp.blogspot.com/-f3o_fWoAcA0/TtoaZlqoDOI/AAAAAAAAANw/FDSdYLu8UJs/s1600/pspicture_pstricks.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="69" src="http://3.bp.blogspot.com/-f3o_fWoAcA0/TtoaZlqoDOI/AAAAAAAAANw/FDSdYLu8UJs/s320/pspicture_pstricks.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Fig.1 pspicture environment</td></tr>
</tbody></table>We see (Fig.1 pspicture environment) that this time the pstricks element "Hello,world!" has been placed in a right place. And some explanations on the pspicture environment is shown below:<br />
<br />
1. Pspicture environment can followed by two coordinate argument, i.e., "\begin{pspicture}(x0,y0)(x1,y1)". The first one represents the lower left corner and the second one represents the upper right corner. If the first one is not specified, it is (0,0) by default.<br />
<br />
2.There is a optional argument called "baseline"("\begin{pspicture}[baseline](x0,y0)(x1,y2)"). It sets the baseline fraction from the bottom. (Note that the value of baseline is not necessarily between 0 and 1.) If this argument is include but it is empty ([]), the baseline is set a horizontal line through the origin.<br />
<br />
3.The pstricks element may extents out the space specified. But if you specify the environment like this "\begin{pspicture}*[baseline](x0,y0)(x1,y1)", the anything outside the specified area will be clipped.<br />
<br />
Files download: <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gNjk1NzcwNWYtNWFhMS00MjEyLTk1ZmEtMTBhMWVkZmQzODM4" target="_blank">tex</a> <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gYjA5YzQwNmItMGVjMC00ODI2LWIwYmUtMGE4ZjU3ZGUwZjQ3" target="_blank">ps</a> <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gYzU0MDkxODctYjQzYi00ZjhiLTgxM2EtYjljMmI4MWMyZTA4" target="_blank">pdf</a><br />
<br />数声风笛离亭晚,我想潇湘君想秦!http://www.blogger.com/profile/08963583502168321534noreply@blogger.com0tag:blogger.com,1999:blog-1953712264459944819.post-37070909523796003292011-11-25T01:41:00.001-08:002011-12-05T19:50:14.591-08:00Begin with Pstricks----Hello,worldIt has be a tradition to give a "Hello, world" program first when a programming language is introduced. Pstricks is not a programming language (In fact, it is a set of macros that allow the inclusion of postscript drawings directly inside Tex or Latex code), but we will also begin it with "Hello, world".<br />
<br />
<br />
<div class="codes">
<pre>\documentclass{article}
\usepackage{pstricks}
\begin{document}
\rput(1,1){Hello,world}
\end{document}
</pre>
</div>
<br />
There are Some explanations on this example. "\rput(1,1){Hello,world}" draw text at position (1,1). The default coordinate Psstrick used is set up like this: the current point in Tex is used as the origin. The horizontal line through this point is the x-axes, and left is the positive direction. The vertical line through this point is the y-axes, and up direction is positive. The default unit is 1cm.<br />
<br />
Save it as a file (for example, with file name Pstircks_hello_world.tex), then Tex compile it with "latex" command. To get a postscript file, "dvips" or other dvi to postscript program should be used. And to get a pdf file, a ps to pdf program is also needed. Note that dvi2pdf may not produce a correct pdf file. <br />
<br />
At last the output file looks like this:<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><br />
<a href="http://1.bp.blogspot.com/-mCV1HniI8CE/Ts9fGK29jmI/AAAAAAAAAMg/LkL7-VXRyow/s1600/hello_world_pstricks.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="http://1.bp.blogspot.com/-mCV1HniI8CE/Ts9fGK29jmI/AAAAAAAAAMg/LkL7-VXRyow/s1600/hello_world_pstricks.jpg" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Fig.1 A simple Pstricks "Hello, world!" example</td></tr>
</tbody></table>
<br />
Files Download: <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gYzIzNTI4MDAtN2IwMi00OTMwLWE0MjAtYzJmMDE3MWVjNDUx" target="_blank">tex</a> <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gMmEwNmI5ZDItNzEwMC00NTA0LTg1OWMtM2Y2ZjBiMzFhOTNm" target="_blank">ps</a> <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gMWI3MWM3YmYtMjkwNC00ZmFkLTkyMmItYzJhOWUzZGJmODRh" target="_blank">pdf</a><br />
<br />
Now we come to a a little more complex "Hello, world" example.<br />
<br />
<div class="codes">
<pre>\documentclass{article}
\usepackage{pstricks}
\begin{document}
Pstricks Hello world! Pstricks Hello world!
Hello,world!
\rput(0,0){\color{red} Hello,world!}
Hello,World!
Pstricks Hello world! Pstricks Hello world!
\end{document}
</pre>
</div>
<br />
This tex file will produce a ps or pdf file like this:<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://2.bp.blogspot.com/-TQGOotTqk_Q/TtoX9vElLjI/AAAAAAAAANg/RyodPKAPDWU/s1600/hello_world_advanced_pstricks.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="77" src="http://2.bp.blogspot.com/-TQGOotTqk_Q/TtoX9vElLjI/AAAAAAAAANg/RyodPKAPDWU/s320/hello_world_advanced_pstricks.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Fig.2 An advanced Pstricks "Hello, world!" example</td></tr>
</tbody></table>
Of course, This is not what we want. The pstricks element is overwritten. This is because Tex do not reserve any space for the pstricks element. So kept in mind that when you insert any pstricks element in, make sure you have leave proper space for it. And to solve it, Pstricks provide a very convenient method--pspicture environment. And it may be talked in the next posts. <br />
<br />
Files Download: <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gNjMzZGE0ZDYtYmJkMi00N2MxLWE2ZTktMDk2M2YyNTM2YzVl" target="_blank">tex</a> <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gODM2MGNjMmEtYjk4MC00MTkwLWI5YzItZDIxMDcwMDRjMzg1" target="_blank">ps</a> <a href="https://docs.google.com/open?id=0B5wSAiwiTq4gNzgwZWRiZjEtYTBkNi00NzE0LWJiMTQtNzhmMzUwYzYwYmI1" target="_blank">pdf</a>数声风笛离亭晚,我想潇湘君想秦!http://www.blogger.com/profile/08963583502168321534noreply@blogger.com0