JuliaPlots / Plots.jl

Powerful convenience for Julia visualizations and data analysis
https://docs.juliaplots.org
Other
1.81k stars 348 forks source link

"line" styles for financial market charting #4

Closed JeffreySarnoff closed 8 years ago

JeffreySarnoff commented 8 years ago

named styles (OHLC, HLC ...) and (not just for finance)subparts that could be combined into customized styles

lineparts

tbreloff commented 8 years ago

Seems like this might make sense to be another linetype, which defaults to :step or something similar when not implemented. If you can create the chart you'd like using the linetypes that exist already, it should be pretty easy to add.

lobingera commented 8 years ago

@JeffreySarnoff Can you please give more examples? Is this line styles, so styling the line that is drawn, or is this about markers that show additional information at certain samples?

On my own plotting agenda i had for some times some ideas (pending) to deal in plots or a plotting engine even with markers that are not predefined, but somehow read-in or imported. Think about using a marker defined by some draw imported from a .svg file. Plotting then could be a 2D plot with x-y lines on one value of a timeline and a second value selecting a marker out of a set of markers.

tbreloff commented 8 years ago

Part of this request is to allow for many marker styles, which would be great, but I suspect may be hard to accomplish depending on the plotting backend. I agree it would be great to have a library of markers to choose from, and if the svg is stored within Plots.jl, it may be possible to pass in custom markers to some of the backends. Right now I'm only using markers built into the backends.

JeffreySarnoff commented 8 years ago

@lobingera This gets difficult, I imagine, as I have not seen it done very accessibly elsewhere. Ultimately, my preoccupation with regard to plots is presenting additionally informative elements without sacrificing visual clarity. When working with stock prices or fuzzy numbers there are sub-aspects that are significant without being sufficient to well-represent the information at a 'point'.

For a daily plot of a stock, people use vertical stick for the high-low range with two thin horizontal tabs for the open (leftward) and close (rightward) prices. Volume is often shown as a second plot below the price plot. To incorporate volume into the primary plot, I might map volume into a blue--red (less(cold)--more(hot)) colorspace and colorcode each vertical stick accordingly. If I had more information, the vertical sticks might become ovoids or thin superellipses.

To do this requires smart, composable and context-aware markers. To do similar with fuzzy information requires the same of curvilinear plot subdivisions. These thoughts are offered as perspective, just so nothing done interferes with building up to such capability.

lobingera commented 8 years ago

@JeffreySarnoff This might look difficult, but if we lay the foundations of markers that are called/rendered with input parameters, your example falls into the easier category because the marker is plotted independently of the surrounding graph, it's just more info at the same x-position. I can follow your text, but can you please somehow attach a picture here?

tbreloff commented 8 years ago

So on some level this is pretty easy to do with certain backends (gadfly/immerse comes to mind). Similar to how it's done with boxplots, the y input could be a tuple of (open,high,low,close) (either vector of tuples, or tuple of vectors), and I'd create a custom compose context on the fly for each x. I borrowed some code from @dcjones to start supporting some other marker shapes, and I could do nearly the same thing for alternate custom plots like OHLC.

What would be most helpful is a detailed description of what your ideal visual looks like, so pictures/drawings are helpful.

JeffreySarnoff commented 8 years ago

ok .. I can paint something tomorrow.

tbreloff commented 8 years ago

I started playing around with passing in vectors of tuples, and then fiddled with making a new polygon, and then... I was done?

julia> using Plots

julia> n=10; hgt=rand(n)+1; bot=randn(n); openpct=rand(n); closepct=rand(n);

julia> y = [(openpct[i]*hgt[i]+bot[i], bot[i]+hgt[i], bot[i], closepct[i]*hgt[i]+bot[i]) for i in 1:n];

julia> plot(y, linetype=:ohlc, markersize=10)

tmp

tbreloff commented 8 years ago

I'm going to close this, but please don't let that stop you from adding a drawing of an alternative shape.

JeffreySarnoff commented 8 years ago

a graph that conveys uncertainty using intensity http://andrewgelman.com/wp-content/uploads/2012/08/hsiang1-300x225.jpg from http://andrewgelman.com/2012/08/26/graphs-showing-regression-uncertainty-the-code/

tbreloff commented 8 years ago

This is quite different from the OHLC charting. I think, to make this graph, you would want to attach a color scheme based on a z-coordinate. Gadfly has this ability, and I certainly intend to support it. I'd say give me a few days and you should be able to do this very simply.