-
Notifications
You must be signed in to change notification settings - Fork 1
Fix broken coordinate/mark examples, dark themes, add missing marks, add padding_of() #5
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
Changes from 11 commits
ca8dc61
5bb5c03
e6e8286
c46688f
8ffb4db
869a92d
bffd9f1
da9b6f4
7f0c72a
4587114
9bbf6c1
ca0f631
2e90ee3
d1ba36c
069a0b6
0bd2a54
1259189
fd78572
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -86,6 +86,54 @@ g2(df, x = 'x', y = 'y', color = 'x') |> | |
| coordinate('radial', innerRadius = 0.3) | ||
| ``` | ||
|
|
||
| ## Parallel | ||
|
|
||
| Maps multiple numeric variables to parallel axes. Use a `position` | ||
| encoding (a character vector of column names) instead of `x`/`y`. | ||
|
|
||
| ```{r} | ||
| g2(iris, position = c('Sepal.Length', 'Sepal.Width', | ||
| 'Petal.Length', 'Petal.Width'), color = 'Species') |> | ||
| mark_line() |> | ||
| coordinate('parallel') |> | ||
| legend_of('color', position = 'bottom') | ||
| ``` | ||
|
|
||
| ## Radar | ||
|
|
||
| Displays data on radial axes emanating from a center point. A radar chart | ||
| is a line or area chart in polar coordinates. Use long-format data with | ||
| `x` (category), `y` (value), and `color` (series) encodings. All values | ||
| should be on the same scale (e.g., 0--100). | ||
|
|
||
| ```{r} | ||
| df_radar = data.frame( | ||
| item = rep(c('Design', 'Dev', 'Marketing', 'Sales', 'Support'), 2), | ||
| score = c(80, 90, 65, 75, 85, 60, 70, 85, 80, 70), | ||
| team = rep(c('A', 'B'), each = 5) | ||
| ) | ||
| g2(df_radar, x = 'item', y = 'score', color = 'team') |> | ||
| mark_area(style = list(fillOpacity = 0.5)) |> | ||
| mark_line(style = list(lineWidth = 2)) |> | ||
| mark_point() |> | ||
| coordinate('polar') |> | ||
| scale_of('x', padding = 0.5, align = 0) |> | ||
| scale_of('y', domainMin = 0, domainMax = 100) |> | ||
| axis_of('x', grid = TRUE) |> | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i can't see the point of setting grid = TRUE on |
||
| axis_of('y', grid = TRUE, title = FALSE) | ||
| ``` | ||
|
|
||
| ## Helix | ||
|
|
||
| Arranges data along a helix spiral. Works best with `mark_interval()`. | ||
|
|
||
| ```{r} | ||
| df_helix = data.frame(x = paste0('D', 1:50), y = abs(sin(1:50 / 5))) | ||
| g2(df_helix, x = 'x', y = 'y', color = 'y') |> | ||
| mark_interval() |> | ||
| coordinate('helix') | ||
| ``` | ||
|
|
||
| ## Transpose (coord_flip) | ||
|
|
||
| Swap x and y axes, equivalent to ggplot2's `coord_flip()`. This is a | ||
|
|
@@ -98,11 +146,11 @@ g2(df, x = 'x', y = 'y') |> | |
| coord_transpose() | ||
| ``` | ||
|
|
||
| ### Transpose with polar | ||
| ### Transpose with radial | ||
|
|
||
| ```{r} | ||
| g2(df, x = 'x', y = 'y', color = 'x') |> | ||
| mark_interval() |> | ||
| coordinate('polar') |> | ||
| coordinate('radial') |> | ||
| coord_transpose() | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this plot is empty in my browser
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in bffd9f1 —
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i didn't see you changes in bffd9f1
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The helix change was already present in
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there's still NO CHANGE in this example "Transpose with polar"; i'm saying for the 3rd time that this plot is blank; i don't know why you are mentioning the helix example in the comment here
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 9bbf6c1 — the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 9bbf6c1 — apologies for the confusion in previous replies. The "Transpose with polar" section now uses
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i can't wrap my head around this example; what does it mean to transpose the radial coordinate? what does it mean to swap radius and angle? the output plot also looks very odd: the categories A and B are lost does transposing parallel coordinates work? in theory, if transposed, axes will be horizontal and variables will line up vertically; if that works, use parallel as the example instead of radial; if not, get rid of this example and add a note saying that coordinate transposing typically works for catesian only |
||
| ``` | ||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
after you move legend to bottom, the axis labels (Sepal.Length, Sepal.Width, etc) are cut at the top---there's not enough space at the top and the top half of the labels are cut out (please test with browser to make sure everything fits on the plot, nothing cut off)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 7f0c72a — switched from iris (long column names like "Sepal.Length") to mtcars (short names: mpg, disp, hp, wt) and added
paddingTop = 30to leave room for the axis labels at the top.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sigh, you didn't remember my earlier request and now the iris variable names are cut off again: there needs some extra padding at the top but i don't like the method you provided earlier (modifying the g2() object); i want a functional approach, i.e. call a function to set the padding when necessary (or if these settings can be done in the g2() function, that's okay too)