NetLogo / NetLogo/SimpleR-Extension

Incompatible with `ggplot2` or is it a plot device issue I don't understand?

Open
#8 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Scala
Stars
4
Forks
1
PR merge metrics
No merged PRs in 30d

Description

The following model code

extensions [ sr ]

to setup
  clear-all
  sr:setup
  sr:run "library(ggplot2)"
end

to ggplot
  sr:set-plot-device
  (sr:run
    "df <- data.frame(x = rnorm(30), y = rnorm(30))"
    "ggplot(df) + "
    "  geom_point(aes(x = x, y = y))"
  )
  sr:run "ggsave('~/Downloads/test.png')"
  user-message "Plot will close when you close this dialog."
  sr:run "dev.off()"
end  

fails to show a plot in the on-screen plot window, although the expected ggplot shows up as the requested PNG file:

test

The user-message is my way to cleanly close plot devices - so don't worry about that part.

Is this some subtlety or R plotting, specifically in relation to ggplot that I don't understand? Or is it a problem with the Simple R extension? How do I do I to get an on-screen ggplot to show up?

Contributor guide

No contributing guide indexed for this repository

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 by reproducing the model using sr:set-plot-device, sr:run, ggplot, ggsave, and dev.off(), comparing the on-screen plot window with the generated PNG. Investigate whether the Simple R extension supports displaying the ggplot device and define done as an on-screen ggplot appearing while the existing PNG behavior remains correct.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data-visualization
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.