Creating plots in a task type

In Python for example Example.Basic.PlotXY uses Core.Python.matplotlib and Core.Python.seaborn to generate a simple plot:

# Avoid requiring tkinter
import matplotlib
matplotlib.use('agg', force=True)

import pandas
import seaborn

import xfworkerutil

worker = xfworkerutil.XFWorkerJob()

inputs = worker.job['inputs']
x_column_name = inputs['x_column_name']
y_column_name = inputs['y_column_name']
mode = inputs['mode']

# Download input files
table_path = worker.download_input_file(inputs['table'])

plot_path = worker.create_related_path(table_path, '_plot.png')

# Plot
data = pandas.read_csv(str(table_path))

if x_column_name is None:
    x_column_name = data.columns[0]
if y_column_name is None:
    y_column_name = data.columns[1]

if mode == 'ci+univariate':
    plot_grid = seaborn.jointplot(x=x_column_name, y=y_column_name, data=data, kind="reg")
    ci = None
    if mode == 'ci':
        ci = 95
    axes = seaborn.regplot(x=x_column_name, y=y_column_name, data=data, ci=ci)
    fig = axes.get_figure()

# Upload output files

# Save outputs
outputs = {
    "plot": worker.create_output_bitmap(,

The plot is stored as an output of type Bitmap.

Chart Report

Also consider using chart reports in XF Desktop for interactive plots.

See also Using R in a task type / Using MATLAB in a task type.