3
\documentclass[12pt,border=5pt]{standalone}
\usepackage{newcent,pstricks-add,multido} 
\usepackage{auto-pst-pdf}
\begin{document}
\begin{pspicture}

\def\stuff1{Môi trường Vật lý}
\def\stuff2{Sự lãng mạn}
\def\stuff3{Sự nghiệp}
\def\stuff4{Gia đình/Bạn bè}
\def\stuff5{Tài chính}
\def\stuff6{Phát triển bản thân}
\def\stuff7{Sức khỏe}
\def\stuff8{Niềm vui/Giải trí}

\psChart[userColor={cyan,green,red,blue,teal,brown,gray,pink}] 
 {20,20,20,20,20,20,20,20}{}{2}
\multido{\r=-1.75+0.5,\n=8+-1}{8}{
     \psset{fillstyle=solid,dotstyle=square,dotscale=2}
     \def\a{3.5}
     \psdot[fillcolor=chartFillColor\n](\a,\r)
     \uput[0](\a,\r){\stuff\n}  }
 \end{pspicture}
 \end{document}

It produces:

enter image description here

How to its produces as the following:

enter image description here

One related question:

Why the result of compiling {20,20,20,20,20,20,20,20} as {10,10,10,10,10,10,10,10} or {45,45,45,45,45,45,45,45}?

4

The sequence specified as part of the mandatory argument for \psChart represents the proportions of the total pie being used for each segment. So, {20,20,20,20,20,20,20,20} will use the same proportions as {10,10,10,10,10,10,10,10} and {45,45,45,45,45,45,45,45} (or 12.5% each). You'll notice a difference in the pie slice sizes if you specify differing numbers.

enter image description here

\documentclass{article}

\usepackage{pstricks-add,multido}

\begin{document}

\begin{pspicture}

  \expandafter\def\csname stuff1\endcsname{First}
  \expandafter\def\csname stuff2\endcsname{Second}
  \expandafter\def\csname stuff3\endcsname{Third}
  \expandafter\def\csname stuff4\endcsname{Fourth}
  \expandafter\def\csname stuff5\endcsname{Fifth}
  \expandafter\def\csname stuff6\endcsname{Sixth}
  \expandafter\def\csname stuff7\endcsname{Seventh}
  \expandafter\def\csname stuff8\endcsname{Eighth}

  \psChart[
    userColor={cyan,green,red,blue,teal,brown,gray,pink}
  ]
    {1,1,1,1,1,1,1,1}{}{2}

  \def\a{3.5}
  \multido{\r=-1.75+0.5,\n=8+-1}{8}{
    \psset{fillstyle=solid,dotstyle=square,dotscale=2}
    \psdot[fillcolor=chartFillColor\n](\a,\r)
    \uput[0](\a,\r){\csname stuff\n\endcsname}
  }

  \psframe(3,-2)(5.5,2)

\end{pspicture}

\end{document}
  • Can you compact the syntax of "\expandafter\def\csname stuff1\endcsname{First}" such as \expandafter\def\csname ... \endcsname{...} only used 1 time ? – Trong Vuong Dec 12 '18 at 7:37
  • @chishimotoji: Sure. Check out this code. – Werner Dec 12 '18 at 7:42
4
\documentclass[12pt]{article}
\usepackage{newcent,pstricks-add,multido} 
\usepackage{auto-pst-pdf}

\def\stuff#1{%
    \ifcase #1
    \or {Môi trường Vật lý}
    \or {Sự lãng mạn}
    \or {Sự nghiệp}
    \or {Gia đình/Bạn bè}
    \or {Tài chính}
    \or {Phát triển bản thân}
    \or {Sức khỏe}
    \or {Niềm vui/Giải trí}
    \fi}
\begin{document}

\begin{pspicture}(-5,-5)(10,5)  
\psChart[userColor={cyan,green,red,blue,teal,brown,gray,pink}]{20,20,20,20,20,20,20,20}{}{2}
\psset{fillstyle=solid,dotstyle=square,dotscale=2}%
\def\a{3.5}%
\multido{\r=-1.75+0.5,\n=8+-1}{8}{%
  \psdot[fillcolor=chartFillColor\n](\a,\r) \uput[0](\a,\r){\stuff{\n}}%
}
\end{pspicture}

\end{document}

enter image description here

  • With good pst-tools package and \psRegisterList{Name}{value list} \<Name>{Index}. I can also get the same result... A wonderful package.... – Trong Vuong Jan 30 at 13:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.