A plotting backend for the TimeSeriesQL library
This project adds a matplotlib plotting backend for the TimeSeriesQL project.
To get a local copy up and running follow these simple steps.
The requirements are in the requirements.txt file.
pip install timeseriesql-matplotlib
- Clone the timeseriesql-matplotlib
git clone https:://github.com/mbeale/timeseriesql-matplotlib.git
- Install library
cd timeseriesql-matplotlib
python setup.py install
The charting library operates on TimeSeries objects. The Axes can be overriden to control the placement of the charts. All the below examples use the following code:
import matplotlib.pyplot as plt
from timeseriesql_matplotlib import MatplotlibTQL as mp
from timeseriesql.backends.csv_backend import CSVBackend
data = CSVBackend(x for x in "AAPL.csv")[:] #CSV of AAPL stock data header = (open, close, high, low, adj close)
mp().line_plot(data)
plt.show()
mp().stacked_plot(data)
plt.show()
mp().timebox_plot(data[:,0])
plt.show()
"""
the plot arguement defaults to auto but you can set a specific period
s - second buckets
m - minute buckets
h - hour buckets
d - day buckets
mth - month buckets
y - year buckets
"""
mp().heatmap_plot(data[{'label': 'Close'}])
plt.show()
"""
the plot arguement defaults to auto but you can set a specific period
s - second buckets
m - minute buckets
h - hour buckets
d - day buckets
mth - month buckets
y - year buckets
"""
mp().dist_plot(data[:,0], percentiles=[25,75]) #percentiles are optional
plt.show()
mp().correlogram_plot(data)
plt.show()
mp().lag_plot( data[{'label': 'Open'}])
plt.show()
mp().line_plot(data)
mp().text_plot(data[-1,0], title="A Nice Text Box", thresholds=[(0, 'green', 'white'), (20, 'cornflowerblue', 'white'), (None, 'darkorange', 'white')])
from matplotlib.gridspec import GridSpec
fig = plt.figure(constrained_layout=True, figsize=(20,20))
gs = GridSpec(4, 4, figure=fig)
ax1 = fig.add_subplot(gs[0, 0])
ax2 = fig.add_subplot(gs[0, 1])
ax3 = fig.add_subplot(gs[0, 2])
ax4 = fig.add_subplot(gs[0, 3])
ax5 = fig.add_subplot(gs[1:3, :3])
ax6 = fig.add_subplot(gs[1, 3])
ax7 = fig.add_subplot(gs[2, 3])
ax8 = fig.add_subplot(gs[3, :2])
ax9 = fig.add_subplot(gs[3, 2:])
mp().text_plot(data[:,0].mean(), ax=ax1, title="Avg Close")
mp().text_plot(data[:,1].mean(), ax=ax2, title="Avg High")
mp().text_plot(data[:,2].mean(), ax=ax3, title="Avg Low")
mp().line_plot(data[:,0], ax = ax4)
mp().line_plot(data, ax=ax5)
mp().line_plot(data[:,1], ax=ax6)
mp().line_plot(data[:,2], ax=ax7)
mp().line_plot(data[:,3], ax=ax8)
mp().line_plot(data[:,4], ax=ax9)
See the open issues for a list of proposed features (and known issues).
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE
for more information.
Michael Beale - [email protected]
Project Link: https://github.com/mbeale/timeseriesql-matplotlib