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) -- Dietrich Trenkler c/o Universitaet Osnabrueck Rolandstr. 8; D-49069 Osnabrueck, Germany email: Dietrich.Trenkler at Uni-Osnabrueck.de
On 3/13/06, Dietrich Trenkler <Dietrich.Trenkler at uni-osnabrueck.de> 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)For what it's worth, library(lattice) dotplot(sort(a)) seems to do a better job. Deepayan
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) > >It looks like the calculations of label widths are inaccurate, probably because strwidth can't accurately measure the size of strings. I'm not sure if this is a bug, or just a limitation of the information available to it. However, I think you could get the result you want with some trial and error by doing the dotchart with blank labels first, then using mtext to put the labels in place. For example: "a" <- 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") o <- order(a) a <- a[o] names <- names[o] dotchart(a, labels=rep(" ", length(a))) mtext(names, 2, at=1:length(a), adj=1, las=2, line=-14, cex=0.8) Duncan Murdoch
Apparently Analagous Threads
- [R] dotchart: Gap between text and chart (PR#8681)
- AW: wbinfo doesnt work...
- Package survey: singularities in linear regression models
- How can I read time series data to create zoo objects if I have two title lines?
- Multiple Network Cards + Multiple Bridges on debian lenny