How to use the seaborn.jointplot function in seaborn

To help you get started, we’ve selected a few seaborn examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DUanalytics / pyAnalytics / 45-stats1 / 40G7_stats_mtcars.py View on Github external
plt.show();

#%% Histogram
data.mpg.plot(kind='hist')
data.wt.plot(kind='hist', bins=3)
data.Weight.value_counts().plot.bar() #same, order of category is changed
plt.hist(data.wt, bins = 5, stacked=True, normed=True, color='green' )
color=['red','green','blue','purple','black']
import seaborn as sns
sns.distplot(data.wt);
sns.distplot(data.wt, kde=False, rug=True);  #no curve, rug lines at bottom
sns.distplot(data.mpg, bins=20, kde=False, rug=True); #more bins, no curve
sns.distplot(data.mpg, hist=False, rug=True); #without density
sns.jointplot(x="wt", y="mpg", data=data);
sns.jointplot(x="wt", y="mpg", data=data, kind="kde");
sns.jointplot(x="x", y="y", data=df, );
#Links:https://seaborn.pydata.org/tutorial/distributions.html
f, ax = plt.subplots(figsize=(6, 6))
sns.kdeplot(data.wt, data.mpg, ax=ax)
sns.rugplot(data.wt, color="g", ax=ax)
sns.rugplot(data.mpg, vertical=True, ax=ax);
#%% Pair Plot
sns.pairplot(data[['wt','mpg', 'hp', 'qsec']]);
#%%% 


#%%%
#%%%outliers
#In statistics, an outlier is an observation point that is distant from other observations.
sns.boxplot(x=data['mpg'])
#The Z-score is the signed number of standard deviations by which the value of an observation or data point is above the mean value of what is being observed or measured
#Links: https://towardsdatascience.com/ways-to-detect-and-remove-the-outliers-404d16608dba
github tech-quantum / sia-cog / Interface / plotmgr.py View on Github external
def Axis_JointPlot(data, x, y, kind="scatter"):
    sns.set(style="white", color_codes=True)
    g = sns.jointplot(x, y, data, kind)
    d = mpld3.fig_to_dict(g.fig)

    return d
github DUanalytics / pyAnalytics / 74-sns / sns03_plots.py View on Github external
#Pair 
sns.pairplot(mtcars[['mpg','wt']])
sns.pairplot(mtcars)


#Facet
grid = sns.FacetGrid(mtcars, row='gear', col='cyl', margin_titles=True)
grid.map(plt.hist, 'mpg', bins=np.linspace(0,35,5))

#Factor Plot
g= sns.factorplot('cyl', 'wt', hue='am', data=mtcars, kind='box')
g.set_axis_labels('Mileage', 'Weight')


#Joint Distributions
sns.jointplot('wt', 'mpg', data=mtcars)
sns.jointplot('wt', 'mpg', data=mtcars, kind='reg')


#Bar Plots
g = sns.factorplot(x='mpg', y=None, data=mtcars, aspect=1, kind='count', color='blue')
g.set_xticklabels(step=5)
#with cat colomn
g = sns.factorplot(x='cyl', y=None, data=mtcars, aspect=1, kind='count', color='blue')
#g.set_xticklabels(step=1)# not reqd here
github Ashton-Sidhu / aethos / aethos / visualizations / visualize.py View on Github external
Kind of plot to draw, by default 'scatter'

    ouput_file : str
        Output file name for the image including extension (.jpg, .png, etc.)
    """

    # NOTE: Ignore the deprecation warning for showing the R^2 statistic until Seaborn reimplements it
    import warnings
    from scipy import stats

    warnings.simplefilter("ignore", UserWarning)

    sns.set(style="ticks", color_codes=True)
    color = kwargs.pop("color", "crimson")

    g = sns.jointplot(x=x, y=y, data=df, kind=kind, color=color, **kwargs).annotate(
        stats.pearsonr
    )

    if output_file:  # pragma: no cover
        g.savefig(os.path.join(IMAGE_DIR, output_file))

    return g
github calico / basenji / bin / basenji_hypers.py View on Github external
def jointplot(vals1, vals2, out_pdf):
  plt.figure()
  g = sns.jointplot(vals1, vals2, alpha=0.8, color='black')
  ax = g.ax_joint
  xmin, xmax = scatter_lims(vals1)
  ymin, ymax = scatter_lims(vals2)
  ax.plot([xmin, xmax], [ymin, ymax], linestyle='--', color='black')
  ax.set_xlim(xmin, xmax)
  ax.set_ylim(ymin, ymax)
  ax.grid(True, linestyle=':')
  plt.tight_layout(w_pad=0, h_pad=0)
  plt.savefig(out_pdf)
  plt.close()
github davek44 / Basset / src / basset_motifs_infl.py View on Github external
#################################################################
    # plot filter influence
    #################################################################
    sb_blue = sns.color_palette('deep')[0]
    sns.set(style='ticks', font_scale=1)
    ymin, ymax = coord_range(filter_infl, buf_pct=0.1)

    if options.motifs_file:
        nonzero = np.array(df_motifs.ic > 0)
        xmin, xmax = coord_range(df_motifs.ic.loc[nonzero])
        plt.figure()

        if not options.color_filters:
            g = sns.jointplot(x=np.array(df_motifs.ic.loc[nonzero]), y=filter_infl[nonzero], color='black', stat_func=None, joint_kws={'alpha':0.8})
        else:
            g = sns.jointplot(x=np.array(df_motifs.ic.loc[nonzero]), y=filter_infl[nonzero], color='black', stat_func=None, joint_kws={'alpha':0.1})

            ax = g.ax_joint
            unannotated = np.logical_and(nonzero, np.array(df_motifs.annotation == '.'))
            ax.scatter(np.array(df_motifs.ic.loc[unannotated]), filter_infl[unannotated], c='#ee8b00', alpha=0.5, linewidths=0)
            annotated = np.array(df_motifs.annotation != '.')
            ax.scatter(np.array(df_motifs.ic.loc[annotated]), filter_infl[annotated], c='#1ba100', alpha=0.5, linewidths=0)

        ax.set_xlim(xmin, xmax)
        ax.set_xlabel('Information content')
        ax.xaxis.label.set_fontsize(18)
        map(lambda xl: xl.set_fontsize(15), ax.get_xticklabels())
        ax.set_ylim(ymin, ymax)
        ax.set_ylabel('Influence')
        ax.yaxis.label.set_fontsize(18)
github wgurecky / StarVine / starvine / bvcopula / bv_plot.py View on Github external
def bvJointPlot(u, v, corr_stat="kendalltau", vs=None, **kwargs):
    stat_funcs = {"kendalltau": kendalltau,
                  "spearmanr": spearmanr,
                  "pearsonr": pearsonr}
    outfile = kwargs.pop("savefig", None)
    joint_plt = sns.jointplot(x=u, y=v, stat_func=stat_funcs[corr_stat], zorder=2, label="resampled", **kwargs)
    vsData = vs
    if vsData is not None:
        joint_plt.x, joint_plt.y = vsData[0], vsData[1]
        sb_color = sns.xkcd_palette(["faded green"])[0]
        joint_plt.plot_joint(plt.scatter, s=4, alpha=0.7, c=sb_color, marker='o', edgecolors='face', label="original", zorder=1)
    plt.legend()
    if outfile:
        joint_plt.savefig(outfile)
    return joint_plt
github bretthandrews / flexce / flexce / scripts / plot_xfe.py View on Github external
params = yml.read(config_file)

    abunds = [txt.read_abundances(path_sim, sim_id=sim_id) for sim_id in params['sim_ids']]

    colors = putils.get_colors(params)

    # Make plot
    for ii, (ab, color) in enumerate(zip(abunds, colors)):
        marg_kws = {
            'norm_hist': True,
            'hist_kws': {'weights': ab.Survivors.values}
        }

        if ii == 0:
            fig = sns.jointplot('[Fe/H]', params['ab'], data=ab, stat_func=None,
                                color=color, marginal_kws=marg_kws)

        else:
            fig = putils.joint_overplot('[Fe/H]', params['ab'], data=ab,
                                        fig=fig, color=color, marg_kws=marg_kws)

    # Make legend
    p = putils.get_path_collections(fig)
    leg_args = putils.get_leg_args(params)
    leg = fig.ax_joint.legend(p, params['labels'], **leg_args)

    fout = join(path_out, os.path.splitext(os.path.basename(config_file))[0] + '.pdf')
    plt.savefig(fout)
    print(f'Wrote: {fout}')
github bretthandrews / flexce / flexCE / plot / plot_xfe_feh.py View on Github external
cfg = cfg_io.read_plot_config(join(path_config, fin))
colors = utils.get_colors(cfg)
abund = cfg['General']['abundance']
labels = cfg['General']['labels']

# Read in simulation results
sims = []
for sim_id in cfg['General']['sim_ids']:
    sims.append(txt_io.load_dataframe(path_output, sim_id))

# Make plot
for i, (sim, color) in enumerate(zip(sims, colors)):
    marg_kws = dict(norm_hist=True,
                    hist_kws=dict(weights=sim.Survivors.values))
    if i == 0:
        fig = sns.jointplot('[Fe/H]', abund, data=sim, stat_func=None,
                            color=color, marginal_kws=marg_kws)
    else:
        fig = utils.joint_overplot('[Fe/H]', abund, df=sim, fig=fig,
                                   color=color, marg_kws=marg_kws)

# Make legend
p = utils.get_path_collections(fig)
leg_args = utils.get_leg_args(cfg)
leg = fig.ax_joint.legend(p, labels, **leg_args)

# Save plot
fout = ''.join((os.path.splitext(fin)[0], '.pdf'))
plt.savefig(join(path_plots, fout))
github erikbern / mta / plot_wait_time.py View on Github external
u = (t + (19 * 60 * 60)) % (24 * 60 * 60)
        j = bisect.bisect(sched_trips[key], u)
        if j < len(sched_trips[key]):
            u1 = sched_trips[key][j]
        else:
            u1 = 24 * 60 * 60 + sched_trips[key][0]
        sched_wait_time = u1 - u

        if max(sched_wait_time, real_wait_time) < MAX:
            xs.append(sched_wait_time / 60.)
            ys.append(real_wait_time / 60.)

        if sched_wait_time < MAX:
            ys_by_x[int(sched_wait_time / 60.0)].append(real_wait_time / 60.)

seaborn.jointplot(numpy.array(xs), numpy.array(ys), kind='hex')
pyplot.savefig('wait_time_real_vs_sched_joint.png')

pyplot.clf()
percs = [50, 60, 70, 80, 90]
results = [[] for p in percs]
for x, ys in enumerate(ys_by_x):
    print x, len(ys)
    ps = numpy.percentile(ys, percs)
    for i, y in enumerate(ps):
        results[i].append(y)

for i, ys in enumerate(results):
    pyplot.plot(range(len(ys)), ys, label='%d percentile' % percs[i])
pyplot.ylim([0, 60])
pyplot.title('How long do you have to wait given how much schedule predicts')
pyplot.xlabel('Scheduled waiting time (min)')