Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Docs] Add vizro-ai chart examples to docs #469

Merged
merged 16 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!--
A new scriv changelog fragment.

Uncomment the section that is right (remove the HTML comment wrapper).
-->

<!--
### Highlights ✨

- A bullet item for the Highlights ✨ category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1))

-->
<!--
### Removed

- A bullet item for the Removed category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1))

-->
<!--
### Added

- A bullet item for the Added category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1))

-->
<!--
### Changed

- A bullet item for the Changed category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1))

-->
<!--
### Deprecated

- A bullet item for the Deprecated category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1))

-->
<!--
### Fixed

- A bullet item for the Fixed category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1))

-->
<!--
### Security

- A bullet item for the Security category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1))

-->
Binary file added vizro-ai/docs/assets/user_guides/map_chart.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion vizro-ai/docs/pages/tutorials/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ vizro_ai.plot(df, "create a line graph for GDP per capita since 1950 for each co

`INFO:httpx:HTTP Request: POST https://api.openai.com/v1/chat/completions "HTTP/1.1 401 Unauthorized"`

Make sure you have [set up access to a large language model](../user-guides/install/#set-up-access-to-a-large-language-model). If you are confident that you have specified your API key correctly and have sufficient credits associated with it, check your environment. Some developers export the environment explicitly to ensure the API key is available at runtime. Call the following in your terminal:
Make sure you have [set up access to a large language model](../user-guides/install.md/#set-up-access-to-a-large-language-model). If you are confident that you have specified your API key correctly and have sufficient credits associated with it, check your environment. Some developers export the environment explicitly to ensure the API key is available at runtime. Call the following in your terminal:

`export OPENAI_API_KEY="sk-YOURKEY"`.

Expand Down
92 changes: 92 additions & 0 deletions vizro-ai/docs/pages/user-guides/chart-examples.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Explore VizroAI
nadijagraca marked this conversation as resolved.
Show resolved Hide resolved

In this guide, we'll learn how to make more advanced charts with Plotly using data from [Plotly Express](https://plotly.com/python-api-reference/generated/plotly.express.data.html). The examples below use the OpenAI `"gpt-4-0613"` model as we are going to request specific updates to the layout of the charts, which are [more complex than the default GPT 3.5 model can handle](./customize-vizro-ai.md).
nadijagraca marked this conversation as resolved.
Show resolved Hide resolved

### Create a polar bar chart
nadijagraca marked this conversation as resolved.
Show resolved Hide resolved

A polar bar chart is a circular graph where each axis represents a different variable, typically used for displaying cyclical or directional data.
It's suitable for quickly comparing multiple variables across different categories or directions. Let's make one using Vizro-AI.


!!! example "Polar Bar Chart"

=== "Code for the cell"
```py
import vizro_ai
from vizro_ai import VizroAI
import plotly.express as px

from dotenv import load_dotenv
load_dotenv()

df = px.data.wind()

vizro_ai = VizroAI(model="gpt-4-0613")
vizro_ai.plot(df,
"""Describe wind frequency and direction using bar_polar chart.
Increase the width and height of the figure.
Improve layout by placing title to the left. Show legend""", explain=True)

```
=== "Resulting chart"
[![VizroAIChart1]][VizroAIChart1]

[VizroAIChart1]: ../../assets/user_guides/polar_bar_chart.png
stichbury marked this conversation as resolved.
Show resolved Hide resolved


### Create a geographical map chart
nadijagraca marked this conversation as resolved.
Show resolved Hide resolved

The next chart we'll look at is a geographical map chart to visualize spatial patterns in data, which often reveals insights not seen in other charts.

!!! example "Map chart"

=== "Code for the cell"
```py
import vizro_ai
from vizro_ai import VizroAI
import plotly.express as px

from dotenv import load_dotenv
load_dotenv()

df = px.data.wind()

vizro_ai = VizroAI(model="gpt-4-0613")
vizro_ai.plot(df,
"""Visualize life expectancy over the years using map chart. Use life expectancy as the color dimension.
Improve layout by using Arial font. Increase the width and height of the map area. Outline continents on the map.
Show countries on the map.
Increase the width and height of the figure.""", explain=True)

```
=== "Resulting chart"
[![VizroAIChart2]][VizroAIChart2]

[VizroAIChart2]: ../../assets/user_guides/map_chart.gif


### Create a surface plot
nadijagraca marked this conversation as resolved.
Show resolved Hide resolved

Let's explore how to generate a 3-dimensional surface plot with VizroAI.

!!! example "Surface plot"

=== "Code for the cell"
```py
import vizro_ai
from vizro_ai import VizroAI
import plotly.express as px

from dotenv import load_dotenv
load_dotenv()

df = px.data.gapminder()

vizro_ai = VizroAI(model="gpt-4-0613")
vizro_ai.plot(df, "create a surface plot")

```
=== "Resulting chart"
[![VizroAIChart3]][VizroAIChart3]

[VizroAIChart3]: ../../assets/user_guides/surface_plot.gif
6 changes: 4 additions & 2 deletions vizro-ai/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ nav:
- Advanced charts: pages/user-guides/create-advanced-charts.md
- Different languages: pages/user-guides/use-different-languages.md
- Vizro-AI charts in dashboards: pages/user-guides/add-generated-chart-usecase.md
- API Reference:
- VizroAI: pages/API-reference/vizro-ai.md
- Explanation:
- FAQs: pages/explanation/faq.md
- Disclaimer: pages/explanation/disclaimer.md
- Safeguard code execution: pages/explanation/safeguard.md
- Safety in Vizro-AI: pages/explanation/safety-in-vizro-ai.md
- API Reference:
- VizroAI: pages/API-reference/vizro-ai.md
- Examples:
stichbury marked this conversation as resolved.
Show resolved Hide resolved
- Chart examples: pages/user-guides/chart-examples.md
#- Contribute:
# - Contributing: pages/contribute/contributing.md
- Vizro:
Expand Down
Loading