-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot_utilities.py
52 lines (40 loc) · 1.19 KB
/
plot_utilities.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
# -*- coding: utf-8 -*-
"""
Created on Fri Mar 8 12:55:43 2019
@author: kcaldeira
"""
import numpy as np
import matplotlib.pyplot as plt
#%%
def qplot(x0,y0=[],xlabel='',ylabel='',title='',filename=''):
if len(y0)==0: # one data argument
if len(np.array(x0).shape) == 1:
plt.plot(x0) # if vector, just plot it
else: # assume all args are in x, with first column as x values
x = np.array(x0)[:,0]
y = np.array(x0)[:,1:]
plt.plot(x,y)
else: # two data arguments
if len(np.array(y0).shape) == 1:
plt.plot(x0,y0)
elif np.array(y0).shape[1] == len(x0): # check if y values need transposition
y = np.array(y0).transpose()
plt.plot(x0, y)
else:
plt.plot(x0, y0)
if xlabel != '':
plt.xlabel(xlabel)
if ylabel != '':
plt.ylabel(ylabel)
if title != '':
plt.title(title)
plt.grid(True)
if filename != '':
plt.savefig(filename)
plt.show()
#%%
def minus(a,b):
return np.array(a)-np.array(b)
#%%
def qplot2(dic1,dic2,var):
qplot(minus(dic1[var],dic2[var]))