0

I want to plot stock prices in time interval but too many values in short time intervals here is the data and plot

How can i fix that?

> head(df)
# A tibble: 6 x 5
  Order_time          Best_Bid mid_price  spread Best_Ask
  <dttm>                 <dbl>     <dbl>   <dbl>    <dbl>
1 2018-03-01 09:40:01     11.7      11.7 0.01000     11.7
2 2018-03-01 09:40:02     11.7      11.7 0.01000     11.7
3 2018-03-01 09:40:02     11.7      11.7 0.01000     11.7
4 2018-03-01 09:40:02     11.7      11.7 0.01000     11.7
5 2018-03-01 09:40:03     11.7      11.7 0.01000     11.7
6 2018-03-01 09:40:03     11.7      11.7 0.01000     11.7

Code of plot

ggplot() + geom_line(df,mapping = aes(x=df$Order_time,y=df$Best_Bid))

PLOT

atahan
  • 3
  • 2
  • What's the code that generates this plot? Having `df$` show up in the axes titles makes me suspect you've used `$` inside your `aes` calls—[don't do that](https://stackoverflow.com/questions/32543340/issue-when-passing-variable-with-dollar-sign-notation-to-aes-in-combinatio) – camille Dec 27 '19 at 19:10
  • 1
    Instead of using a geom_line() call, you may want to look into using a geom_smooth (). I am not sure the purpose of this chart, so I don't want to post a final answer, but that should clear out some of the noise. Agree with @Camille, it would be helpful to have the code to the plot. – SharpSharpLes Dec 27 '19 at 19:12
  • Remove $ but same output – atahan Dec 27 '19 at 19:15
  • 3
    Summarize the data into larger time intervals before plotting it. For instance, you could do median, mean, or max "best bid" per minute, hour, or day. Currently, it looks like you have a resolution of best bid per second, which is probably a lot finer scale than you are looking for. If you want to keep all the data, you could do something with geom_smooth and then maybe add a confidence interval. – Tanner33 Dec 27 '19 at 19:28

0 Answers0