jbengler / tidyplots

Tidy Plots for Scientific Papers
https://jbengler.github.io/tidyplots/
Other
291 stars 3 forks source link

Default `dodge_width = 0.8` causes unexpected shifts in line graphs #13

Open jbengler opened 1 day ago

jbengler commented 1 day ago

The default dodge_width of 0.8 in the tidyplot() function leads to unexpected results in line graphs. Here, a dodge_width of 0 would be more appropriate.

Default behavior

Bildschirmfoto 2024-11-29 um 14 33 23

Expected behavior

Bildschirmfoto 2024-11-29 um 14 43 07
jbengler commented 1 day ago

One potential solution could be to implement a heuristic within tidyplot() that estimates the optimal dodge_width.

Pseudocode example:

if(is_discrete(x_axis_variable) || is_discrete(y_axis_variable)) {
   dodge_width = 0.8
} else {
   dodge_width = 0
}