Closed Moelf closed 4 years ago
:man_facepalming: I need time to figure out the Plot.jl issue. I'm working on Gadfly.jl support: https://github.com/GiovineItalia/Gadfly.jl/pull/1215. Maybe you can try this branch out first
no worries, I know Plots (recipes) can be suck to work with sometime. thx for the good work!
Hi @Moelf , I just rewrite the plot recipe for candlestick. Could you try PR #464 out?
wow, thanks for the swift reaction.
It looks like the hover tooltips is gone completely? and the x-axis is too granular I think
let me give you this for testing:
using DataFrames, TimeSeries, Dates, Plots
m = [ 1.83 1.8708 1.83 1.84 5351.0
1.85 1.85 1.7688 1.7701 12854.0
1.75 1.8869 1.75 1.8201 15735.0
1.795 1.82 1.78 1.78 24814.0
1.76 1.8578 1.76 1.8299 6539.0
1.8159 1.8709 1.7973 1.8309 7422.0
1.79 1.87 1.7899 1.87 18386.0
1.88 1.88 1.79 1.79 7768.0
1.78 1.8 1.6785 1.75 18711.0
1.71 1.79 1.71 1.7892 16594.0]
df = DataFrame(m, [:open, :high, :low, :close, :volume])
df.ts = (now()-Day(9)):Day(1):now()
df_ts = TimeArray(df, timestamp=:ts)
plotly()
plot(df_ts, st=:candlestick)
It looks like the hover tooltips is gone completely?
What kind of information do you expect to show on the tooltips? Since I rewrite the recipe, there is a chance that we can decide the content of tooltips.
and the x-axis is too granular I think
well, I'm still searching about the xticks
auto-shrinking method from Plots.
if I look for inspiration on some online candle plots, for example yahool they hover a window on top left for high, low, open, close; so I guess we can default to display those 4 as well on hover.
I update the PR and add the hover text.
also, I made the density of xticks controlled by xticks::Int
.
e.g.
plot(ta, st = :candlestick, xrotation = 60, xticks = 3)
BTW, we have MarketData.yahoo
in the latest version.
ta = MarketData.yahoo(:GE, YahooOpt(period1 = now() - Month(2), period2 = now()))
plot(ta, st = :candlestick, xrotation = 60, xticks = 3)
ah, thanks, this looks much better now!
https://plotly.com/python/candlestick-charts/
btw, while we're at it, is it possible to have the sliding window at the bottom as well? i'm looking to integrate with Dash.jl
maybe it's something I need to do for Dash
specifically but I really would like to use TimeSeries instead of manually construct stuff, https://github.com/plotly/Dash.jl/issues/50
JS version is here: https://plotly.com/javascript/candlestick-charts/#simple-candlestick-chart
btw, while we're at it, is it possible to have the sliding window at the bottom as well? i
If I understand correctly, in order to support native candlestick from Plotly and get the sliding window,
we have to modify stuffs in Plots.plotly_series
, since the JS doc of Plotly shows that the argument type: "candlestick"
should go with Plots.plotly_series
(the var plotattributes_out[:type]
).
i'm looking to integrate with Dash.jl maybe it's something I need to do for Dash specifically but I really would like to use TimeSeries instead of manually construct stuff, plotly/Dash.jl#50
I think there are two option to get the native support of candlestick from Plotly,
Plots
native support for Plotly banckend only, and let other seriestype = :candlestick
fallback to our recipe. (not sure the fallback is possible or not)TimeArray
support for PlotlyJS.jl
(but I never use that package before, also need time to figure out)1. Add `Plots` native support for Plotly banckend only, and let other `seriestype = :candlestick` fallback to our recipe. (not sure the fallback is possible or not)
I'm fine with using TimeSeries
to extend the recipe when plotting, but I assumed this would give me the correct layout etc. when calling Plots.plotly_series
on the result plot but it wasn't quite right
I'm fine with using TimeSeries to extend the recipe when plotting, but I assumed this would give me the correct layout etc. when calling Plots.plotly_series on the result plot but it wasn't quite right
well, I'm not quite sure what you mean.
In short, the interactive sliding window of Plotly isn't possible to construct by a plot recipe. It requires some changes in Plots.plotly_series
.
ah, I see what you mean. Well, then I guess that's the extend to can do for this issue, thanks for your time and effort of fixing it!