0

Any ideas on how to change the width of barplot bars with the function bargraph.CI() from the sciplot pacakge? I have a very simple barplot with 2 bars, and can't figure out how to slim them down. I've tried the argument, width, from the barplot() function, but without any success. Thanks for your help!

thelatemail
  • 91,185
  • 12
  • 128
  • 188
user2096647
  • 99
  • 1
  • 9

2 Answers2

1

Try adjusting the space= argument. As the bar widths specified through width= are all relative, if you just specify one value they will never change size:

E.g.: both of the following give the same result:

bargraph.CI(x.factor = dose, response = len, data = ToothGrowth, width=1)
bargraph.CI(x.factor = dose, response = len, data = ToothGrowth, width=1000) 

enter image description here

Adjusting space= however, pushes the bars apart and indirectly affects their width:

bargraph.CI(x.factor = dose, response = len, data = ToothGrowth, space=1)

enter image description here

bargraph.CI(x.factor = dose, response = len, data = ToothGrowth, space=5)

enter image description here

To ultimately reduce the size of plots though, you might also look at pushing in the margins or reducing the size of the plotting device. See this previous question:

reducing the space between plotted points in plot( x, y) type=n

Then try something like:

par(mar=c(5.1,8,2.1,8))
bargraph.CI(x.factor = dose, response = len, data = ToothGrowth, space=c(1))

enter image description here

Community
  • 1
  • 1
thelatemail
  • 91,185
  • 12
  • 128
  • 188
0
barplot(1:3, width=1:3)

Works --> maybe give us your code to see what's wrong?

Hillary Sanders
  • 5,778
  • 10
  • 33
  • 50