[SOLVED] How to show all 4 borders in R `hist()`?

Issue

This Content is from Stack Overflow. Question asked by user0

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()?



Solution

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.


This Question was asked in StackOverflow by user0 and Answered by Dirk Eddelbuettel It is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?