Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

removing x axis in error.bars

Tags:

r

axis

I've been having a problem today, I want to remove the x-axis from the following R-plot, but it just won't disappear. I want the axis to be on top. Is anybody able to help me?

library(psych)
temp <- describe(attitude)
error.bars(stats=temp,xaxt="n")
axis(3)
like image 539
Sir Ksilem Avatar asked Jun 19 '26 20:06

Sir Ksilem


2 Answers

You can use fixInNamespace() to edit the error.bars() function in the psych NAMESPACE. Try:

fixInNamespace(error.bars)

That will open the function in a rudimentary text editing window. Find the axis() calls and comment out the ones you don't want. Exit the editor and R will update the function in the NAMESPACE.

Then try using the function again.

Alternatively, you can print the code for error.bars() to the prompt, copy it into a text editor, change the name of the function, say to my.error.bars, and comment out the axis() calls as before. Save the function in a file and source() it into your session or copy and paste the function in. Then use to your heart's desire.

A third alternative, is to work out how error.bars() does it's base plotting - look at the code. Recreate that plot yourself, without axes, then call error.bars() with add = TRUE.

like image 136
Gavin Simpson Avatar answered Jun 27 '26 19:06

Gavin Simpson


As in the comment, you can edit the source code. Easiest way is probably to use 'fix':

eb = fix(error.bars)

should pop up an editor. Change the axis(1,.etc.) calls to axis(3,.etc.). Then you have a new function called eb() that works like error.bars.

You might want to tweak some other things too, like the title which stomps on the axes when placed at the top.

like image 36
Spacedman Avatar answered Jun 27 '26 18:06

Spacedman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!