NetLogo / NetLogo/Galapagos

`set-plot-pen-color` changes all data points, not future points/lines

Open
#394 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
CoffeeScript
Stars
65
Forks
47
PR merge metrics
No merged PRs in 30d

Description

As Jason described in an old post about this issue, in NetLogo desktop when you use set-plot-pen-color all existing points/lines already on the plot for your pen stay the color they were, and any new points you add will use the new color. In NetLogo Web, all points old and new are changed to the new color you set.

Sample code for a model with a single plot named test:

to plot-pen-color-change-fail
  clear-all
  set-current-plot "test"
  create-temporary-plot-pen "ziggy pen"
  set-plot-pen-color blue
  plotxy 0 0
  plotxy 1 5
  set-plot-pen-color red
  plotxy 2 7
  plotxy 3 11
end

The result will be a red line instead of a half blue, half red line.

Quoting Jason:

When I initially implemented plotting, I tried to accommodate for NetLogo's quirky ability to have a multicolored plot pen trail, but telling the plotting library to handle that (incredibly atypical) case made plotting performance absolutely awful, and it only updated the plot marker dots, not the lines. I couldn't really find any good plotting library that supported lines that would partially changed colors, so it seems to me that that (anti-)feature will just go unsupported in NetLogo Web.

I wanted to open this issue just so the difference had it's own place to be tracked in case we ever decide it's worth putting time into. I have encountered at least one user model that relied on the ability to change the plot pen color in the middle of the data set. The workaround is also given by Jason:

A workaround for anyone who finds the old behavior absolutely essential to their use case: Create a new pen for each new color.

And that should work for most use cases, but if someone wants to use the plot legend with a single entry for the pen, creating more pens per color will not work for them.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the supplied NetLogo sample model and reproduce the color change in the test plot. The work is complete when points and lines added before the color change retain their original color, later points and lines use the new color, and the plot legend still has one pen entry.

Written by the indexing model from the issue text.

Assessment

Tech stack
coffeescript
Domain
data-visualization
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.