Showing posts with label \psframe. Show all posts
Showing posts with label \psframe. Show all posts

Wednesday, September 12, 2012

rput --- 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.
The common useage of this command is "\rput[refpoint]{rotation}(x,y){stuff}".
"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).

"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).

In the following example the usage of this command is shown practically.

\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}

Fig.1 rput --- a most offen used pstricks command
Files Download: tex ps pdf

Thursday, July 5, 2012

Pie 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".

name description default value
chartSep distance from the pie chart center to an outraged pie piece 10pt
chartColor gray or color gray
usercolor a comma separated list of user defined colors for the pie pieces encloed with { } { }
chartNodeI the position of the inner node, relative to the radius 0.75
chartNodeO the position of the outer node, relative to the radius 1.5

With these arguments we can plot a outstanding pie chart.

\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}

Fig.1 An advanced practical example of pie chart plotting

Files downloads: tex ps pdf


Sunday, June 3, 2012

Pie 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".

Now let us have a try of this command.

  \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}

Fig.1 Pie chart plots in Pstricks

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.

Files Downloads: tex ps pdf

Sunday, December 11, 2011

Axes of coordinates

This 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.

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"?

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.

"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".

In the following example the using of "\psaxes" is illustrated.

\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} 

Fig.1 The usage of Psaxes
Files Download: tex ps pdf

Sunday, December 4, 2011

Some 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.

"\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.

"\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).

"\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.

"\psellipticarc[par]{arrow}(x0,y0)(x1,y1){angA}{angB}" which is very similar to "\psarc" draws an elliptic.

"\psframe[parameters](x0,y0)(x1,y1)" draws a rectangle with lower left corner at (xo,y0), upper right corner at (x1,y1).

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.

For all these commands a star can be followed (for example, "\pscircle*"). This determine the fill the object.

Now let we have a practice on these commands.


\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}

This practice draw something like this:

Fig.1 Draw circle,arc,ellipse,rectangle... uisng Pstricks
 Files download: tex ps pdf
Creative Commons License
Except as otherwise noted, the content of this page is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.