3

I'm creating pie chart using code below:

\begin{center}
\begin{pspicture}(-5,-4)(4,4)
\psset{unit=1.2}
\psChart[userColor={black!10,black!40},chartSep=10pt,shadow,shadowsize=3pt]{\above,\below}{}{3}
\bfseries%
\rput(psChartI1){TEXTA \above \%}\rput(psChartI2){TEXTB \below \%}
\end{pspicture}
\end{center}

Currently TEXTA & TEXTB are aligned towards circumference, is there any way to center align this text?

UPDATE: (with MWE);

\documentclass{article}
\usepackage{pstricks-add}
\usepackage{pgfplots, pgfplotstable}
\usepackage{datatool}
\usepackage{tikz}
\begin{document}
\begin{center}
\begin{pspicture}(-5,-4)(4,4)
\psset{unit=1.2}
\psChart[userColor={black!10,black!40},chartSep=10pt,shadow,shadowsize=3pt]{30,70}{}{3}
\bfseries%
\rput(psChartI1){TEXTA 30 \%}\rput(psChartI2){TEXTB 70 \%}
\end{pspicture}
\end{center}
\end{document}
3
  • 1
    Please provide us with MWE (minimal working example). \rput has an optional argument to specify the anchor. Oct 5, 2013 at 17:10
  • MWE updated in the question.
    – Pawan Mude
    Oct 5, 2013 at 17:20
  • 1
    Herbert's answer is much more elegant than mine. Oct 5, 2013 at 18:25

2 Answers 2

3

Set the distance of the inner chart node to 0.5:

\documentclass{article}
\usepackage{pstricks-add}

\begin{document}
\begin{pspicture}(-5,-4)(4,4)
\psset{unit=1.2}
\psChart[userColor={black!10,black!40},chartSep=10pt,chartNodeI=0.5,%%%%%
         shadow,shadowsize=3pt]{30,70}{}{3}
\rput(psChartI1){\bf TEXTA 30\%}
\rput(psChartI2){\bf TEXTB 70\%}
%\psdots(psChartI1)(psChartI2)%% for a test
\end{pspicture}
\end{document}

enter image description here

7
  • 6
    I really don't understand why you still use a command (\bf) that has been declared obsolete twenty years ago. If you want to use it in your own documents, fine; I find it wrong to use it in a public place where we are expected to teach proper usage of LaTeX.
    – egreg
    Oct 5, 2013 at 17:44
  • 2
    What has PSTricks to do with \bf? Try changing article into memoir and see the result.
    – egreg
    Oct 5, 2013 at 17:48
  • Thank You, it's working perfectly for ratio of 30,70; Is there any way to make it generic (to make center align for any values ex: 10:90 , 5:95, 50,50 and so on)?
    – Pawan Mude
    Oct 5, 2013 at 18:01
  • 2
    @PawanMude: see my edit. I set the relative distance of the inner node to 0.5
    – user2478
    Oct 5, 2013 at 18:09
  • Why do we need to load pst-node when using (*x {\f(x)}) syntax? Oct 7, 2013 at 8:06
2
\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pstricks-add}

\begin{document}

\multido{\i=0+15}{24}{%
\begin{pspicture}(-4,-4)(4,4)
\psset{unit=1.2}
\psChart[userColor={black!10,black!40},chartSep=10pt,shadow,shadowsize=3pt]{30,70}{}{3}
\bfseries
\rput{\i}(1.5;54){TEXTA 30 \%}
\rput{\i}(1.5;234){TEXTB 70 \%}
\end{pspicture}}

\end{document}

enter image description here

2
  • 3
    Animation proves that the labels are centered. Oct 5, 2013 at 17:37
  • 1
    Thank You PGFTricks for sharing answer. It's working as desired.
    – Pawan Mude
    Oct 5, 2013 at 18:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .