Skip to content

Correcting the order of traces #227

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

Merged
merged 9 commits into from
Dec 10, 2015
Merged

Correcting the order of traces #227

merged 9 commits into from
Dec 10, 2015

Conversation

13bzhang
Copy link
Contributor

@13bzhang 13bzhang commented Jun 5, 2015

This is a pull request to address #225 "Ordering of traces is wrong". This seems to be a problem with a lot of geoms. I am attempting a general first-cut solution (pretty drastic try) by reversing the order of the traces. I want to see how it fares in the plotly test tables.
@cpsievert @chriddyp

@13bzhang
Copy link
Contributor Author

13bzhang commented Jun 5, 2015

Ok, maybe that is too drastic of a change to reverse the order of the traces since a lot of the tests depend on the order of the traces from the old code. Let me think this over.

@13bzhang
Copy link
Contributor Author

13bzhang commented Jun 7, 2015

After realizing how dumb my initial solution was, I decided to reverse the order of the traces only when there is a problem. Right now the two cases where I have detected a problem include:

  1. geom_area
  2. geom_density when position = "stack"

So I added the following lines to trace_generation.R:

  # reverse the traces in the following cases:
  # geom_area
  # geom_density with position = stack
  if (g$geom == "area" | 
        g$geom == "density" & l$position$.super$objname == "stack"){
    traces <- rev(traces)
  } else{
    traces
  }

I also included tests for the two cases that I list above to test-ggplot-area.R and test-ggplot-density.R, respectively. I supect there are other cases of these trace orders out of whack. I will keep looking for them. If you find them, let me know.

@cpsievert @chriddyp

@cpsievert
Copy link
Collaborator

The message below was automatically generated after build https://travis-ci.org/ropensci/plotly/builds/65741975

On TravisCI, commit 495ba85 was successfully merged with 6ff8831 (master) to create 5660dda. A visual testing table comparing 6ff8831 with 5660dda can be found here:
http://ropensci.github.io/plotly-test-table/tables/5660ddaf3015e927d1c47960946647ad13973176/index.html

@13bzhang
Copy link
Contributor Author

13bzhang commented Jun 7, 2015

Hit a snag because the dataset for one of the new tests required the package dplyr. I rewrote the code so the data gets prepped using base R instead. Good ol' aggregate.

@cpsievert
Copy link
Collaborator

The message below was automatically generated after build https://travis-ci.org/ropensci/plotly/builds/65745397

On TravisCI, commit 6afd57e was successfully merged with 6ff8831 (master) to create 2c09c51. A visual testing table comparing 6ff8831 with 2c09c51 can be found here:
http://ropensci.github.io/plotly-test-table/tables/2c09c512f388905bc6cb79815db4581e990aa046/index.html

@cpsievert
Copy link
Collaborator

The message below was automatically generated after build https://travis-ci.org/ropensci/plotly/builds/66496333

On TravisCI, commit a892b5d was successfully merged with 6ff8831 (master) to create e0f0fae. A visual testing table comparing 6ff8831 with e0f0fae can be found here:
http://ropensci.github.io/plotly-test-table/tables/e0f0faeaa8a3165b7620956f3d5c903d0bb8e17b/index.html

@cpsievert
Copy link
Collaborator

@cpsievert
Copy link
Collaborator

^^^ much better than the test table, huh @chriddyp? :)

(that jitter test is a false positive, just ignore it, I'll fix it later)

@cpsievert
Copy link
Collaborator

cpsievert added a commit that referenced this pull request Dec 10, 2015
@cpsievert cpsievert merged commit a4a9a1d into master Dec 10, 2015
@cpsievert cpsievert deleted the baobao-trace_order branch December 11, 2015 21:10
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

Successfully merging this pull request may close these issues.

2 participants