4

I'm trying to make a bar plot with the axis breaking on 0-25-50-75-100 but I can't find the parameter to do that. My syntax is from the likert package:

plot(x, ordered=FALSE, group.order=names(data))

This displays a break on 0-50-100. The plot must be a tornado chart, which is what likert package offers with the above function. See an example:

enter image description here

In this other example you can see what I want to get:

enter image description here

Mikelowski
  • 195
  • 3
  • 16
  • It's not clear what you are trying to do. Do you want to make a histogram? Usually, we think of breaks as going w/ histograms. If you only have 1 variable (`x`), it is not clear how you would make a bar plot--what would you want the height of the bars to me, the mean of your `x` values b/t 0-25? Would that even make any sense? – gung - Reinstate Monica Feb 11 '14 at 18:44
  • More a tornado chart than a histogram. If you look the likert package link you'll immediately see what I try to do. Basically, a stacked bar plot with several items and classic likert categories. Problem is, by default the plot comes with breaks on values 0, 50 and 100. I'd like to choose the breaks. – Mikelowski Feb 11 '14 at 19:34
  • Thanks for the edit. It might also help if you could add some example data. It appears that you want to change the x-axis ticks & their labels, is that correct? (I would not refer to those as "breaks".) – gung - Reinstate Monica Feb 11 '14 at 19:42
  • Yes, that's right. I called it breaks because I knew about the breaks function in the histogram function, but you're right. Now I put an example. – Mikelowski Feb 11 '14 at 19:50

1 Answers1

0

I don't have the likert package. The plotting functions appear to be new methods built on top of R's standard plot() function. As such, you should be able to use R's standard graphical parameters. The key argument is xaxp=, which allows you to specify the placement of the tick marks on the x-axis. Here is an example using hist():

  # this will allow you to run my code & get the same results
set.seed(1)    
  # here I generate some data
x <- runif(100, min=0, max=100)  
  # this makes the histogram, the xaxp argument does what you're after
hist(x, breaks=c(0,25,50,75,100), xaxp=c(0,100,4))  

enter image description here

For more information, see: R, change the spacing of tick marks on the axis of a plot?

Community
  • 1
  • 1
gung - Reinstate Monica
  • 11,583
  • 7
  • 60
  • 79
  • 1
    I only deleted the previous version of the figure, @Mike. You should be able to adapt the code from the new version. Let me know if this doesn't work for you. – gung - Reinstate Monica Feb 11 '14 at 20:14
  • Sadly, it displays this: Error: unexpected symbol in "plot(x, ordered=FALSE, group.order=names(data) breaks" – Mikelowski Feb 11 '14 at 20:36