#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Mar  3 16:38:17 2020

@author: francescopiscitelli
"""
import pandas as pd
import numpy  as np
import matplotlib.pyplot as plt
import time
import os

# bars 

labels = ['G1', 'G2', 'G3', 'G4', 'G5']
cats_means = [20, 34, 30, 35, 27]
dogs_means = [25, 32, 34, 20, 25]

x = np.arange(len(labels))  # the label locations
width = 0.35  # the width of the bars

fig, ax = plt.subplots()
rects1 = ax.bar(x - width/2, cats_means, width, label='Cats')
rects2 = ax.bar(x + width/2, dogs_means, width, label='Dogs')

# Add some text for labels, title and custom x-axis tick labels, etc.
ax.set_ylabel('Scores')
ax.set_title('Scores by group and animal')
ax.set_xticks(x)
ax.set_xticklabels(labels)
ax.legend()


# projections 
N = 1000
nbins = 50
x = np.random.normal(0.0, scale=20.0, size=N)
y = np.random.normal(0.0, scale=20.0, size=N)

dx = 0.65
xymin = 0.1
fig = plt.figure(figsize=(8, 8))
# Use: add_axes([x_lower_left, y_lower_left, size_x, size_y])
ax1 = fig.add_axes([xymin, xymin, dx, dx]) # Central figure
ax2 = fig.add_axes([xymin+dx, xymin, 0.2, dx]) # Right histogram
ax3 = fig.add_axes([xymin, xymin+dx, dx, 0.2]) # Top histogram

ax1.scatter(x, y)
ax2.hist(y, bins=nbins, orientation='horizontal') # Note "horizontal" here refers to horizontal bars
ax3.hist(x, bins=nbins)

# Set the ticks on the histogram axes to the right and top to avoid overlap on main panel
ax2.yaxis.tick_right()
ax3.xaxis.tick_top()