Home > Enterprise >  How to show all 4 borders in R `hist()`?
How to show all 4 borders in R `hist()`?

Time:09-19

R hist() shows only the bottom and left border by default. In plot(), we can use frame.border=TRUE to show all 4 borders. In hist, not so. Is there a way to show all 4 borders in hist()?

CodePudding user response:

Just call box() to enclose the plot figure you just created in a "box" on all four sides as you desire.

Code

> hist(mtcars$disp)
> box()

Output

enter image description here

Details

Per help(box):

Draw a Box around a Plot

Description:

     This function draws a box around the current plot in the given
     color and linetype.  The ‘bty’ parameter determines the type of
     box drawn.  See ‘par’ for details.
  •  Tags:  
  • r
  • Related