python - Plotting candlesticks with tight resolution - understanding "width" parameters -
i have been using tutorials candlestick data , work daily charts. however, i'm guessing since rely on default behaviour matplotlib.finance candlestick function, there pieces i'm missing in understanding switching intraday.
my data looks (but convert date/time numbers prior call finance.candlestick)
high low open close volume vwap 2013-09-18 18:05:00 126.343750 125.468750 125.468750 126.046875 721 126.285909 2013-09-18 18:10:00 126.296875 126.078125 126.078125 126.187500 271 126.194649 2013-09-18 18:15:00 126.234375 125.843750 126.234375 125.843750 83 126.157003 2013-09-18 18:20:00 125.984375 125.953125 125.953125 125.953125 505 125.953311 2013-09-18 18:25:00 126.250000 126.250000 126.250000 126.250000 1 126.250000 2013-09-18 18:30:00 126.250000 126.250000 126.250000 126.250000 0 126.250000
and code (stripped of attempts i've made) i'm using follows:
fig = plt.figure(figsize=(10, 5)) ax = fig.add_axes([0.1, 0.2, 0.85, 0.7]) # customization of axis ax.spines['right'].set_color('none') ax.spines['top'].set_color('none') ax.xaxis.set_ticks_position('bottom') ax.yaxis.set_ticks_position('left') ax.tick_params(axis='both', direction='out', width=2, length=8, labelsize=12, pad=8) ax.spines['left'].set_linewidth(2) ax.spines['bottom'].set_linewidth(2) ax.set_ylabel('quote ($)', size=20) ax.xaxis.set_major_locator(fiveminutelocator) ax.xaxis.set_minor_locator(oneminutelocator) # candlestick call requires following format: # (time, open, close, high, low, ...) print(bars.to_records()) bars.index = bars.index.map(date2num) candle_bars = bars[ ['open', 'close', 'high', 'low' ] ] candle_bars = map(list, candle_bars.to_records()) finance.candlestick(ax, candle_bars, width=0.1, colorup='g', colordown='r') plt.show()
the resulting plot follows:
edit: problem lies lack of understanding of relationship between "figure.size" gather in inches, "figure.dpi", , width parameters passed in line2d , rectangles patches in matplotlib.
i don't quite how relation works. smaller range of times in (i.e. 10 millisecond bars, , total range of 10 seconds) requires tiny width in finance.candlestick plot (0.000005 seems work). larger range of times (day-bars , months of data) can use default width of 0.8.
so not understand width measured in. it's described "points". fiddling dpi in figure doesn't seem i'd want do.
Comments
Post a Comment