Plots are integral elements to helping users visualize their data in an AI App, and the Virtualitics AI Platform (VAIP) makes it easy to incorporate Plotly’s flexible and interactive plots.
From Plotly:
The plotly Python library is an interactive, open-source plotting library that supports over 40 unique chart types covering a wide range of statistical, financial, geographic, scientific, and 3-dimensional use-cases.
You can leverage Plotly Elements to provide in-App visualizations and encourage interactivity, including the ability to select certain areas of the plot, hover over key elements, hide and show data points from the plot legend, and more.
Creating Plotly Plots
In order to create Plotly plots in your AI App, you’ll first need to include the PlotlyPlot import statement.
from virtualitics_sdk import PlotlyPlot
import plotly.express as px
Once you’ve imported PlotlyPlot, you can create a Plotly Element within a Step, as shown below:
# Imports
from virtualitics_sdk import PlotlyPlot
import plotly.express as px
. . .
# Example usage
class ExampleStep(Step):
def run(self, flow_metadata):
. . .
fig_1 = px.scatter(ex_df,
x="gdpPercap",
y="lifeExp",
size="pop",
color="continent",
log_x=True, size_max=60,
template="predict_default",
title="Gapminder 2007 - Predict")
fig_2 = px.scatter(ex_df,
x="gdpPercap",
y="lifeExp",
size="pop",
color="continent",
log_x=True,
size_max=60,
title="Gapminder 2007 - Default")
pplot_1 = PlotlyPlot(fig_1)
pplot_2 = PlotlyPlot(fig_2)
This code will result in the following inside of an App:
More Plotly Configuration Details
For more details on configuring Plotly plots within an App, see Plotly's documentation. For additional details on incorporating Plotly into your App, see the Virtualitics SDK.