How do I specify axis thickness in a plot? (in R)

2019-06-16 07:46发布

问题:

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.

回答1:

You mean list this?

plot(sample(100))

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



回答2:

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



回答3:

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.



标签: r plot ggplot2