matplotlib

Numpy / Matplotlib - Transform tick data into OHLCV

我的梦境 提交于 2021-02-10 03:51:56
问题 I have tick data that I wold like to transform in OHLCV(Open, High, Low, Close, Volume) Daily, Hourly, 15min, 5min, 1min. The tick data that I have is like this: array([[u'2011-08-18 13:37:25', u'10.9', u'0.48990826'], [u'2011-08-19 13:19:24', u'11.85', u'0.08438819'], [u'2011-08-19 16:45:01', u'11.5', u'0.4'], ..., [u'2013-08-24 01:29:27', u'107.97', u'0.18523664'], [u'2013-08-24 01:29:35', u'107.98', u'4.61659567'], [u'2013-08-24 01:30:56', u'107.98', u'0.09339562']], dtype='<U19') The

Numpy / Matplotlib - Transform tick data into OHLCV

我们两清 提交于 2021-02-10 03:51:13
问题 I have tick data that I wold like to transform in OHLCV(Open, High, Low, Close, Volume) Daily, Hourly, 15min, 5min, 1min. The tick data that I have is like this: array([[u'2011-08-18 13:37:25', u'10.9', u'0.48990826'], [u'2011-08-19 13:19:24', u'11.85', u'0.08438819'], [u'2011-08-19 16:45:01', u'11.5', u'0.4'], ..., [u'2013-08-24 01:29:27', u'107.97', u'0.18523664'], [u'2013-08-24 01:29:35', u'107.98', u'4.61659567'], [u'2013-08-24 01:30:56', u'107.98', u'0.09339562']], dtype='<U19') The

Numpy / Matplotlib - Transform tick data into OHLCV

徘徊边缘 提交于 2021-02-10 03:49:26
问题 I have tick data that I wold like to transform in OHLCV(Open, High, Low, Close, Volume) Daily, Hourly, 15min, 5min, 1min. The tick data that I have is like this: array([[u'2011-08-18 13:37:25', u'10.9', u'0.48990826'], [u'2011-08-19 13:19:24', u'11.85', u'0.08438819'], [u'2011-08-19 16:45:01', u'11.5', u'0.4'], ..., [u'2013-08-24 01:29:27', u'107.97', u'0.18523664'], [u'2013-08-24 01:29:35', u'107.98', u'4.61659567'], [u'2013-08-24 01:30:56', u'107.98', u'0.09339562']], dtype='<U19') The

Matplotlib plot multiple bars in one graph

こ雲淡風輕ζ 提交于 2021-02-09 07:29:45
问题 I have a plot with multiple bars with different scenarios, but when I plot it all the bars are repeated. Please find below my code. I know that I'm using only one value at a time from the list, but when I try to pass the whole sub-array using data[0] instead, I get a Value mismatch error: ValueError: shape mismatch: objects cannot be broadcast to a single shape What am I doing wrong? I looked at the PyPlot example and this other post and both pass an array to ax.bar . import numpy as np

Python Numpy Loadtxt - Convert unix timestamp

。_饼干妹妹 提交于 2021-02-09 04:57:16
问题 I have a text file with many rows of data - the first piece of data in each row is a unix timestamp such as 1436472000 . I am using numpy.loadtxt and in the parameters for converters I want to specify for it to convert the timestamp into whatever numpy understands as a date time. I know this needs to go after the 0: in the curly brackets, but I can't work out how to convert it. I know a converter can be used from matplotlib.dates.strpdate2num for normal dates, but I this won't work for unix

Bar chart in matplotlib using a colormap

只谈情不闲聊 提交于 2021-02-09 00:44:35
问题 I have a df with two columns: y: different numeric values for the y axis days: the names of four different days (Monday, Tuesday, Wednesday, Thursday) I also have a colormap with four different colors that I made myself and it's a ListedColorMap object. I want to create a bar chart with the four categories (days of the week) in the x axis and their corresponding values in the y axis. At the same time, I want each bar to have a different color using my colormap. This is the code I used to

Python matplotlib, get position of xtick labels

时间秒杀一切 提交于 2021-02-09 00:36:37
问题 How do I get the positions of the xtick major labels? The values that I am getting from label.get_position() do not make sense. import numpy as np import matplotlib.pyplot as plt def f(t): return np.exp(-t) * np.cos(2*np.pi*t) t1 = np.arange(0.0, 5.0, 0.1) t2 = np.arange(0.0, 5.0, 0.02) # fig, ax = plt.figure(1) fig, ax = plt.subplots() plt.plot(t1, f(t1), 'bo', t2, f(t2), 'k') # plt.show() print(fig) print(ax.get_position()) # ------------------------------------------------ # positions of

Python matplotlib, get position of xtick labels

家住魔仙堡 提交于 2021-02-09 00:30:43
问题 How do I get the positions of the xtick major labels? The values that I am getting from label.get_position() do not make sense. import numpy as np import matplotlib.pyplot as plt def f(t): return np.exp(-t) * np.cos(2*np.pi*t) t1 = np.arange(0.0, 5.0, 0.1) t2 = np.arange(0.0, 5.0, 0.02) # fig, ax = plt.figure(1) fig, ax = plt.subplots() plt.plot(t1, f(t1), 'bo', t2, f(t2), 'k') # plt.show() print(fig) print(ax.get_position()) # ------------------------------------------------ # positions of

Python matplotlib, get position of xtick labels

徘徊边缘 提交于 2021-02-09 00:27:22
问题 How do I get the positions of the xtick major labels? The values that I am getting from label.get_position() do not make sense. import numpy as np import matplotlib.pyplot as plt def f(t): return np.exp(-t) * np.cos(2*np.pi*t) t1 = np.arange(0.0, 5.0, 0.1) t2 = np.arange(0.0, 5.0, 0.02) # fig, ax = plt.figure(1) fig, ax = plt.subplots() plt.plot(t1, f(t1), 'bo', t2, f(t2), 'k') # plt.show() print(fig) print(ax.get_position()) # ------------------------------------------------ # positions of

I have a problem with plotting sphere and a curve on it

旧街凉风 提交于 2021-02-08 23:43:22
问题 I am trying to plot a curve on a sphere but I can not plot them at the same time. I identified some points with Euclidean norm 10 for my curve, and some other points to plot the sphere of radius 10 , respectively as following. Points for curve: random_numbers=[] basevalues=np.linspace(-0.9,0.9,100) for i in range(len(basevalues)): t=random.random() random_numbers.append(t*10) xvalues=[random_numbers[i]*np.cos(basevalues[i]) for i in range(len(basevalues))] yvalues=[random_numbers[i]*np.sin