项目作者: mbeale

项目描述 :
tiemseriesql-matplotlib
高级语言: Python
项目地址: git://github.com/mbeale/timeseriesql-matplotlib.git
创建时间: 2019-11-17T16:49:56Z
项目社区:https://github.com/mbeale/timeseriesql-matplotlib

开源协议:BSD 2-Clause "Simplified" License

下载


Contributors
Forks
Stargazers
Issues
LinkedIn



TimeSeriesQL-Matplotlib




A plotting backend for the TimeSeriesQL library


Table of Contents

About The Project

This project adds a matplotlib plotting backend for the TimeSeriesQL project.

Built With

Getting Started

To get a local copy up and running follow these simple steps.

Prerequisites

The requirements are in the requirements.txt file.

Installation

pip

  1. pip install timeseriesql-matplotlib

manual

  1. Clone the timeseriesql-matplotlib
    1. git clone https:://github.com/mbeale/timeseriesql-matplotlib.git
  2. Install library
    1. cd timeseriesql-matplotlib
    2. python setup.py install

Usage

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:

  1. import matplotlib.pyplot as plt
  2. from timeseriesql_matplotlib import MatplotlibTQL as mp
  3. from timeseriesql.backends.csv_backend import CSVBackend
  4. data = CSVBackend(x for x in "AAPL.csv")[:] #CSV of AAPL stock data header = (open, close, high, low, adj close)

Line Plot

  1. mp().line_plot(data)
  2. plt.show()

Line Plot Example

Stacked Plot

  1. mp().stacked_plot(data)
  2. plt.show()

Stacked Plot Example

Timebox Plot

  1. mp().timebox_plot(data[:,0])
  2. plt.show()
  3. """
  4. the plot arguement defaults to auto but you can set a specific period
  5. s - second buckets
  6. m - minute buckets
  7. h - hour buckets
  8. d - day buckets
  9. mth - month buckets
  10. y - year buckets
  11. """

Timebox Plot Example

Heatmap Plot

  1. mp().heatmap_plot(data[{'label': 'Close'}])
  2. plt.show()
  3. """
  4. the plot arguement defaults to auto but you can set a specific period
  5. s - second buckets
  6. m - minute buckets
  7. h - hour buckets
  8. d - day buckets
  9. mth - month buckets
  10. y - year buckets
  11. """

Heatmap Plot Example

Distribution Plot

  1. mp().dist_plot(data[:,0], percentiles=[25,75]) #percentiles are optional
  2. plt.show()

Distribution Plot Example

Correlogram Plot

  1. mp().correlogram_plot(data)
  2. plt.show()

Correlogram Plot Example

Lag Plot

  1. mp().lag_plot( data[{'label': 'Open'}])
  2. plt.show()

Lag Plot Example

Text Plot

  1. mp().line_plot(data)
  2. mp().text_plot(data[-1,0], title="A Nice Text Box", thresholds=[(0, 'green', 'white'), (20, 'cornflowerblue', 'white'), (None, 'darkorange', 'white')])

Text Plot Example

Layout Example

  1. from matplotlib.gridspec import GridSpec
  2. fig = plt.figure(constrained_layout=True, figsize=(20,20))
  3. gs = GridSpec(4, 4, figure=fig)
  4. ax1 = fig.add_subplot(gs[0, 0])
  5. ax2 = fig.add_subplot(gs[0, 1])
  6. ax3 = fig.add_subplot(gs[0, 2])
  7. ax4 = fig.add_subplot(gs[0, 3])
  8. ax5 = fig.add_subplot(gs[1:3, :3])
  9. ax6 = fig.add_subplot(gs[1, 3])
  10. ax7 = fig.add_subplot(gs[2, 3])
  11. ax8 = fig.add_subplot(gs[3, :2])
  12. ax9 = fig.add_subplot(gs[3, 2:])
  13. mp().text_plot(data[:,0].mean(), ax=ax1, title="Avg Close")
  14. mp().text_plot(data[:,1].mean(), ax=ax2, title="Avg High")
  15. mp().text_plot(data[:,2].mean(), ax=ax3, title="Avg Low")
  16. mp().line_plot(data[:,0], ax = ax4)
  17. mp().line_plot(data, ax=ax5)
  18. mp().line_plot(data[:,1], ax=ax6)
  19. mp().line_plot(data[:,2], ax=ax7)
  20. mp().line_plot(data[:,3], ax=ax8)
  21. mp().line_plot(data[:,4], ax=ax9)

Text Plot Example

Roadmap

See the open issues for a list of proposed features (and known issues).

Contributing

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.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Michael Beale - michael.beale@gmail.com

Project Link: https://github.com/mbeale/timeseriesql-matplotlib