Note that there are some explanatory texts on larger screens.

plurals
  1. POmatplotlib candlestick bars/boxes/width/spacing
    primarykey
    data
    text
    <p>I am using matplotlib to draw candlestick charts.</p> <p>[Q] The default setting shows the high-low bar running through the open-close box. I would prefer to have the open-low box be "above" the line so that I only see high-max(open,close) and min(open,close)-low as lines. Is that possible? How?</p> <blockquote> <p>I answered my own question and am posting my finding with the original question if it helps anyone else.</p> <p>The only way to do this is by rewriting the candletsick() function to draw two lines instead of one. I have some sample code that I am using that does this. Always happy to hear better ways to do the same thing.</p> </blockquote> <pre><code>def fooCandlestick(ax, quotes, width=0.5, colorup='k', colordown='r', alpha=1.0): OFFSET = width/2.0 lines = [] boxes = [] for q in quotes: t, op, cl, hi, lo = q[:5] box_h = max(op, cl) box_l = min(op, cl) height = box_h - box_l if cl&gt;=op: color = colorup else: color = colordown vline_lo = Line2D( xdata=(t, t), ydata=(lo, box_l), color = 'k', linewidth=0.5, antialiased=True, ) vline_hi = Line2D( xdata=(t, t), ydata=(box_h, hi), color = 'k', linewidth=0.5, antialiased=True, ) rect = Rectangle( xy = (t-OFFSET, box_l), width = width, height = height, facecolor = color, edgecolor = color, ) rect.set_alpha(alpha) lines.append(vline_lo) lines.append(vline_hi) boxes.append(rect) ax.add_line(vline_lo) ax.add_line(vline_hi) ax.add_patch(rect) ax.autoscale_view() return lines, boxes </code></pre> <p>[Q] Does matplotlib support setting the width of the candle and also the spacing between each candlestick?</p> <p>Thanks.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload