Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import matplotlib.pyplot as plt
- import numpy as np
- from pandas import DataFrame
- from datetime import datetime, timedelta
- def draw(plotdict):
- df = DataFrame(plotdict)
- fig, ax = plt.subplots()
- ax.set_ylim([-1,1])
- #fig.subplots_adjust(left=0.10, bottom=0.17, right=0.80, top=0.96, wspace=0, hspace=0)
- for key in plotdict.keys():
- if key != "dates":
- df.plot.line(x="dates", y=key, ax=ax)
- plt.grid(b=True, which="major", axis="both")
- plt.figure(figsize=(5,3), dpi=60)
- for tick in ax.xaxis.get_major_ticks():
- tick.label.set_fontsize(8)
- tick.label.set_rotation(45)
- plt.show()
- def create_plots(): ##this is just to generate some sinewave data and add it to some dates.
- d= datetime.now()
- dates = []
- s1 = np.sin(np.arange(0, 10, 0.1))
- s2 = np.sin(np.arange(1, 10, 0.1))
- s3 = np.sin(np.arange(2, 10, 0.1))
- sinelength = min([len(s1), len(s1), len(s3)])
- s1 = s1[0:sinelength]
- s2 = s2[0:sinelength]
- s2 = s2[0:sinelength]
- for i in range(sinelength):
- d = d + timedelta(days=1)
- dates.append(d.strftime("%d/%m/%Y"))
- plotdict = {'dates':dates, 's1':s1, 's2':s2, 's3':s3}
- draw(plotdict)
- create_plots()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement