Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can use <a href="http://matplotlib.sourceforge.net/" rel="nofollow noreferrer">matplotlib</a> and the the optional <code>bottom</code> parameter of <a href="http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.bar" rel="nofollow noreferrer">matplotlib.pyplot.bar</a>. You can then use line <code>plot</code> to indicate the opening and closing prices:</p> <p>For example:</p> <pre><code>#!/usr/bin/env python import numpy as np import matplotlib.pyplot as plt from matplotlib import lines import random deltas = [4, 6, 13, 18, 15, 14, 10, 13, 9, 6, 15, 9, 6, 1, 1, 2, 4, 4, 4, 4, 10, 11, 16, 17, 12, 10, 12, 15, 17, 16, 11, 10, 9, 9, 7, 10, 7, 16, 8, 12, 10, 14, 10, 15, 15, 16, 12, 8, 15, 16] bases = [46, 49, 45, 45, 44, 49, 51, 52, 56, 58, 53, 57, 62, 63, 68, 66, 65, 66, 63, 63, 62, 61, 61, 57, 61, 64, 63, 58, 56, 56, 56, 60, 59, 54, 57, 54, 54, 50, 53, 51, 48, 43, 42, 38, 37, 39, 44, 49, 47, 43] def rand_pt(bases, deltas): return [random.randint(base, base + delta) for base, delta in zip(bases, deltas)] # randomly assign opening and closing prices openings = rand_pt(bases, deltas) closings = rand_pt(bases, deltas) # First we draw the bars which show the high and low prices # bottom holds the low price while deltas holds the difference # between high and low. width = 0 ax = plt.axes() rects1 = ax.bar(np.arange(50), deltas, width, color='r', bottom=bases) # Now draw the ticks indicating the opening and closing price for opening, closing, bar in zip(openings, closings, rects1): x, w = bar.get_x(), 0.2 args = { } ax.plot((x - w, x), (opening, opening), **args) ax.plot((x, x + w), (closing, closing), **args) plt.show() </code></pre> <p>creates a plot like this:</p> <p><img src="https://i.stack.imgur.com/4dWF7.png" alt="enter image description here"></p> <p>Obviously, you'd want to package this up in a function that drew the plot using <code>(open, close, min, max)</code> tuples (and you probably wouldn't want to randomly assign your opening and closing prices).</p>
    singulars
    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.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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