5

I have created a histogram of a variable in my model in NetLogo 5.0.5, but the histogram keeps showing a line rather than bars I want. I'm using the set-histogram-num-bars n in the pot set up areas, but nothing is changing. In the histogram example in the models library I also get a line rather than bars, even when I copy the settings from the previous histogram plot.

In my model the turtles have their own variable reliability, which ranges from 0 to 10 as a continuous function. I have 2000 turtles. In the plot areas I've added the following:

;;plot setup commands
set-plot-x range 0 10
set-plot-y-range 0 800                       
set-histogram-num-bars 10

;;plot pens
histogram [reliability] of turtles

Can anyone see where i might be going wrong?

desertnaut
  • 57,590
  • 26
  • 140
  • 166
Simon Bush
  • 407
  • 2
  • 9

2 Answers2

7

I believe that you must set the plot pen mode to bar mode, which is mode 1.

set-plot-pen-mode 1
Charles
  • 3,888
  • 11
  • 13
  • This seems like a good guess at what the problem might be. Note, though, that normally you set the plot pen mode simply by editing the plot, and then editing the pen. It isn't normally necessary to set the mode using code. – Seth Tisue Jun 18 '14 at 22:04
  • Added set-plot-pen-mode 1 to the plot setup section. Worked a treat. Why is this not needed in the histogram code example though? – Simon Bush Jun 19 '14 at 06:14
  • 2
    Because, as Seth suggested, the bar mode is set in that example by editing the "turtles" plot pen, by pressing the "pencil" icon. Mode there is set to "bar". – Charles Jun 20 '14 at 12:13
  • I found also that I had not changed the pen type in the advanced pen options section. – Simon Bush Jul 08 '14 at 01:38
3

Or you can change it in editing mode (pencil symbol) in GUI interface - click on Edit (pencil) and then change mode "Line" to Mode "Bar". (printscreen from Histogram exemple)

enter image description here

maycca
  • 3,848
  • 5
  • 36
  • 67