Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
LaCuneta opened this issue Feb 9, 2021 · 1 comment
Open

Comments

@LaCuneta
Copy link
Contributor

LaCuneta commented Feb 9, 2021

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.

@LaCuneta
Copy link
Contributor Author

I just stumbled on a side-effect of this - because set-plot-pen-color recolors all points, if you've used plot-pen-up to skip drawing some points, then once you change the pen color those previously invisible lines will become visible. This can be seen with the Decay model from the library. A workaround is, as above, use a different pen for each color to avoid changing the pen color at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant