English 中文(简体)
Geom_hline将不展示,而以前是这样。
原标题:geom_hline will not show up whereas it did before
  • 时间:2024-02-29 08:47:06
  •  标签:
  • r
  • ggplot2

我试图在15岁和300岁时达到两条横向破碎线,以在我的土地上展示。 他们正在前台,我不敢肯定我所做的事情,但不再显示。 我没有听说过密码,所以我很想知道,我是否删除/更改了一块地块依赖的 d/包裹。

# Create labels and limits for week numbers
labels_week_n <- c("W
1", "W
2", "W
3", "W
4", "W
5")
limits_week_n <- c(
  "Week 15 of 2016", "Week 16 of 2016", "Week 17 of 2016",
  "Week 18 of 2016", "Week 19 of 2016"
)
# Weekly_moderate_very plot
# for all 33 participants
weekly_moderate_very_p <- 
  weekly_data %>%
  {
    ggplot(.) +
      geom_line(
        aes(
          x = as.factor(week_number), 
          y = weekly_mod_very_m,
          group = id, 
          color = as.factor(id)
          ),
        linejoin = "mitre",
        show.legend = FALSE,
        size = .5
        ) +
      geom_point(
        aes(
          x = as.factor(week_number), 
          y = weekly_mod_very_m, 
          group = id, 
          color = as.factor(id)
          ), 
        show.legend = FALSE, 
        size = 1) +
      labs(
        title = "Moderate/vigorous activity",
        subtitle = "Weekly totals for 33 participants",
        y = "Minutes"
      ) +
      scale_x_discrete(
        name = NULL,
        limits = limits_week_n,
        labels = labels_week_n,
        expand = c(0, 0)
      ) +
      scale_y_continuous(
        breaks = c(0, 150, 300, 450, 600, 750, 900), 
        limits = c(0, 1060)
        ) +
      scale_color_discrete() +
      theme_minimal() +
      geom_hline(yintercept = 150, linetype = "dashed") +
      geom_hline(yintercept = 300, linetype = "dashed") +
      facet_wrap(~id, drop = TRUE, nrow = 3, ncol = 11, scales = "fixed") +
      theme(
        plot.title = element_text(
          margin = margin(5, 5, 5, 0),
          size = 14,
          hjust = 1,
          face = "bold"
        ),
        plot.subtitle = element_text(
          margin = margin(1, 5, 5, 0),
          size = 10,
          hjust = 1,
          face = "italic"
        ),
        axis.title.y = element_text(
          margin = margin(0, 5, 0, 5),
          size = 12
        ),
        panel.spacing.x = unit(.75, "lines")
      )
  }
weekly_moderate_very_p

This yields the following plot

It used to look like this, and that s what I would like it to look like again: plot

我试图去除/改变这一类线,但结果不及损失的那类。

SOLVED Thanks all, I feel so silly for not thinking to define the line color!

最佳回答

我可以不使用<条码>每周——数据。 在这方面,我将努力:

这条线就存在,看不到。 变化的规模和肤色可以解决这个问题。

geom_hline(yintercept = 150, linetype = "dashed", size = 2, color = "black") +
geom_hline(yintercept = 300, linetype = "dashed", size = 2, color = "black")

或使用<条码>线上宽度=2。 不接受

问题回答

暂无回答




相关问题
How to plot fitted model over observed time series

This is a really really simple question to which I seem to be entirely unable to get a solution. I would like to do a scatter plot of an observed time series in R, and over this I want to plot the ...

REvolution for R

since the latest Ubuntu release (karmic koala), I noticed that the internal R package advertises on start-up the REvolution package. It seems to be a library collection for high-performance matrix ...

R - capturing elements of R output into text files

I am trying to run an analysis by invoking R through the command line as follows: R --no-save < SampleProgram.R > SampleProgram.opt For example, consider the simple R program below: mydata =...

R statistical package: wrapping GOFrame objects

I m trying to generate GOFrame objects to generate a gene ontology mapping in R for unsupported organisms (see http://www.bioconductor.org/packages/release/bioc/vignettes/GOstats/inst/doc/...

Changing the order of dodged bars in ggplot2 barplot

I have a dataframe df.all and I m plotting it in a bar plot with ggplot2 using the code below. I d like to make it so that the order of the dodged bars is flipped. That is, so that the bars labeled "...

Strange error when using sparse matrices and glmnet

I m getting a weird error when training a glmnet regression. invalid class "dgCMatrix" object: length(Dimnames[[2]]) must match Dim[2] It only happens occasionally, and perhaps only under larger ...

Generating non-duplicate combination pairs in R

Sorry for the non-descriptive title but I don t know whether there s a word for what I m trying to achieve. Let s assume that I have a list of names of different classes like c( 1 , 2 , 3 , 4 ) ...

Per panel smoothing in ggplot2

I m plotting a group of curves, using facet in ggplot2. I d like to have a smoother applied to plots where there are enough points to smooth, but not on plots with very few points. In particular I d ...

热门标签