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

Using group + color produces incorrect plot #418

Closed
alyst opened this issue Jan 21, 2016 · 3 comments
Closed

Using group + color produces incorrect plot #418

alyst opened this issue Jan 21, 2016 · 3 comments

Comments

@alyst
Copy link
Contributor

alyst commented Jan 21, 2016

plotly incorrectly draws lines scatter (and scatter3d) plots.

Consider the following minimal example:

df = data.frame(x=c(1,2,3,4,5,6),
           y=c(1,1,2,2,3,3),
           t=c("A","A","B","B","A","A"))

plot_ly(df, type="scatter", x=x, y=y, color=t, group=y, mode="lines")

The output is:
image

In the correct plots only the horizontal segments colored according to t column are expected; also no 1,2,3 entries in the legend, A and B sorted either alphabetically or by their appearance in the data frame.

@cpsievert cpsievert changed the title Incorrect lines scatter plot if group is used Using group + color produces incorrect plot Jan 21, 2016
@cpsievert
Copy link
Collaborator

I have a note of this here as well #381

I hope to get to this soon...thanks for the minimal example!

@alyst
Copy link
Contributor Author

alyst commented Jan 21, 2016

@cpsievert Yes, it's the same as #381 + an additional issue of drawing "parasitic line" (2,1) - (5,3).

alyst added a commit to alyst/plotly that referenced this issue Feb 22, 2016
- convert the list of traces into 'plotly_traces' class
  that also has 'data' attribute holding unmodified data
- make trace the 'plotly_trace' object that also have an 'indices'
  property referencing rows of the original data
- replace `tracify()` by `subdivide_traces()` that correctly subdivides
  the current set of traces based on the provided property and maintains
  the internals
alyst added a commit to alyst/plotly that referenced this issue Feb 23, 2016
- convert the list of traces into 'plotly_traces' class
  that also has 'data' attribute holding unmodified data
- make trace the 'plotly_trace' object that also have an 'indices'
  property referencing rows of the original data
- replace `tracify()` by `subdivide_traces()` that correctly subdivides
  the current set of traces based on the provided property and maintains
  the internals
alyst added a commit to alyst/plotly that referenced this issue Feb 23, 2016
- add 'indices' property to the trace to reference the indices of
  the data elements associated with the trace
- replace `tracify()` by `subdivide_traces()` that correctly subdivides
  the current set of traces based on the given property
alyst added a commit to alyst/plotly that referenced this issue May 18, 2016
- separate the grouping of data into traces (this now done
  with the help of dplyr::group_by()) from traces creating and
  applying styles(brushes) to each resulting trace
- replace `tracify()` by `generate_traces()`,
  replace `colorize/symbolize()` by `color/symbol_brush()`
- import dplyr
alyst added a commit to alyst/plotly that referenced this issue May 18, 2016
- separate the grouping of data into traces (this now done
  with the help of dplyr::group_by()) from traces creating and
  applying styles(brushes) to each resulting trace
- replace `tracify()` by `generate_traces()`,
  replace `colorize/symbolize()` by `color/symbol_brush()`
- import dplyr
alyst added a commit to alyst/plotly that referenced this issue May 19, 2016
- separate the grouping of data into traces (this now done
  with the help of dplyr::group_by()) from traces creating and
  applying styles(brushes) to each resulting trace
- replace `tracify()` by `generate_traces()`,
  replace `colorize/symbolize()` by `color/symbol_brush()`
- import dplyr
alyst added a commit to alyst/plotly that referenced this issue May 19, 2016
- separate the grouping of data into traces (this now done
  with the help of dplyr::group_by()) from traces creating and
  applying styles(brushes) to each resulting trace
- replace `tracify()` by `generate_traces()`,
  replace `colorize/symbolize()` by `color/symbol_brush()`
- import dplyr
alyst added a commit to alyst/plotly that referenced this issue May 19, 2016
- separate the grouping of data into traces (this now done
  with the help of dplyr::group_by()) from traces creating and
  applying styles(brushes) to each resulting trace
- replace `tracify()` by `generate_traces()`,
  replace `colorize/symbolize()` by `color/symbol_brush()`
- import dplyr
alyst added a commit to alyst/plotly that referenced this issue May 28, 2016
- separate the grouping of data into traces (this now done
  with the help of dplyr::group_by()) from traces creating and
  applying styles(brushes) to each resulting trace
- replace `tracify()` by `generate_traces()`,
  replace `colorize/symbolize()` by `color/symbol_brush()`
- import dplyr
alyst added a commit to alyst/plotly that referenced this issue May 28, 2016
- separate the grouping of data into traces (this now done
  with the help of dplyr::group_by()) from traces creating and
  applying styles(brushes) to each resulting trace
- replace `tracify()` by `generate_traces()`,
  replace `colorize/symbolize()` by `color/symbol_brush()`
- import dplyr
alyst added a commit to alyst/plotly that referenced this issue Jun 2, 2016
- separate the grouping of data into traces (this now done
  with the help of dplyr::group_by()) from traces creating and
  applying styles(brushes) to each resulting trace
- replace `tracify()` by `generate_traces()`,
  replace `colorize/symbolize()` by `color/symbol_brush()`
- import dplyr
alyst added a commit to alyst/plotly that referenced this issue Jun 2, 2016
- separate the grouping of data into traces (this now done
  with the help of dplyr::group_by()) from traces creating and
  applying styles(brushes) to each resulting trace
- replace `tracify()` by `generate_traces()`,
  replace `colorize/symbolize()` by `color/symbol_brush()`
- import dplyr
- update "group" tests
@cpsievert
Copy link
Collaborator

Closed via d2bf2a1. This is now the official way to do this:

df = data.frame(x=c(1,2,3,4,5,6),
           y=c(1,1,2,2,3,3),
           t=c("A","A","B","B","A","A"))

df %>% group_by(y) %>% plot_ly(x = ~x, y = ~y, color = ~t) %>% add_lines()

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

2 participants