Re: [R] dotchart: Gap between text and chart (PR#8681)

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: [R] dotchart: Gap between text and chart (PR#8681)

Duncan Murdoch
(Moved from r-help)

On 3/13/2006 9:33 AM, Dietrich Trenkler wrote:

> I have some data which I would like to display with dotchart. The
> labels are very long, so the chart becomes too small. Setting cex=0.7
> seems to be a good compromise, but the gap between the text and the
> chart still is too large. I did not find a "gap" parameter in the
> description of dotchart...
>
> Thanks for any help.
>
> D. Trenkler
>
>
> "a" <- structure(c(103.35, 36.73, 55.09, 302.66, 68.54, 35.46,
>     138.65, 25.21, 110.85, 6.66, 46.57, 70.23), .Names =
> c("Nahrungsmittel und alkoholfreie Getraenke",
>     "Alkoholische Getraenke, Tabakwaren", "Bekleidung und Schuhe",
>     "Wohnungsmieten, Energie", "Einrichtungsgegenstaende",
> "Gesundheitspflege",
>     "Verkehr", "Nachrichtenuebermittlung", "Freizeit, Unterhaltung  und
> Kultur",
>     "Bildungswesen", "Beherbergungs und Gaststaettendienstleistungen",
>     "Andere Waren und Dienstleistungen"))
>
> dotchart(sort(a))
> dotchart(sort(a),cex=0.7)

I've determined that this is a bug in dotchart.  It miscalculates the
height of a line of text in the right margin, using

  lheight <- strheight("M", "inch")

which doesn't give the right answer.  You get the correct answer in this
case by putting

  lheight <- par("mai")[2]/par("mar")[2]

but that's not a general solution, as the denominator may be zero.

I'll look for a better solution.

Duncan Murdoch

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: [R] dotchart: Gap between text and chart (PR#8681)

Brian Ripley
On Mon, 13 Mar 2006, [hidden email] wrote:

> (Moved from r-help)
>
> On 3/13/2006 9:33 AM, Dietrich Trenkler wrote:
>> I have some data which I would like to display with dotchart. The
>> labels are very long, so the chart becomes too small. Setting cex=0.7
>> seems to be a good compromise, but the gap between the text and the
>> chart still is too large. I did not find a "gap" parameter in the
>> description of dotchart...
>>
>> Thanks for any help.
>>
>> D. Trenkler
>>
>>
>> "a" <- structure(c(103.35, 36.73, 55.09, 302.66, 68.54, 35.46,
>>     138.65, 25.21, 110.85, 6.66, 46.57, 70.23), .Names =
>> c("Nahrungsmittel und alkoholfreie Getraenke",
>>     "Alkoholische Getraenke, Tabakwaren", "Bekleidung und Schuhe",
>>     "Wohnungsmieten, Energie", "Einrichtungsgegenstaende",
>> "Gesundheitspflege",
>>     "Verkehr", "Nachrichtenuebermittlung", "Freizeit, Unterhaltung  und
>> Kultur",
>>     "Bildungswesen", "Beherbergungs und Gaststaettendienstleistungen",
>>     "Andere Waren und Dienstleistungen"))
>>
>> dotchart(sort(a))
>> dotchart(sort(a),cex=0.7)
>
> I've determined that this is a bug in dotchart.  It miscalculates the
> height of a line of text in the right margin, using
>
>  lheight <- strheight("M", "inch")
>
> which doesn't give the right answer.  You get the correct answer in this
> case by putting
>
>  lheight <- par("mai")[2]/par("mar")[2]
>
> but that's not a general solution, as the denominator may be zero.
>
> I'll look for a better solution.

Like setting mai not mar?  The ratio is par("csi"), by the way.

--
Brian D. Ripley,                  [hidden email]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: [R] dotchart: Gap between text and chart (PR#8681)

Duncan Murdoch
On 3/13/2006 12:55 PM, Prof Brian Ripley wrote:

> On Mon, 13 Mar 2006, [hidden email] wrote:
>
>> (Moved from r-help)
>>
>> On 3/13/2006 9:33 AM, Dietrich Trenkler wrote:
>>> I have some data which I would like to display with dotchart. The
>>> labels are very long, so the chart becomes too small. Setting cex=0.7
>>> seems to be a good compromise, but the gap between the text and the
>>> chart still is too large. I did not find a "gap" parameter in the
>>> description of dotchart...
>>>
>>> Thanks for any help.
>>>
>>> D. Trenkler
>>>
>>>
>>> "a" <- structure(c(103.35, 36.73, 55.09, 302.66, 68.54, 35.46,
>>>     138.65, 25.21, 110.85, 6.66, 46.57, 70.23), .Names =
>>> c("Nahrungsmittel und alkoholfreie Getraenke",
>>>     "Alkoholische Getraenke, Tabakwaren", "Bekleidung und Schuhe",
>>>     "Wohnungsmieten, Energie", "Einrichtungsgegenstaende",
>>> "Gesundheitspflege",
>>>     "Verkehr", "Nachrichtenuebermittlung", "Freizeit, Unterhaltung  und
>>> Kultur",
>>>     "Bildungswesen", "Beherbergungs und Gaststaettendienstleistungen",
>>>     "Andere Waren und Dienstleistungen"))
>>>
>>> dotchart(sort(a))
>>> dotchart(sort(a),cex=0.7)
>>
>> I've determined that this is a bug in dotchart.  It miscalculates the
>> height of a line of text in the right margin, using
>>
>>  lheight <- strheight("M", "inch")
>>
>> which doesn't give the right answer.  You get the correct answer in this
>> case by putting
>>
>>  lheight <- par("mai")[2]/par("mar")[2]
>>
>> but that's not a general solution, as the denominator may be zero.
>>
>> I'll look for a better solution.
>
> Like setting mai not mar?  The ratio is par("csi"), by the way.

Yes, setting mai rather than mar simplifies the code a bit, but some
parts still need to work in lines, because mtext doesn't accept
positioning arguments in inches.  I've used par("csi") in place of the
ratio now, and am about to commit to r-devel and r-patched.

Duncan Murdoch

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel