12

I am using using plot(), matplot() and ggplot(). I am guessing the answer will be the same for all of them.

I want to specify the thickness of the y-axis, the x-axis, and the other two lines that constitute the box around the plot, all separately. How can I achieve that?

Thanks in advance.

Note: I have already read this - Increasing the thickness of box lines in an R boxplot? , but I want to change the thickness of the individual axis lines separately.

Community
  • 1
  • 1
Soumendra
  • 1,174
  • 1
  • 15
  • 28

4 Answers4

14

You mean list this?

plot(sample(100))

axis(side = 1, lwd = 2)
axis(side = 2, lwd = 2)

enter image description here

CHP
  • 16,981
  • 4
  • 38
  • 57
1

See ?axis and use it along with plot(). Here is a nice tutorial.

fdetsch
  • 5,239
  • 3
  • 30
  • 58
1

Well, I could make it by using the command at = x and describing the distance from 0 to the end of the axis, either by your desired scale, counts or length (I just have no clue whether the length is in inches, cm, etc. I tried numbers until I got the right lenght). Hope it helps!

One thing I did not manage was to input breaks to the axis 2, so I had to type the whole scale. As I have lots of plots which differs in scales, this will become boring at some stage. Any idea how to break scales using "axis" command?

Cheers, Romário

axis(1, at = 0:15, lwd=2, lwd.tick=0, lab=F)
axis(2, at = c(0, 2000, 4000, 6000, 8000, 10000, 12000), lab=c(0, 2000, 4000, 6000, 8000, 10000, 12000), lwd=2, lwd.tick=1, tck=0.01, las=1, cex=0.5)

PS: Couldn't post the final plot. I need at least 10 reputation to post images.

dpel
  • 1,954
  • 1
  • 21
  • 31
Melo Jrf
  • 29
  • 5
0

For ggplot use the following as a statement in the ggplot set of comments with + before and maybe after depending on what else you need. This is for the x-axis, and the equivalent is axis.line.y.left= for the y-axis.

theme(axis.line.x.bottom=element_line(size=1))