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

Axis category ordering - adds feature #189 #419

Merged
merged 9 commits into from
Apr 18, 2016

Conversation

monfera
Copy link
Contributor

@monfera monfera commented Apr 13, 2016

CR: #189

Original PR within downstream repo, with comments and historical commits: monfera#1

Implement axis attributes categorymode and categorylist to allow control of axis tick ordering independent of the trace order. See the attribute documentation, added Jasmine test cases and image tests for the API addition.

@monfera monfera changed the title 189 Axis category ordering - squashed Axis category ordering - adds feature #189 Apr 13, 2016
categorymode: {
valType: 'enumerated',
values: [
'trace', 'category ascending', 'category descending', 'array'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cldougl @chriddyp does ⏫ look ok to you?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 for me

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should include truncated versions of those values as well e.g. 'cat asc', 'cat des' ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest avoiding muti-word strings. Maybe just ascending and descending?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for me just ascending`descendingdoesn't have a clear relation to _alpha_numeric ordering. I definitely understand the aversion to multi-word strings, but I would vote for more description thanascending\descending`

plus if 'value ascending' \ 'value descending' are going to be implemented eventually

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but I gotta say, catergoryorder doesn't sound bad at all.

Copy link
Member

@chriddyp chriddyp Apr 14, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can add them as labels to the axes (currently described as ticktext) or use them as data (currently described as x). Given that the axis.type is category, one might think that categories is how you would add data to that axis.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and maybe categoryarray instead of categorylist

@chriddyp we're already using the value 'array' for tickmode.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can add them as labels to the axes

More like: categories are added automatically. Categories have no effect on ticktext.

Copy link
Contributor

@etpinard etpinard Apr 14, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that the axis.type is category, one might think that categories is how you would add data to that axis.

Great point 👍

That's why I'm thinking that categoryorder might be the winner here.

@etpinard
Copy link
Contributor

@monfera we should also add one scatter3d test (similar to http://codepen.io/etpinard/pen/VaXmPx) showcasing one categorymode setting.

@etpinard
Copy link
Contributor

etpinard commented Apr 14, 2016

@monfera

@chriddyp and I settled on categoryorder in place of categorymode and categoryarray in place of categorylist,

@monfera @cldougl @mdtusz any objections?

@cldougl
Copy link
Member

cldougl commented Apr 14, 2016

👍 all good for me

@monfera
Copy link
Contributor Author

monfera commented Apr 15, 2016

@etpinard @chriddyp categoryorder and categoryarray are fine.

@etpinard
Copy link
Contributor

@monfera Awesome work. 🍻

@etpinard etpinard merged commit 4065112 into plotly:master Apr 18, 2016
@bmcole
Copy link

bmcole commented Jun 13, 2016

Can someone provide an example (or point me to one) on how to use categoryorder = 'array' and categoryarray in order to manually specify the ordering of a categorical feature for plotting purposes with plotly? I can't find any online and all of my attempts in R have not worked. Any help would be appreciated

@monfera
Copy link
Contributor Author

monfera commented Jun 13, 2016

@bmcole I suppose you looked into the examples in the PR, but on the off chance not yet, just search for 'test' here, below the images: https://github.com/plotly/plotly.js/pull/419/files

@bmcole
Copy link

bmcole commented Jun 13, 2016

I found the test examples with json code, but am still unsure of how to
implement in R. here's my code that isn't working (it plots the order as
Friday, Monday, Saturday, Sunday, Thursday, Tuesday, Wednesday which is
undesired.

xform <- list(title = "Weekday",
               b = 150,
               tickangle=270,
               ticklen = 5,
               tickwidth = 2,
               categoryorder = "array",
               categoryarray = c("Sunday" , "Monday",

"Tuesday","Wednesday","Thursday", "Friday", "Saturday"))

yform <- list( title = "Number of Crimes",
               ticklen = 5,
               tickwidth = 2)

# line + scatter plot
plot_ly(weekdata, x = DayOfWeek, y = totalCrimes, type = "scatter",
        mode = "markers+lines", color = Category)  %>%

layout(xaxis=xform, yaxis=yform)

On Mon, Jun 13, 2016 at 5:28 PM, Robert Monfera notifications@github.com
wrote:

@bmcole https://github.com/bmcole I suppose you looked into the
examples in the PR, but on the off chance not yet, just search for 'test'
here, below the images: https://github.com/plotly/plotly.js/pull/419/files


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#419 (comment), or mute
the thread
https://github.com/notifications/unsubscribe/ANlA2U_rLgmFJLDwCc7mR6Xk6W7eUXyJks5qLcuSgaJpZM4IGL7W
.

@monfera
Copy link
Contributor Author

monfera commented Jun 13, 2016

@bmcole I wonder if it's a date type related mismatch. Have you had any success with simple (non-date) strings or e.g. integer values? I don't have R in front of me right now but it may be a thing to try.

@etpinard
Copy link
Contributor

cc @cpsievert @timelyportfolio

@cpsievert
Copy link

cpsievert commented Jun 14, 2016

@bmcole categoryorder was added in v1.10.2 of plotly.js and the R package is currently using v1.10.1. I'll update our plotly.js version ASAP.

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

Successfully merging this pull request may close these issues.

7 participants