[pstricks] query from enterline re scatterplot datapoint labeling in pstricks
Andrew Enterline
ajenter at gmail.com
Sat Sep 16 05:41:42 CEST 2006
all,
i am grateful to vinay for his advice regarding the scatterplot with
labels. ultimately, i relied on his idea of using \rput for the labels and
\listplot for the data points, as the the labels require adjustment,
because they often overlap and are unreadable. again, thanks to vinay for
his time.
my final code is as follows:
\documentclass[12pt]{article}
\usepackage[dvips]{graphics}
\usepackage{pst-all} % From PSTricks
\newpsobject{showgrid}{psgrid}{subgriddiv=1,griddots=5,gridlabels=.5pt}
\begin{document}
\psset{xunit=1cm,yunit=.125cm} %for 80 year setup
\begin{pspicture}(0,0)(10,80)
%create data series for data points
\def\datab{10 80 4 80 4 75 8 73 3 59 2 50 10 49 7 47 10
46 9 45 10 43 10 38 5 38 10 36 8 35 2 33 8 30 10 29 5 29 9
27 4 24 2 21 8 15 2 15 2 12 7 10 2 9 7 9 2 8 6 7 5 7 7 6 9
5 8 5 7 5 8 5 9 5 2 4 4 4 5 2 }
%\showgrid
\psaxes[tickstyle=bottom,ticks=all,Oy=0,Dy=10,Ox=0,Dx=1,labels=all](0,0)(0,0)(10,80)
\listplot[plotstyle=dots,dotsize=2.5pt,linecolor=red]{\datab}%
%insert data labels proximate to data points
\rput (4,77){\tiny South Africa} \rput (8.2,80){\tiny New Zealand
(10, 138 years)} \rput (2.5,80){\tiny Canada (4, 128 years)}
\rput(8,75){\tiny Ireland} \rput(3,61){\tiny Cuba}
\rput(2,52){\tiny Lebanon} \rput(10,55){\tiny Austria (1946)}
\rput(7,49){\tiny Sri Lanka} \rput(8.75,49){\tiny W.~Germany}
\rput(9,43){\tiny India} \rput(10,41){\tiny Japan}
\rput(8,40){\tiny Malaysia} \rput(5,40){\tiny Philippines}
\rput(10,34){\tiny Jamaica} \rput(8,37){\tiny Cyprus}
\rput(2,35){\tiny Haiti} \rput(7.5,32){\tiny Gambia}
\rput(10,28){\tiny Botswana} \rput(5,31){\tiny Honduras}
\rput(8.4,26){\tiny Mauritius} \rput(4,26){\tiny Zimbabwe}
\rput(2,23){\tiny Yugoslavia} \rput(8,17){\tiny Austria (1920)}
\rput(2,17){\tiny Guyana} \rput(2,13.5){\tiny Pakistan}
\rput(5.15,15){\tiny Somalia} \rput(1,11){\tiny Zambia}
\rput(9,10){\tiny Singapore} \rput(3,1.5){\tiny Kenya} \rput(5,12)
{\tiny Sierra Leone} \rput(4.5,9){\tiny Syria} \rput(7,7.5){\tiny
Panama} \rput(10.1,5){\tiny Lesotho/Namibia} \rput(9.3,1.25){\tiny
Nigeria/Sudan} \rput(7,2.95){\tiny Uganda} \rput(2,2){\tiny Benin}
\rput(4,1.5){\tiny Congo} \rput(5.75,1.5){\tiny Comoros}
\psline[linestyle=solid,linewidth=.25pt]{->}(1.5,11)(1.9,9) %Zambia
\psline[linestyle=solid,linewidth=.25pt]{->}(2.63,2)(2.05,7.35) %Kenya
\psline[linestyle=solid,linewidth=.25pt]{->}(5.7,11)(6,7.75) %Sierra Leone
\psline[linestyle=solid,linewidth=.25pt]{->}(5.75,15)(6.9,10.2) %Somalia
\psline[linestyle=solid,linewidth=.25pt]{->}(8.4,10)(7.1,9) %Singapore
\psline[linestyle=solid,linewidth=.25pt]{->}(8.45,1.3)(8.05,4.5)
%Nigeria/Sudan
\psline[linestyle=solid,linewidth=.25pt]{->}(10,53)(10,50) %Austria (1946)
\psline[linestyle=solid,linewidth=.25pt]{->}(9.5,48)(9.9,46.5) %Germany
\psline[linestyle=solid,linewidth=.25pt]{->}(8.75,39.5)(9.9,38) %Malaysia
\end{pspicture}
On 9/13/06, vkanetka at uoguelph.ca <vkanetka at uoguelph.ca> wrote:
>
> Andrew:
>
> This is one solution... but there might be better approaches than this..
>
> Vinay
>
> =================
>
> \documentclass[12pt]{article}
> \usepackage[dvips]{graphics}
> \usepackage{pst-all} % From PSTricks
> \newpsobject{showgrid}{psgrid}{subgriddiv=1,griddots=10,gridlabels=6pt}
> \begin{document}
> \psset{xunit=.5cm,yunit=.2cm}
> \begin{pspicture}(0,0)(15,80)%\showgrid
> {\tiny
>
> \psaxes[tickstyle=bottom,ticks=all,Oy=0,Dy=5,Ox=0,Dx=1,labels=all]{<->}(0,0)(0,0)(15,80)}
> \rput(2, 4){\tiny Benin}
> \rput(4, 4){\tiny Congo}
> \rput(2, 9){\tiny Zambia}
> \rput(9, 5){\tiny Lesotho}
> \rput(1, 7){\tiny Malagasy}
> \rput(6, 7){\tiny Sierra Leone}
> \rput(8, 5){\tiny Nigeria}
> \rput(7, 5){\tiny Uganda}
> \rput(5, 2){\tiny Comoros}
> \rput(8, 5){\tiny Sudan}
> \rput(2, 8){\tiny Kenya}
> \rput(7, 10){\tiny Somalia}
> \rput(4, 24){\tiny Zimbabwe}
> \rput(4, 75){\tiny South Africa}
> \end{pspicture}
> \end{document}
> ==================
> Quoting Andrew Enterline <ajenter at gmail.com>:
>
> > all,
> >
> > i'm interested in creating an X-Y scatterplot in pstricks that enables
> me to
> > automatically label the scattered data points with a label (in this
> case, a
> > country). i searched around, but experienced trouble locating an
> example.
> > a sample data series is as follows:
> >
> > X Y Label
> > 2 4 Benin
> > 4 4 Congo
> > 2 9 Zambia
> > 9 5 Lesotho
> > 1 7 Malagasy
> > 6 7 Sierra Leone
> > 8 5 Nigeria
> > 7 5 Uganda
> > 5 2 Comoros
> > 8 5 Sudan
> > 2 8 Kenya
> > 7 10 Somalia
> > 4 24 Zimbabwe
> > 4 75 South Africa
> >
> > does anyone have any ideas? i am grateful for any examples.
> >
> > thanks,
> > andrew
>
>
>
>
>
> _______________________________________________
> pstricks mailing list
> pstricks at tug.org
> http://tug.org/mailman/listinfo/pstricks
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://tug.org/pipermail/pstricks/attachments/20060915/d2c18331/attachment.html
More information about the PSTricks
mailing list