Skip to main content

Python example

Overview

Figlinq is compatible with Plotly's Chart Studio Python API, and you can use Plotly's Python chart_studio package to interact with content on Figlinq. This simple example illustrates how you can use this package to create a simple line chart and save it, together with associated data, to your Figlinq account.

API key and username

To connect to your Figlinq account, you will need to provide your username and API key. You can find both in your account page. There, you can also create a new API key if needed.

Privacy settings

By default, all plots and data grids created with the Python API are currently public. Make sure to override this setting by including the world_readable parameter set to False in the set_config_file function.

Example

# Import required libraries
import chart_studio
import chart_studio.plotly as py
import plotly.graph_objects as go

# Set credentials and privacy settings
chart_studio.tools.set_config_file(
plotly_domain='https://create.figlinq.com',
plotly_api_domain='https://create.figlinq.com',
plotly_streaming_domain='https://stream.figlinq.com',
world_readable=False,
sharing='private'
)
chart_studio.tools.set_credentials_file(username='YOUR_USER_NAME', api_key='YOUR_API_KEY')

# Create traces
trace0 = go.Scatter(
x=[1, 2, 3, 4],
y=[10, 15, 13, 17]
)
trace1 = go.Scatter(
x=[1, 2, 3, 4],
y=[16, 5, 11, 9]
)
data = [trace0, trace1]

# Set some basic plot styling
layout=go.Layout(
width=400,
height=360,
autosize=False,
plot_bgcolor='white',
title=dict(
text='Example Plot with Custom Styling',
x=0.5,
xanchor='center',
yanchor='top',
),
xaxis=dict(
showgrid=False,
title='X Axis',
titlefont=dict(size=14),
tickfont=dict(size=14),
linewidth=1,
linecolor='black',
ticklen=5,
ticks='outside',
),
yaxis=dict(
showgrid=False,
title='Y Axis',
titlefont=dict(size=14),
tickfont=dict(size=14),
linewidth=1,
linecolor='black',
ticklen=5,
ticks='outside',
),
)

# Create plot and save to Figlinq
fig = go.Figure(data=data, layout=layout)
py.plot(fig, filename = 'Simple line chart', auto_open=True)

Result

  • After running the script, your default browser will open the newly-created plot in view mode.
  • If you receive a 404 error after the browser opens, you are likely not logged in. Please make sure that you are logged in to your Figlinq account in your default browser before running the script.
  • The newly-created plot and data grid will be available in your home directory - from there you can move them to other folders and edit, restyle, add to a figure or share.
  • If you run the script multiple times without changing the filename, the plot and grid will be overwritten.

chart_studio.plotly.plot Function

Overview

The plot function in the Chart Studio Plotly library is used to create and upload interactive Plotly graphs directly from Python. This function facilitates the process of creating and sharing high-quality, interactive visualizations in Figlinq.

Syntax

import chart_studio.plotly as py
response = py.plot(figure, **kwargs)

Input Arguments

figure: A plotly.graph_objects.Figure or plotly.graph_objs.Figure object containing the data and layout of the graph. **kwargs: Specify optional parameters using keyword arguments. Available options are:

  • filename: [string]{'untitled'} - Filename as appears on Chart Studio.
  • fileopt: [string]{'new'} - One of the following options: 'new', 'overwrite', 'extend', 'append'.
  • auto_open: [boolean]{True} - Open plot in browser (True).
  • sharing: [string]{'public'} - One of the following options: 'public', 'private', 'secret'.

Output

response: A string containing the URL of the created Figling plot.