Unable to see x axis labels completely
未关闭
还没有人认领这个 Issue。
- 主要语言
- R
- 星标
- 2.7k
- 派生
- 641
- PR 合并指标
- 30 天内没有已合并 PR
描述
Unable to show all the months , Its skipping one month after the other, the months are present but not visible until you zoom in.
What needs to be done here
` output$TP1 <- renderPlotly({
df_plot <- filtered_data()
# Ensure the 'date' column is of Date type
df_plot$date <- as.Date(df_plot$date)
# Set font size
base_size <- 15
# Custom label function to split month and year onto separate lines
library(scales)
custom_date_label <- function(x) {
format(x, "%b\n%Y")
}
# Plot 1: Month vs Interest Coverage Ratio
plot1 <- ggplot(df_plot, aes(x = date, y = interest_coverage_ratio_ttm, group = 1)) +
geom_line(color = "red", size = 1) +
labs(title = "Month vs Interest Coverage Ratio", x = "Date", y = "Interest Coverage Ratio") +
theme_minimal(base_size = base_size) +
theme(
axis.text.x = element_text(size = 8, angle = 0, hjust = 0.5), # Reduce size of x-axis labels
panel.spacing = unit(2, "lines")
) +
scale_x_date(labels = custom_date_label, date_breaks = "1 month") # Custom label formatting
# Convert ggplot objects to plotly objects for interactive tooltips
ggplotly(plot1, dynamicTicks = TRUE) %>%
layout(
xaxis = list(
tickformat = "%b\n%Y" # Format the tooltips as month and year on separate lines
)
)
})`
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
使用提供的 renderPlotly 示例重现该报告,重点检查 ggplotly(plot1) 和 layout 的 xaxis 设置。检查 scale_x_date(date_breaks = "1 month") 和 dynamicTicks 如何影响渲染后的 x 轴标签。当预期的月份标签在正常缩放级别下可见,同时交互式图表仍可使用时,即视为完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- r
- 领域
- data-visualization
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 30/100