0

I have a data set like:

head(TI_plot)
# A tibble: 6 x 6
  MeanWindSpeed_mean TurbInt_mean NTM_A_Plus_mean NTM_A_mean NTM_B_mean NTM_C_mean
               <dbl>        <dbl>           <dbl>      <dbl>      <dbl>      <dbl>
1          0.2920231    3.0270543             Inf        Inf        Inf        Inf
2          1.1201188    0.4204022       1.1026039  0.9800923  0.8575808  0.7350693
3          2.0283907    0.2641950       0.6423299  0.5709599  0.4995900  0.4282200
4          3.0094789    0.2151093       0.4730658  0.4205029  0.3679401  0.3153772
5          4.0142807    0.1879412       0.3874176  0.3443712  0.3013248  0.2582784
6          5.0125075    0.1669939       0.3367696  0.2993508  0.2619319  0.2245131

How should I use ggplot2 to plot 3 of those columns against MeanWindSpeed_mean? Rhe columns that I'm interested to plot are TurbInt_mean, NTM_A_mean and NTM_B_mean .

pogibas
  • 27,303
  • 19
  • 84
  • 117
Ali Hadjihoseini
  • 941
  • 1
  • 11
  • 31

1 Answers1

1

Select and transform your data using dplyr and tidyr (from tidyverse) and plot using ggplot2:

library(tidyverse)
TI_plot %>%
    select(MeanWindSpeed_mean, TurbInt_mean, NTM_A_mean, NTM_B_mean) %>%
    gather(key, value, -MeanWindSpeed_mean) %>%
    filter(!is.infinite(value)) %>%
    ggplot(aes(MeanWindSpeed_mean, value, color = key)) +
        geom_point(size = 2) +
        geom_line(size = 1.4) +
        labs(x = "Wind Speed, mean", 
             y = "Recorded signal",
             title = "Change in measurement according to wind speed") +
        scale_color_brewer(name = "Measurement", palette = "Dark2") +
        theme_classic()

enter image description here

pogibas
  • 27,303
  • 19
  • 84
  • 117