Skip to content

Commit 07de72b

Browse files
committed
+ combined plot
1 parent db924a9 commit 07de72b

File tree

2 files changed

+62
-12
lines changed

2 files changed

+62
-12
lines changed

hydrometer.ipynb

Lines changed: 51 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
{
44
"cell_type": "code",
55
"execution_count": null,
6-
"metadata": {},
6+
"metadata": {
7+
"pycharm": {
8+
"name": "#%%\n"
9+
}
10+
},
711
"outputs": [],
812
"source": [
913
"from collections import defaultdict\n",
@@ -15,7 +19,11 @@
1519
{
1620
"cell_type": "code",
1721
"execution_count": null,
18-
"metadata": {},
22+
"metadata": {
23+
"pycharm": {
24+
"name": "#%%\n"
25+
}
26+
},
1927
"outputs": [],
2028
"source": [
2129
"# ignore NaN\n",
@@ -30,7 +38,11 @@
3038
{
3139
"cell_type": "code",
3240
"execution_count": null,
33-
"metadata": {},
41+
"metadata": {
42+
"pycharm": {
43+
"name": "#%%\n"
44+
}
45+
},
3446
"outputs": [],
3547
"source": [
3648
"data = pd.read_csv('data/hydrometer.csv', names=['color', 'epoch', 'iso', 'sg', 'c', 'f', 'n'],\n",
@@ -46,7 +58,11 @@
4658
{
4759
"cell_type": "code",
4860
"execution_count": null,
49-
"metadata": {},
61+
"metadata": {
62+
"pycharm": {
63+
"name": "#%%\n"
64+
}
65+
},
5066
"outputs": [],
5167
"source": [
5268
"data.info()"
@@ -55,7 +71,11 @@
5571
{
5672
"cell_type": "code",
5773
"execution_count": null,
58-
"metadata": {},
74+
"metadata": {
75+
"pycharm": {
76+
"name": "#%%\n"
77+
}
78+
},
5979
"outputs": [],
6080
"source": [
6181
"plt.rcParams[\"figure.figsize\"] = (15,6)\n",
@@ -66,7 +86,11 @@
6686
{
6787
"cell_type": "code",
6888
"execution_count": null,
69-
"metadata": {},
89+
"metadata": {
90+
"pycharm": {
91+
"name": "#%%\n"
92+
}
93+
},
7094
"outputs": [],
7195
"source": [
7296
"plt.grid()\n",
@@ -76,7 +100,11 @@
76100
{
77101
"cell_type": "code",
78102
"execution_count": null,
79-
"metadata": {},
103+
"metadata": {
104+
"pycharm": {
105+
"name": "#%%\n"
106+
}
107+
},
80108
"outputs": [],
81109
"source": [
82110
"date_data"
@@ -85,7 +113,11 @@
85113
{
86114
"cell_type": "code",
87115
"execution_count": null,
88-
"metadata": {},
116+
"metadata": {
117+
"pycharm": {
118+
"name": "#%%\n"
119+
}
120+
},
89121
"outputs": [],
90122
"source": [
91123
"plt.grid()\n",
@@ -95,7 +127,11 @@
95127
{
96128
"cell_type": "code",
97129
"execution_count": null,
98-
"metadata": {},
130+
"metadata": {
131+
"pycharm": {
132+
"name": "#%%\n"
133+
}
134+
},
99135
"outputs": [],
100136
"source": [
101137
"plt.grid()\n",
@@ -105,7 +141,11 @@
105141
{
106142
"cell_type": "code",
107143
"execution_count": null,
108-
"metadata": {},
144+
"metadata": {
145+
"pycharm": {
146+
"name": "#%%\n"
147+
}
148+
},
109149
"outputs": [],
110150
"source": []
111151
}
@@ -131,4 +171,4 @@
131171
},
132172
"nbformat": 4,
133173
"nbformat_minor": 4
134-
}
174+
}

plot.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ def make_plots(config, data, data_by_date, color):
6262
f1 = os.path.join(output_dir, 'temperature.png')
6363
f2 = os.path.join(output_dir, 'density_date.png')
6464
f3 = os.path.join(output_dir, 'temperature_date.png')
65+
f4 = os.path.join(output_dir, 'both.png')
6566

6667
date_html = data_by_date.to_html()
6768

@@ -105,7 +106,16 @@ def make_plots(config, data, data_by_date, color):
105106
ax3.plot(data_by_date.index, data_by_date['c'])
106107
plt.savefig(f3, dpi=200)
107108

108-
return date_html, mm_html, (f0, f1, f2, f3)
109+
fig4, ax4a = plt.subplots(figsize=FIGSIZE)
110+
ax4b = ax4a.twinx()
111+
ax4a.xaxis.set_major_locator(days_locator)
112+
ax4a.xaxis.set_major_formatter(days_format)
113+
ax4a.format_xdata = days_format
114+
ax4a.plot(data['time'], data['sg'], color="red")
115+
ax4b.plot(data['time'], data['c'], color="yellow")
116+
plt.savefig(f4, dpi=200)
117+
118+
return date_html, mm_html, [f0, f1, f2, f3, f4]
109119

110120

111121
def send_mail(message):

0 commit comments

Comments
 (0)