title: Netlogo: Plot relative-frequency
body: <p>Yes, a similar question has been asked here <a href="https://stackoverflow.com/questions/37051972/netlogo-histogram-relative-frequency">NetLogo: histogram relative frequency</a>, but as far as I know, no answer has been given. Am I allowed to re-ask it again? I would have added a comment under the question but I am not allowed to. </p>
  
  <p>I would like to plot the relative frequency of patches with a specific colour against increasing distance from a turtle. What I've tried so far:</p>
  
  <pre><code>ask turtle [
    set-current-plot "plot 1"
    set-plot-y-range 0 1
    set-plot-pen-mode 1
    histogram [distance myself] of patches with [pcolor = red]]
  </code></pre>
  
  <p>This only gives me the absolute frequency. I want to plot the relative frequency of each patch colour against increasing distance from a turtle. So at distance = 1 away from turtle, how many patches out of the total no. of patches are red. I tried adding a </p>
  
  <pre><code>histogram [distance myself ] of patches with [ ] / count patches with [distance myself = 1] ; when x-axis = 1, and so for increasing x 
  </code></pre>
  
  <p>but there were certain syntax problems since the primitive histogram expects a list. I would think there is a simpler way to set the y-axis to (absolute occurrences/total no. of patches at distance x) so I looked through the Netlogo dictionary but could not find something that sets up the y-axis under plot set-up commands. </p>
  
  <p>Would appreciate any advice with regards to this issue! Thank you for your time. </p>