Testing 3D Plot Knitting:

All Verses:

# Remove zero values in quote_count
plot_3d <- verses %>% 
  mutate(quote_count = ifelse(quote_count == 0, NA, quote_count))

# Convert columns to numeric if they are not already
plot_3d$verse <- as.numeric(plot_3d$verse)
plot_3d$quote_count <- as.numeric(plot_3d$quote_count)

fig <- plot_ly(data = plot_3d, x = ~verse, y = ~factor(book_chapter, levels = verse_order), z = ~quote_count) %>% 
  add_markers(size = 5) %>% 
  layout(
    scene = list(
      xaxis = list(title = 'Verse'),
      yaxis = list(title = 'Chapter'),
      zaxis = list(title = 'Quotes'),
      aspectratio = list(x = 1, y = 3, z = 1)
    ),
    xaxis = list(title = 'Overall Book')  # Add x-axis title
  )

fig

All Chapters:

# Plotting the Book Chapter Image in 3D:

chapter_fig <- plot_ly(data = chapters, x = ~chapter, y = ~factor(chapters$book, levels = book_ordering), z = ~quote_count) %>% 
  add_markers(size = 5) %>% 
  layout(
    scene = list(
      xaxis = list(title = 'Chapter'),
      yaxis = list(title = 'Book'),
      zaxis = list(title = 'Quotes'),
      aspectratio = list(x = 1, y = 3, z = 1)
    ),
    xaxis = list(title = 'Overall Book')  # Add x-axis title
  )

chapter_fig