Re: [R] Sorting of captions on axes

From: Duncan Murdoch <murdoch_at_stats.uwo.ca>
Date: Fri, 04 Jan 2008 11:12:58 -0500

On 1/4/2008 10:44 AM, mika03 wrote:
>
> Hello,
>
> I think this might be a beginner question, but I couldn't find the answer in
> the manual...
>
>
> http://www.nabble.com/file/p14618947/at-modality.png
>
>
> I created this image with R by using the following code:
>
>
> modality <- read.table("results.table", header=TRUE, sep=",")
> color <- c("red3","green3","blue3","orange2","purple2","brown4")
> plot(modality, col=color)
>
> The data I read in has this format:
> ...
> 38355 GeneralInfo Textual
> 38356 GeneralInfo Textual
> 38357 Person Textual
> 38358 Person Combination
> 38359 Advice Textual
> 38360 GeneralInfo Textual
> ...
>
>
> The plot is exactly what I want, except for the sorting of the captions on
> the axes.
>
> I want to have them in a specfic order which is for the x-axis: Textual,
> Graphic, Video, Combination
> The y-axis shoul also sorted in different way, moreover some labels are
> missing here, that's not good!
>
> Does anyone know how to fix this?

You didn't give enough code to reproduce your plot, but generally the idea would be to replace the factor that's in the wrong order with an ordered factor in your chosen order, with something like

modality$col3 <- ordered(modality$col3, levels=c("Textual", "Graphic", "Video", "Combination"))

(Put the actual column name in place of col3 above.)

Duncan Murdoch



R-help_at_r-project.org mailing list
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. Received on Fri 04 Jan 2008 - 16:19:10 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 04 Jan 2008 - 17:30:05 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive