StatisticsNZ / simplevis

Simple visualisation with ggplot2 and leaflet wrappers
https://StatisticsNZ.github.io/simplevis
Other
86 stars 11 forks source link

y_reorder not working in all cases. #437

Closed klee8 closed 2 years ago

klee8 commented 2 years ago

y_reorder works in most cases, but found a few examples where it did not e.g. image

where most of the other plots were correct...

  plot <-  gg_hbar(plot_data,
                   x_var = value,
                   y_var = lake_name,
                   y_labels = ggplot2::waiver(),
                   y_reorder = TRUE,
                   y_title = "",
                   x_title = .xtitle,
                   title = .title,
                   title_wrap = 50,
                   theme = .theme,
                   mobile = .mobile)
davidhodge931 commented 2 years ago

Hi Kate, oh that's weird.

Is x_var a factor? Can you print the plot_data out, or provide some data to illustrate the problem?

klee8 commented 2 years ago

Hey David, sorry for the false alarm. It is happening where the lake has more than one value. It seems to have added them. I'll go sort it out at the data level.

Does it actually make a difference if the y_var is a factor? In the documentation it only says 'categorical variable' not that it needs to be factorised, or maybe those things are synonymous for you?

davidhodge931 commented 2 years ago

Oh great!

No, It shouldn't matter if y_var is a factor. Why just trying to brainstorm why it could be happening

If it says categorical, it means character/factor/logical

klee8 commented 2 years ago

Sweet as. Thanks for your help! From: David Hodge @.> Sent: Tuesday, 29 March 2022 11:30 AM To: StatisticsNZ/simplevis @.> Cc: Kate Lee @.>; State change @.> Subject: Re: [StatisticsNZ/simplevis] y_reorder not working in all cases. (Issue #437)

Oh great!

No, It shouldn't matter if y_var is a factor. Why just trying to brainstorm why it could be happening

If it says categorical, it means character/factor/logical

— Reply to this email directly, view it on GitHubhttps://github.com/StatisticsNZ/simplevis/issues/437#issuecomment-1081216911, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACILHZHNNS2QZRMKJ6OVYGDVCIXHXANCNFSM5R4LRQFQ. You are receiving this because you modified the open/close state.Message ID: @.**@.>>