import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
sns.set(style="darkgrid")
from scipy import signal
x = np.linspace(0, 1, 500)
y = signal.sawtooth(2 * np.pi * 5 * x)
df = pd.DataFrame(dict(xLabel = x, yLabel = y))
sns.relplot(x="xLabel", y="yLabel", kind="line", sort=False, data=df)
magnitude = np.linspace(0, 100, 500)
angle = np.linspace(0, 50*np.pi, 500)
x = magnitude * np.sin(angle)
y = magnitude * np.cos(angle)
df = pd.DataFrame(dict(xLabel = x, yLabel = y))
sns.relplot(x="xLabel", y="yLabel", kind="line", sort=False, data=df)
fmri = sns.load_dataset("fmri")
fmri.tail(10)
subject timepoint event region signal
1054 s5 8 cue frontal -0.028292
1055 s4 8 cue frontal -0.160821
1056 s3 8 cue frontal -0.033848
1057 s2 8 cue frontal -0.069666
1058 s1 8 cue frontal -0.136059
1059 s0 8 cue frontal 0.018165
1060 s13 7 cue frontal -0.029130
1061 s12 7 cue frontal -0.004939
1062 s11 7 cue frontal -0.025367
1063 s0 0 cue parietal -0.006899
#mean and the 95% confidence interval around the mean:
sns.relplot(x="timepoint", y="signal", kind="line", data=fmri);
#mean only
sns.relplot(x="timepoint", y="signal", ci=None, kind="line", data=fmri);
#mean + standard deviation
sns.relplot(x="timepoint", y="signal", kind="line", ci="sd", data=fmri);
sns.relplot(x="timepoint", y="signal", hue="event", kind="line", data=fmri);
sns.relplot(x="timepoint", y="signal", hue="region", style="event",
kind="line", data=fmri);
sns.relplot(x="timepoint", y="signal", hue="region", style="event",
dashes=False, markers=True, kind="line", data=fmri);
from datetime import datetime
date = ["08/28/2019", "08/29/2019", "08/30/2019",...]
dateArray = [datetime.strptime(_, '%m/%d/%Y').date() for _ in date]
price = [23.889999389648438, 23.829999923706055, 21.959999084472656, ...]
df = pd.DataFrame(dict(date=dateArray, price=price))
df.tail()
date price
2549 2020-08-13 1621.000000
2550 2020-08-14 1650.709961
2551 2020-08-17 1835.640015
2552 2020-08-18 1887.089966
2553 2020-08-19 1878.530029
tsla = sns.relplot(x="date", y="price", kind="line", data=df)
tsla.fig.suptitle('TSLA')
fig, ax = plt.subplots()
# the size of A4 paper
fig.set_size_inches(11.7, 8.27)
plt.xticks(rotation=45)
plt.title('TSLA')
filter = (df['date'] > datetime.strptime("06/01/2019", '%m/%d/%Y').date())
tsla = sns.relplot(x="date", y="price", kind="line", data=df.loc[filter], ax=ax)
reference:
string to date
add title
rotate label
No comments:
Post a Comment