def plot_vert_hist(fig,ax1,y,pos,ylim,color='grey',label=None,legend=False,onlyhist=True,loc=2,bins=30,alpha=0.5): """ Purpose: function to plot a 'bean' like vertical histogram Input: fig: figure object for reference and plotting ax1: axis object to plot on y: values to be plotted in histogram fashion pos: position along axis to create the bean plot ylim: range of plotted axis [min,max] color: (default to grey) color of the plotted histogram label: (default to none) if included, the label for the color squares of this histogram legend: (default to False) If True adds a legend on the location onlyhist: (default to True) only plots the histogram bean, not the mean and median lines loc: (default to 2) location of the legend bins: (default to 30) number of bins to plot alpha: (defautl to 0.5) value of transparency (0 to 1) Output: only the histogram plot on top of an existing plot Dependencies: - numpy - Sp_parameters - plotting_utils : this file Required files: None Modification History: Written: Samuel LeBlanc, NASA Ames Modified: Samuel LeBlanc, NASA Ames in Santa Cruz, 2015-12-09 - added comments - added the bins keyword to be used Modified: Samuel LeBlanc, NASA Ames in Santa Cruz, 2015-12-12 - added alpha keyword """ import Sp_parameters as Sp import numpy as np from plotting_utils import data2figpoints (ymask,iy) = Sp.nanmasked(y) ax = fig.add_axes(data2figpoints(pos,0.4,fig=fig,ax1=ax1),frameon=False,ylim=ylim) ax.tick_params(axis='both', which='both', labelleft='off', labelright='off',bottom='off',top='off', labelbottom='off',labeltop='off',right='off',left='off') ax.hist(ymask,orientation='horizontal',normed=True,color=color,edgecolor='None',bins=bins,alpha=alpha,label=label,range=ylim) if onlyhist: label_mean = None label_median = None else: label_mean = 'Mean' label_median = 'Median' ax.axhline(np.mean(ymask),color='red',linewidth=2,label=label_mean) ax.axhline(np.median(ymask),color='k',linewidth=2,linestyle='--',label=label_median) if legend: ax.legend(frameon=False,loc=loc) ax = fig.add_axes(data2figpoints(pos+0.01,-0.4,fig=fig,ax1=ax1),frameon=False,ylim=ylim) ax.tick_params(axis='both', which='both', labelleft='off', labelright='off',bottom='off',top='off', labelbottom='off',labeltop='off',right='off',left='off') ax.hist(ymask,orientation='horizontal',normed=True,color=color,edgecolor='None',bins=bins,alpha=alpha,range=ylim) ax.axhline(np.mean(ymask),color='red',linewidth=2) ax.axhline(np.median(ymask),color='k',linewidth=2,linestyle='--')