- Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdata_frame.py
45 lines (34 loc) · 1.1 KB
/
data_frame.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
"""
===============
Show data frame
===============
Wrapping a :class:`pandas.DataFrame` using :class:`.containers.DataFrameContainer`
and :class:`.artist.Line`.
"""
importmatplotlib.pyplotasplt
importnumpyasnp
importpandasaspd
fromdata_prototype.artistimportCompatibilityArtistasCA
fromdata_prototype.lineimportLine
fromdata_prototype.containersimportDataFrameContainer
th=np.linspace(0, 4*np.pi, 256)
dc1=DataFrameContainer(
pd.DataFrame({"x": th, "y": np.cos(th)}), index_name=None, col_names=lambdan: n
)
df=pd.DataFrame(
{
"cos": np.cos(th),
"sin": np.sin(th),
},
index=th,
)
dc2=DataFrameContainer(df, index_name="x", col_names={"sin": "y"})
dc3=DataFrameContainer(df, index_name="x", col_names={"cos": "y"})
fig, (ax1, ax2) =plt.subplots(2, 1)
ax1.add_artist(CA(Line(dc1, linewidth=5, color="green", label="sin")))
ax2.add_artist(CA(Line(dc2, linewidth=5, color="green", label="sin")))
ax2.add_artist(CA(Line(dc3, linewidth=5, color="blue", label="cos")))
foraxin (ax1, ax2):
ax.set_xlim(0, np.pi*4)
ax.set_ylim(-1.1, 1.1)
plt.show()