Skip to content

Basic Charts

Here we'll talk about how to plot some basic chart types in DEX using dx.

Setup

We will be using our own built-in DataFrame generation function for these visualizations. The values you see may be different if you run the same code in a cell, but the column structure should be very similar (if not identical).

df = dx.random_dataframe(100)

The Customized examples with more options do not necessarily represent "good" data visualization; they are just a glimpse into what settings are available to compare against the Simple examples.

Bar

Simple

dx.bar(df, x='keyword_column', y='integer_column')

df.plot.bar(x='keyword_column', y='integer_column')

Customized

dx.bar(
    df, 
    x='keyword_column', 
    y='integer_column',
    y2='float_column',
    y2_style='dot',
    horizontal=True,
    bar_width='index',
    group_other=True,
    column_sort_order="desc",
    column_sort_type="string",
    pro_bar_mode="combined",
    combination_mode="max",
    show_bar_labels=True,
)

df.plot.bar(
    x='keyword_column', 
    y='integer_column',
    y2='float_column',
    y2_style='dot',
    horizontal=True,
    bar_width='index',
    group_other=True,
    column_sort_order="desc",
    column_sort_type="string",
    pro_bar_mode="combined",
    combination_mode="max",
    show_bar_labels=True,
)

Chart Name

Coming soon!

Line

Simple

dx.line(df, x='datetime_column', y='integer_column')

df.plot.line(x='datetime_column', y='integer_column')

Customized

You may need to use a larger dataset to see the changes here. For these examples, we used dx.random_dataframe(5000).

dx.line(
    df, 
    x='datetime_column', 
    y='integer_column',
    line_type="cumulative",
    split_by="keyword_column",
    multi_axis=True,
    smoothing="hourly",
    use_count=True,
    bounding_type="relative",
    zero_baseline=True,
    combination_mode="min",
)

df.plot.line(
    x='datetime_column', 
    y='integer_column',
    line_type="cumulative",
    split_by="keyword_column",
    multi_axis=True,
    smoothing="hourly",
    use_count=True,
    bounding_type="relative",
    zero_baseline=True,
    combination_mode="min",
)

Pie

Simple

dx.pie(df, y='index')

df.plot.pie(y='index')

Customized

dx.pie(
    df, 
    y='index',
    split_slices_by='keyword_column',
    show_total=False,
    pie_label_type='annotation',
    pie_label_contents='percent',
)

df.plot.pie(
    y='index',
    split_slices_by='keyword_column',
    show_total=False,
    pie_label_type='annotation',
    pie_label_contents='percent',
)

Scatter

Simple

dx.scatter(df, x='float_column', y='integer_column')

Known Issue

df.plot.scatter() can be used unless size is specified. If you wish to use pandas syntax and provide a size argument, please use df.plot(kind='scatter', ...).

df.plot(kind='scatter', x='float_column', y='integer_column')

Customized

dx.scatter(
    df, 
    x='float_column', 
    y='integer_column',
    size='index',
    trend_line='polynomial',
    marginal_graphics='histogram',
    formula_display='r2'
)

Known Issue

df.plot.scatter() can be used unless size is specified. If you wish to use pandas syntax and provide a size argument, please use df.plot(kind='scatter', ...).

df.plot(
    kind='scatter',
    x='float_column', 
    y='integer_column',
    size='index',
    trend_line='polynomial',
    marginal_graphics='histogram',
    formula_display='r2'
)

Tilemap

Since dx.random_dataframe() returns integer_column values (-100 to 100) and float_column values (0.0 to 1.0) as the only numeric columns by default, we can suggest enabling the lat_float_column and lon_float_column arguments for some quick testing:

df = dx.random_dataframe(100, lat_float_column=True, lon_float_column=True)

More about how Noteable builds with Mapbox here. 🗺️

Simple

dx.tilemap(df, lon='lon_float_column', lat='lat_float_column')

df.plot(kind='tilemap', lon='lon_float_column', lat='lat_float_column')
*Note you can't use df.plot.tilemap() directly

Customized

dx.tilemap(
    df,
    lat='lat_float_column',
    lon='lon_float_column',
    icon_opacity=0.5,
    icon_size='index',
    icon_size_scale="log",
    stroke_color="magenta",
    stroke_width=5,
    label_column='bytes_column',
    tile_layer="light",
    hover_cols=['keyword_column', 'datetime_column'],
)

df.plot(
    kind='tilemap',
    lat='lat_float_column',
    lon='lon_float_column',
    icon_opacity=0.5,
    icon_size='index',
    icon_size_scale="log",
    stroke_color="magenta",
    stroke_width=5,
    label_column='bytes_column',
    tile_layer="light",
    hover_cols=['keyword_column', 'datetime_column'],
)
*Note you can't use df.plot.tilemap() directly

Violin

Simple

dx.violin(df, split_by='keyword_column', metric='integer_column')

df.plot(kind='violin', split_by='keyword_column', metric='integer_column')
*Note you can't use df.plot.violin() directly

Customized

dx.violin(
    df, 
    split_by='keyword_column', 
    metric='integer_column',
    bins=5,
    show_interquartile_range=True,
    column_sort_order='desc',
)

df.plot(
    kind='violin',
    split_by='keyword_column', 
    metric='integer_column',
    bins=5,
    show_interquartile_range=True,
    column_sort_order='desc',
)
*Note you can't use df.plot.violin() directly

Wordcloud

Simple

dx.wordcloud(df, word_column='keyword_column', size='float_column')

df.plot(kind='wordcloud', word_column='keyword_column', size='float_column')
*Note you can't use df.plot.wordcloud() directly

Customized

dx.wordcloud(
    df, 
    word_column='dtype_column',
    size='float_column',
    text_format='token',
    word_rotation='45',
    random_coloring=True,
)

df.plot(
    kind='wordcloud',
    word_column='keyword_column',
    word_column='dtype_column',
    size='float_column',
    text_format='token',
    word_rotation='45',
    random_coloring=True,
)
*Note you can't use df.plot.wordcloud() directly