-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdraw.py
59 lines (49 loc) · 1.72 KB
/
draw.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
import time
# 设置风格,seaborn有5种基本风格,context表示环境
sns.set(style="darkgrid", context="talk")
# 处理中文问题
sns.set_style('whitegrid', {'font.sans-serif':['simhei', 'Arial']})
def draw_polar(x, y, fig_size=None, title=None):
"""
draw a single polar picture
:param x:
:param y:
:return:
"""
fig = plt.figure(figsize=fig_size)
ax = fig.add_subplot(111, projection='polar')
ax.plot(x, y)
plt.savefig(title if title else ('Untitled' + time.asctime(time.localtime(time.time()))) + '.jpg')
# plt.show()
def draw(x, y, fig_size=None, title=None):
"""
:param data: data to be plotted
:return:
"""
fig = plt.figure(figsize=fig_size)
ax = fig.add_subplot(111)
ax.plot(x, y)
if title is not None:
plt.title(title)
# plt.show()
plt.savefig(title if title else ('Untitled' + time.asctime(time.localtime(time.time()))) + '.jpg')
def draw_v2(x, y1, y2, fig_size=None, title=None):
fig = plt.figure(figsize=fig_size)
ax1 = fig.add_subplot(211)
ax1.plot(x, y1, 'r')
ax2 = fig.add_subplot(212)
ax2.plot(x, y2, 'b')
if title is not None:
plt.title(title)
plt.savefig(title if title else ('Untitled' + time.asctime(time.localtime(time.time()))) + '.jpg')
def draw_bar(x, y, fig_size=None, title=None):
fig = plt.figure(figsize=fig_size)
sns.barplot(x, y, palette="BuPu_r")
if not title is None:
plt.title(title)
plt.savefig(title if title else ('Untitled' + time.asctime(time.localtime(time.time()))) + '.jpg')
# sns.despine(bottom=True)
# plt.show()