[R] customizing the axis (adding labels)

Jörg Groß joerg at licht-malerei.de
Sun Aug 10 19:08:38 CEST 2008


Am 10.08.2008 um 18:53 schrieb stephen sefick:

> the xaxt="n" needs to be inside of the plot command otherwise you can
> never plot the x axis- I think.

Ah, ok, thanks!
Now it works fine.

Here a complete example of what I wanted to plot:


par(bty="n", mar=c(10, 10, 3, 3))
plot(c(1,2), c(50,60), ylim=c(40,70), xlim=c(0,3), xaxt="n")
dispbars(1,50,5)
dispbars(2,60,5)
axis(1, at=c(1,2), labels=c("group 1","group 2"))


>
>
> On Sun, Aug 10, 2008 at 12:51 PM, stephen sefick <ssefick at gmail.com>  
> wrote:
>> j = c(5,6)
>> f = c(1,2)
>> plot(f,j, xaxt="n")
>> axis(1, at=c(1,2), labels=c("group1", "group2"))
>>
>> On Sun, Aug 10, 2008 at 12:09 PM, Jörg Groß <joerg at licht- 
>> malerei.de> wrote:
>>>
>>> Am 10.08.2008 um 17:46 schrieb stephen sefick:
>>>
>>>> Would you provide reproducible code because form your example it  
>>>> looks
>>>> like you are trying to label a scatterplot with just two lables -  
>>>> this
>>>> is your boxplot from yesterday?  If so look into the ?boxplot and  
>>>> it
>>>> will tell you some answers
>>>
>>> No, what I want is to plot the mean for two different groups.
>>> So that I get group 1 and 2 on the x-axis and also label it like  
>>> that.
>>>
>>>
>>>>
>>>>
>>>> On Sun, Aug 10, 2008 at 11:29 AM, Jörg Groß <joerg at licht- 
>>>> malerei.de>
>>>> wrote:
>>>>>
>>>>> Hi,
>>>>>
>>>>> I want to customize the x-axis.
>>>>>
>>>>> I tried that:
>>>>> par(bty="n", xaxt="n")
>>>>> so that the x-axis is supressed.
>>>>>
>>>>> then I tried to plot two variables and add a customized x-axis:
>>>>> plot(x, y)
>>>>> axis(1, at=c(1,2), labels=c("group1", "group2"))
>>>>>
>>>>> but the axis is not added to the plot.
>>>>>
>>>>> I don't understand why..
>>>>> And how then can I customize the axis?
>>>>>     [[alternative HTML version deleted]]
>>>>>
>>>>> ______________________________________________
>>>>> 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.
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Let's not spend our time and resources thinking about things that  
>>>> are
>>>> so little or so large that all they really do for us is puff us  
>>>> up and
>>>> make us feel like gods. We are mammals, and have not exhausted the
>>>> annoying little problems of being mammals.
>>>>
>>>>       -K. Mullis
>>>
>>> ______________________________________________
>>> 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.
>>>
>>
>>
>>
>> --
>> Let's not spend our time and resources thinking about things that are
>> so little or so large that all they really do for us is puff us up  
>> and
>> make us feel like gods. We are mammals, and have not exhausted the
>> annoying little problems of being mammals.
>>
>>       -K. Mullis
>>
>
>
>
> -- 
> Let's not spend our time and resources thinking about things that are
> so little or so large that all they really do for us is puff us up and
> make us feel like gods. We are mammals, and have not exhausted the
> annoying little problems of being mammals.
>
> 	-K. Mullis



More information about the R-help mailing list