[R] X axis labels are not fully shown when using pareto.chart function

Jim Lemon drj|m|emon @end|ng |rom gm@||@com
Wed Sep 16 06:54:44 CEST 2020


Hi Paul,
It is a contest between the quantity of information and legibility.
You have 140 labels to place on the x-axis in your plot and I barely
managed it by almost doubling the width of the plot, halving the size
of the font and truncating the labels to a maximum of 20 characters.
Unless you want to follow something like Google Maps, where the
information springs up in a little balloon, you are close to the
limits of a static display. That said, you are correct in saying that
staxlab will cram a lot of information at the edges of a plot.

Jim

On Wed, Sep 16, 2020 at 11:36 AM Paul Bernal <paulbernal07 using gmail.com> wrote:
>
> Dear Jim,
>
> Thank you so much for your valuable and kind reply. I will try what you suggest and will let you and the group members how that goes.
>
> Can the resolution you suggest be applied whenever I encounter an issue like the one I just described (to make x-axis labels clearly visible)? I imagine if work with some other x-axis labels I'd just have to play around with the width, height, srt and cex parameters?
>
> Best regards,
>
> Paul
>
>
> El mar., 15 de septiembre de 2020 7:06 p. m., Jim Lemon <drjimlemon using gmail.com> escribió:
>>
>> Hi Paul,
>> This looks very familiar to me, but I'll send my previous suggestion.
>>
>> library(qcc)
>> x11(width=13,height=5)
>> pareto.chart(dataset2$Points,xaxt="n")
>> library(plotrix)
>> staxlab(1,at=seq(0.035,0.922,length.out=140),
>>  labels=substr(dataset2$School,1,20),srt=90,cex=0.5)
>>
>> Jim
>>
>> On Wed, Sep 16, 2020 at 2:53 AM Paul Bernal <paulbernal07 using gmail.com> wrote:
>> >
>> > Dear friends,
>> >
>> > Hope you are doing well. I am currently using R version 3.6.2. I installed
>> > and loaded package qcc by Mr. Luca Scrucca.
>> >
>> > Hopefully someone can tell me if there is a workaround for the issue I am
>> > experiencing.
>> >
>> > I generated the pareto chart using qcc´s pareto.chart function, but when
>> > the graph gets generated, the x-axis labels aren´t fully shown (some labels
>> > get truncated), and so the text can´t be viewed properly.
>> >
>> > Is there any way to adjust the x-axis labels (font and orientation), so
>> > that they can be easily shown?
>> >
>> > This is the structure of my data:
>> >
>> > str(dataset2)
>> > 'data.frame':   140 obs. of  2 variables:
>> >  $ School: Factor w/ 140 levels "24 de Diciembre",..: 39 29 66 16 67 116 35
>> > 106 65 17 ...
>> >  $ Points: num  55 43 24 21 20 20 18 17 16 16 ...
>> >
>> >
>> > Below is the dput() of my dataset.
>> >
>> > dput(dataset2)
>> > structure(list(School = structure(c(39L, 29L, 66L, 16L, 67L,
>> > 116L, 35L, 106L, 65L, 17L, 12L, 55L, 136L, 8L, 24L, 140L, 123L,
>> > 114L, 22L, 15L, 98L, 4L, 107L, 110L, 20L, 76L, 19L, 25L, 93L,
>> > 14L, 46L, 7L, 104L, 121L, 23L, 88L, 74L, 41L, 103L, 59L, 96L,
>> > 95L, 30L, 109L, 117L, 132L, 47L, 21L, 137L, 79L, 115L, 101L,
>> > 125L, 2L, 129L, 71L, 73L, 58L, 127L, 131L, 78L, 18L, 50L, 100L,
>> > 80L, 37L, 38L, 108L, 40L, 85L, 86L, 45L, 138L, 126L, 34L, 135L,
>> > 5L, 1L, 31L, 82L, 87L, 63L, 105L, 68L, 28L, 72L, 111L, 49L, 112L,
>> > 32L, 70L, 10L, 3L, 118L, 44L, 133L, 57L, 48L, 64L, 97L, 43L,
>> > 99L, 56L, 9L, 119L, 61L, 77L, 81L, 51L, 11L, 52L, 42L, 60L, 53L,
>> > 134L, 122L, 124L, 128L, 94L, 130L, 92L, 33L, 6L, 26L, 113L, 27L,
>> > 69L, 36L, 75L, 102L, 83L, 84L, 120L, 13L, 54L, 62L, 89L, 90L,
>> > 91L, 139L), .Label = c("24 de Diciembre", "Achiote", "Aguadulce",
>> > "Alcalde Díaz", "Alto Boquete", "Amador", "Amelia Denis de Icaza",
>> > "Ancón", "Antón", "Arnulfo Arias", "Arosemena", "Arraiján", "Bajo Boquete",
>> > "Barrio Balboa", "Barrio Colón", "Barrio Norte", "Barrio Sur",
>> > "Bejuco", "Belisario Frías", "Belisario Porras", "Bella Vista",
>> > "Betania", "Buena Vista", "Burunga", "Calidonia", "Cañaveral",
>> > "Canto del Llano", "Capira", "Cativá", "Cermeño", "Cerro Silvestre",
>> > "Chame", "Chepo", "Chicá", "Chilibre", "Chitré", "Ciricito",
>> > "Comarca Guna de Madugandí", "Cristóbal", "Cristóbal Este", "Curundú",
>> > "David", "Don Bosco", "El Arado", "El Caño", "El Chorrillo",
>> > "El Coco", "El Espino", "El Guabo", "El Harino", "El Higo", "El Llano",
>> > "El Roble", "El Valle", "Ernesto Córdoba Campos", "Escobal",
>> > "Feuillet", "Garrote o Puerto Lindo", "Guadalupe", "Herrera",
>> > "Hurtado", "Isla de Cañas", "Isla Grande", "Iturralde", "José Domingo
>> > Espinar",
>> > "Juan Demóstenes Arosemena", "Juan Díaz", "La Concepción", "La Ensenada",
>> > "La Laguna", "La Mesa", "La Raya de Calobre", "La Represa", "Las Cumbres",
>> > "Las Lajas", "Las Mañanitas", "Las Ollas Arriba", "Lídice", "Limón",
>> > "Los Díaz", "Los Llanitos", "María Chiquita", "Mateo Iturralde",
>> > "Miguel de la Borda", "Nombre de Dios", "Nueva Providencia",
>> > "Nuevo Chagres", "Nuevo Emperador", "Obaldía", "Ocú", "Olá",
>> > "Omar Torrijos", "Pacora", "Pajonal", "Palmas Bellas", "Parque Lefevre",
>> > "Pedasí", "Pedregal", "Penonomé", "Piña", "Playa Leona", "Pocrí",
>> > "Portobelo", "Pueblo Nuevo", "Puerto Armuelles", "Puerto Caimito",
>> > "Puerto Pilón", "Punta Chame", "Rio Abajo", "Río Abajo", "Río Grande",
>> > "Río Hato", "Río Indio", "Rufina Alfaro", "Sabanagrande", "Sabanitas",
>> > "Sajalices", "Salamanca", "San Carlos", "San Felipe", "San Francisco",
>> > "San José", "San Juan", "San Juan Bautista", "San Martín", "San Martín de
>> > Porres",
>> > "Santa Ana", "Santa Clara", "Santa Fe", "Santa Isabel", "Santa Rita",
>> > "Santa Rosa", "Santiago", "Santiago Este", "Tinajas", "Tocumen",
>> > "Veracruz", "Victoriano Lorenzo", "Villa Rosario", "Vista Alegre"
>> > ), class = "factor"), Points = c(55, 43, 24, 21, 20, 20, 18,
>> > 17, 16, 16, 15, 13, 13, 12, 12, 11, 11, 11, 11, 11, 10, 9, 9,
>> > 9, 9, 9, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6,
>> > 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
>> > 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4,
>> > 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
>> > 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2,
>> > 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2)), row.names = c(NA, -140L
>> > ), class = "data.frame")
>> >
>> > Best regards,
>> >
>> > Paul
>> >
>> >         [[alternative HTML version deleted]]
>> >
>> > ______________________________________________
>> > R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> > https://stat.ethz.ch/mailman/listinfo/r-help
>> > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> > and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list