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

Bateson plot (combining geom_turn, geom_wave and geom_text) #55

Open
mdingemanse opened this issue Jan 19, 2024 · 1 comment
Open

Bateson plot (combining geom_turn, geom_wave and geom_text) #55

mdingemanse opened this issue Jan 19, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@mdingemanse
Copy link
Contributor

Something like geom_wave() (#46) would also be useful as part of a visualization that I will call the Bateson plot in recognition of Mary Catherin Bateson:

image-91-1024x538

This would be geom_turn() laid out horizontally, with geom_wave() above it, and with the utterance column mapped to a geom_text() (like here), but at a 45 degree angle.

Pseudocode:

data |>
  ggplot(aes(xmin=begin,xmax=end) +
  geom_turn(aes(y=participant),height=0.8) +
  geom_wav(y=???) +
  geom_text(aes(x=begin,y=???,color=participant)

The slightly tricky thing here would be that only geom_turn() would use stacked coordinates, and the other two geoms would map onto an area outside those coordinates. I'm not sure how to set or determine that y most elegantly, hence the ??? in the pseudocode above. Could look into the placement logic of ggtext::geom_repel because they allow you to do similar things.

@mdingemanse mdingemanse added the enhancement New feature or request label Aug 19, 2024
@mdingemanse
Copy link
Contributor Author

mdingemanse commented Aug 26, 2024

Just to note that a rudimentary version of this kind of plot (without waveform) is already possible with talkr 0.1:

conv <- ifadv::ifadv

conv |>
  filter(source == "/dutch2/DVA12S",
         end < 30000 ) |>
  ggplot(aes(x = end, y = participant)) +
  geom_turn(aes(
    begin = begin,
    end = end,
    fill = participant),
    height=0.8) +
  geom_text(aes(label=utterance_raw,
                x=begin,
                colour=participant),
            y = 3,
            angle = 45,
            hjust=0) +
  scale_fill_brewer(palette = "Dark2") +
  scale_colour_brewer(palette = "Dark2") +
  xlab("Time (ms)") +
  ylab("") +
  coord_cartesian(ylim=c(1,10)) +
  theme_turnPlot() + theme(legend.position="none")

image

Though with considerable downsides:

  • have to set ylim() manually to make text appear above participants
  • have to determine height of ylim() manually to avoid text being clipped
  • no dealing with overlap

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

No branches or pull requests

1 participant