import matplotlib.pyplot as plt
import pandas as pd


"""
Explanation: Matplotlib
Introduction
Matplotlib is a Python 2D plotting library which produces publication quality figures in a variety of hardcopy formats and interactive environments across platforms. Matplotlib can be used in Python scripts, the Python and IPython shell, the jupyter notebook, web application servers, and four graphical user interface toolkits.
Installation 
bash 
sudo pip3 install matplotlib
End of explanation
"""


%matplotlib inline

"""
Explanation: You'll also need to use this line to see plots in the notebook:
End of explanation
"""


import numpy as np
x = np.linspace(0, 5, 11)
y = x ** 2

plt.plot(x, y ,'r--')
#plt.plot(x, y ,'b--')

x = np.arange(5)        
y = (20, 35, 30, 35, 27)
plt.bar(x,y)           

import numpy as np
x = np.linspace(0, 5, 11)
y = x ** 2
plt.scatter(x,y)

plt.subplot(1,2,1)
plt.plot(x, y, 'r--')
plt.subplot(1,2,2)
plt.plot(y, x, 'g*-');

data = [np.random.normal(0, std, 100) for std in range(1, 4)]
plt.boxplot(data,vert=True,patch_artist=True); 

"""
Explanation: That line is only for jupyter notebooks, if you are using another editor, you'll use: plt.show() at the end of all your plotting commands to have the figure pop up in another window.
Using global functions

plt.bar – creates a bar chart
plt.scatter – makes a scatter plot
plt.boxplot – makes a box and whisker plot
plt.hist – makes a histogram
plt.plot – creates a line plot
End of explanation
"""


X = pd.read_csv('Datasets/matplot/X.csv')
Y = pd.read_csv('Datasets/matplot/Y.csv')

import matplotlib.patches as mpatches

fig, axes = plt.subplots(1, 2, figsize=(20,8))

axes[0].scatter(X['ENSG00000141448.7'],X['ENSG00000178401.13'], c = Y['0'] , marker='o',cmap = 'jet',s=30)
axes[1].scatter(X['ENSG00000006611.14'],X['ENSG00000106078.16'], c = Y['0'] , marker='o', cmap='jet', s = 30)
## add details
axes[0].legend(handles=[mpatches.Patch(color='red', label='bladder'),mpatches.Patch(color='green', label='colorectal'),mpatches.Patch(color='blue', label='pancreas')],fontsize = 15)
axes[1].legend(handles=[mpatches.Patch(color='red', label='bladder'),mpatches.Patch(color='green', label='colorectal'),mpatches.Patch(color='blue', label='pancreas')],fontsize = 15)
#labelxy
axes[0].set_xlabel('feature1')
axes[0].set_ylabel('feature2')
axes[1].set_xlabel('feature1')
axes[1].set_ylabel('feature2')
#name of figure.
axes[0].set_title("figure 1.2")
axes[1].set_title("figure 1.3")


import seaborn as sns

"""
Explanation: Matplotlib Object Oriented Method
Now that we've seen the basics, let's break it all down with a more formal introduction of Matplotlib's Object Oriented API. This means we will instantiate figure objects and then call methods or attributes from that object.
End of explanation
"""



tips = sns.load_dataset('tips')

tips.head()


"""
Explanation: Data
Seaborn comes with built-in data sets!
End of explanation
"""


sns.distplot(tips['total_bill'],bins=30)


"""
Explanation: distplot
The distplot shows the distribution of a univariate set of observations.
End of explanation
"""



sns.distplot(tips['total_bill'],kde=False,bins=30)

"""
Explanation: To remove the kde layer and just have the histogram use:
End of explanation
"""



sns.jointplot(x='total_bill',y='tip',data=tips,kind='scatter')



sns.jointplot(x='total_bill',y='tip',data=tips,kind='hex')


sns.jointplot(x='total_bill',y='tip',data=tips,kind='reg')

"""
Explanation: jointplot() allows you to basically match up two distplots for bivariate data. With your choice of what kind parameter to compare with: 
* “scatter” 
* “reg” 
* “resid” 
* “kde” 
* “hex”
End of explanation
"""


sns.pairplot(tips)

sns.pairplot(tips,hue='sex',palette='coolwarm')

"""
Explanation: pairplot
pairplot will plot pairwise relationships across an entire dataframe (for the numerical columns) and supports a color hue argument (for categorical columns).
End of explanation
"""


