예제 #1
0
def test_irregular_subplots():
    df = cf.datagen.bubble(10, 50, mode='stocks')
    figs = cf.figures(df, [
        dict(kind='histogram', keys='x', color='blue'),
        dict(kind='scatter', mode='markers', x='x', y='y', size=5),
        dict(
            kind='scatter', mode='markers', x='x', y='y', size=5, color='teal')
    ],
                      asList=True)
    figs.append(
        cf.datagen.lines(1).figure(bestfit=False,
                                   colors=['blue'],
                                   bestfit_colors=['pink']))
    base_layout = cf.tools.get_base_layout(figs)
    sp = cf.subplots(
        figs,
        shape=(3, 2),
        base_layout=base_layout,
        vertical_spacing=.15,
        horizontal_spacing=.03,
        specs=[[{
            'rowspan': 2
        }, {}], [None, {}], [{
            'colspan': 2
        }, None]],
        subplot_titles=['Histogram', 'Scatter 1', 'Scatter 2', 'Bestfit Line'])
    sp['layout'].update(showlegend=False)
    return sp
예제 #2
0
def test_irregular_subplots():
	df = cf.datagen.bubble(10, 50, mode='stocks')
	figs = cf.figures(df, [
		dict(kind='histogram', keys='x', color='blue'),
		dict(kind='scatter', mode='markers', x='x', y='y', size=5),
		dict(kind='scatter', mode='markers', x='x', y='y',
			 size=5, color='teal')],asList=True)
	figs.append(cf.datagen.lines(1).figure(bestfit=False, colors=['blue'],
										   bestfit_colors=['pink']))
	base_layout = cf.tools.get_base_layout(figs)
	sp = cf.subplots(figs, shape=(3, 2), base_layout=base_layout,
					 vertical_spacing=.15, horizontal_spacing=.03,
					 specs=[[{'rowspan': 2}, {}], [None, {}],
							[{'colspan': 2}, None]],
					 subplot_titles=['Histogram', 'Scatter 1',
									 'Scatter 2', 'Bestfit Line'])
	sp['layout'].update(showlegend=False)
	return sp
예제 #3
0
def test_irregular_subplots():
    df = cf.datagen.bubble(10, 50, mode="stocks")
    figs = cf.figures(
        df,
        [
            dict(kind="histogram", keys="x", color="blue"),
            dict(kind="scatter", mode="markers", x="x", y="y", size=5),
            dict(kind="scatter", mode="markers", x="x", y="y", size=5, color="teal"),
        ],
        asList=True,
    )
    figs.append(cf.datagen.lines(1).figure(bestfit=False, colors=["blue"], bestfit_colors=["pink"]))
    base_layout = cf.tools.get_base_layout(figs)
    sp = cf.subplots(
        figs,
        shape=(3, 2),
        base_layout=base_layout,
        vertical_spacing=0.15,
        horizontal_spacing=0.03,
        specs=[[{"rowspan": 2}, {}], [None, {}], [{"colspan": 2}, None]],
        subplot_titles=["Histogram", "Scatter 1", "Scatter 2", "Bestfit Line"],
    )
    sp["layout"].update(showlegend=False)
    return sp
예제 #4
0
df = pd.DataFrame(np.random.randn(1000, 4), columns=['a', 'b', 'c', 'd'])
df.scatter_matrix()

df = cf.datagen.lines(4)
df.iplot(subplots=True,
         shape=(4, 1),
         shared_xaxes=True,
         vertical_spacing=.02,
         fill=True)
df.iplot(subplots=True, subplot_titles=True, legend=False)

df = cf.datagen.bubble(10, 50, mode='stocks')
figs = cf.figures(df, [
    dict(kind='histogram', keys='x', color='blue'),
    dict(kind='scatter', mode='markers', x='x', y='y', size=5),
    dict(kind='scatter', mode='markers', x='x', y='y', size=5, color='teal')
],
                  asList=True)
figs.append(
    cf.datagen.lines(1).figure(bestfit=True,
                               colors=['blue'],
                               bestfit_colors=['pink']))
base_layout = cf.tools.get_base_layout(figs)
sp = cf.subplots(
    figs,
    shape=(3, 2),
    base_layout=base_layout,
    vertical_spacing=.15,
    horizontal_spacing=.03,
    specs=[[{
        'rowspan': 2
                  title='up视频质量走势参考',
                  xTitle='时间',
                  yTitle='比率')
        return df3.figure(
            kind='lines',
            orientation='v',
        )

    def month_video_play(self):
        df1 = self.df_data[[
            'created', 'stat#favorite', 'stat#coin', 'stat#like'
        ]]
        df2 = df1.groupby([df1.created.dt.year,
                           df1.created.dt.month]).agg('sum')
        # df2.iplot(kind='bar', barmode='stack', orientation='v')
        df2.iplot(kind='histogram', bins=10)
        return df2


if __name__ == '__main__':
    upid = 176037767
    analysis_video = AnalysisVideo(upid)
    figs = cf.figures(analysis_video.month_video_play(),
                      [dict(kind='bar', barmode='stack')],
                      asList=True)
    figs.append(analysis_video.month_video_play_rate())
    layout = cf.tools.get_base_layout(figs)
    sp = cf.subplots(figs, shape=(1, 2), base_layout=layout)
    sp['layout'].update(showlegend=False)
    cf.iplot(sp)