Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Netlogo how to add a legend?

Tags:

netlogo

I started to use netlogo and I would like to add a legend to the model.

I didn't found any way to do it.

Is there some standard way to do it?

I thought about adding image to the interface but I didn't find any way to do it. For example I want that user will know is the green particle means and what the read means

enter image description here

like image 859
arn Avatar asked Jul 13 '18 15:07

arn


2 Answers

You can use the bitmap extension. Here is a result example:

enter image description here

the code:

extensions [bitmap]
....
let legend bitmap:import "symbology.png"
bitmap:copy-to-drawing legend 40 275

"symbology.png" is the name of the graphics file, and 40 275 are the location coordinates. You will have to test several image sizes and coordinates until it suits your needs.

like image 194
Javier Sandoval Avatar answered Oct 31 '22 17:10

Javier Sandoval


I don't know a great way to do this, the closest I've ever been able to get is to use a combination of specific plot set-ups and note widgets. As an example, start out with a plot called "Legend" with this setup to start:

enter image description here

Now size it to look something like this:

enter image description here

Now make a procedure to 'draw' legend guides (some detail in comments):

to setup-legend-plot
  ; Choose correct plot
  set-current-plot "Legend"
  clear-plot

  ; Define starting y and color
  let starts [ [ 10 green ] [ 7 red ] [ 4 blue ] ]

  ; for each value in starts
  foreach starts [ start ->
    ; make a range of values starting at the initial
    ; y value from 'starts'
    let s first start
    let f s - 2.5 
    let ran ( range s f -0.01 )
    create-temporary-plot-pen "temp"
    set-plot-pen-color last start

    ; draw lines at each y value to make it
    ; look like a solid drawing
    foreach ran [ y ->
      plot-pen-up
      plotxy 1 y
      plot-pen-down
      plotxy 2 y
    ]   
  ]
end

Calling setup-legend-plot should now make your "Legend" plot look like

enter image description here

Now you can make some note widgets and layer them over the blank space in the plot:

enter image description here

enter image description here

Not exactly straightforward, but definitely the closest I've found.

Edit:

"Closest I've found for building a legend within NetLogo." Javier's answer is a far better approach if you can swing it.

like image 3
Luke C Avatar answered Oct 31 '22 19:10

Luke C