Dynamic Axis Labels (Ticks) Misalignment with Data Points and Rangeslider
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 35/100
- Tipo de issue
- Bug
- Clareza
- Razoavelmente clara
- Status de atividade
- Estagnada
- Stack de tecnologia
- r
- Domínio
- data-visualization
Direção de pesquisa
Comece com o exemplo reproduzível em R usando plotly, lubridate, dplyr, tickvals e o x-axis rangeslider. Investigue como valores fixos de ticks semanais interagem com o ajuste de ticks orientado pelo zoom; considera-se concluído quando os rótulos semanais baseados na segunda-feira permanecem corretos enquanto o zoom altera o intervalo para evitar a sobreposição excessiva.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Description:
In my Plotly chart with a rangeslider, I'm facing a dilemma with axis labels (ticks). Without using tickvals, the chart incorrectly displays Sunday as the start of the week. When using tickvals to correct this, the axis labels don't dynamically adjust when zooming out, leading to overcrowding.
Expected Behavior:
- The x-axis should consistently display Monday as the start of each week.
- When zooming out, the axis should dynamically adjust to a coarser interval (e.g., every month, every quarter, or every year) to maintain readability.
- The rangeslider should allow smooth navigation while preserving appropriate tick density at different zoom levels.
Actual Behavior:
- Without
tickvals:
-
The chart incorrectly uses Sunday as the start of the week.
-
Zooming functions work as expected, with appropriate tick density at different zoom levels.
- With
tickvals:
-
The chart correctly displays Monday as the start of the week.
-
When zooming out, the axis doesn't adjust to a more appropriate interval, resulting in overcrowded and illegible labels.
Reproducible Example:
library(shiny)
library(plotly)
library(lubridate)
library(dplyr)
# Example data
data <- data.frame(
date = seq(as.Date("2024-01-01"), Sys.Date(), by = "day"),
value = runif(length(seq(as.Date("2024-01-01"), Sys.Date(), by = "day")), 10, 100)
)
# Aggregate data by week
data_weekly <- data %>%
mutate(week = floor_date(date, unit = "week", week_start = 1)) %>%
group_by(week) %>%
summarise(value = sum(value))
# Create a plot with the week start as the x-axis
fig <- plot_ly(data = data_weekly,
x = ~week,
y = ~value,
type = 'bar') %>%
layout(xaxis = list(
range = c(floor_date(max(data$date) - months(3) + days(4),
unit = "week", week_start = 1), # Set the x-axis range starting 3 months before the latest date
max(data$date + days(4))), # Extend the range to the maximum date (with 4 extra days for buffer)
tickvals = data_weekly$week # Use the start of each week as the ticks on the x-axis
)
)
fig %>%
config(displayModeBar = FALSE) %>%
layout(xaxis = list(rangeslider = list(visible = TRUE))) # Add a range slider for the x-axis
Additional Notes:
- The issue arises from the need to use
tickvalsto enforce Monday as the week start, which then prevents Plotly's automatic tick adjustment. - An ideal solution would combine correct week start representation (Monday) with dynamic tick adjustment when zooming.
System info
R version: 4.3.3 (2024-02-29)
Plotly version: 4.10.4
Operating System: Linux 5.15.173.1-1.cm2
- Linguagem predominante
- R
- Estrelas
- 2.7k
- Forks
- 640
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Sem modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de plotly/plotly.R
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 35/100
-
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 68/100
-
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 72/100
-
save_image ErrorAberta
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 52/100
Todas as issues de plotly/plotly.R
Issues semelhantes
-
OG improvementAbertabug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
rladies/rladies.github.io#620 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
rfordatascience/tidytuesday#1089 ·
-
Component: R Type: bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
apache/arrow#51695 · 1 comentário ·
Mantenedores costumam responder em até 2 dias