PlotAI: Simplifying Plot Creation in Python
PlotAI is a revolutionary tool designed to make plot creation in Python using Matplotlib easier than ever. By harnessing the power of Large Language Models (LLM), PlotAI streamlines the process, transforming user inputs into Python code that generates plots effortlessly.
How PlotAI Works
PlotAI operates through a straightforward process:
- A user supplies an input DataFrame and a prompt describing the type of plot desired.
- PlotAI constructs a prompt for the LLM, including the first five rows of the DataFrame and the user’s prompt, and requests Python code in response.
- The generated Python code is executed to produce and display the plot.
Using PlotAI: A Simple API
PlotAI features a minimalistic API with a single method, make()
, making it accessible for both beginners and experienced users. It is compatible with Python scripts and various notebooks such as Jupyter, Colab, and VS Code.
Getting Started with PlotAI
To start using PlotAI, follow these simple steps:
-
Installation: Install the PlotAI package using pip:
pip install plotai
-
OpenAI API Key: Create a
.env
file with your OpenAI API key:OPENAI_API_KEY=your-key-here
Alternatively, set the API key directly in Python:
import os os.environ["OPENAI_API_KEY"] = "your-key-here"
-
Creating a Plot: Import PlotAI and create plots by simply instructing it:
from plotai import PlotAI import pandas as pd df = pd.DataFrame({"x":[1,2,3], "y": [4,5,6]}) plot = PlotAI(df) plot.make("scatter plot")
PlotAI uses the gpt-3.5-turbo
model by default, but users can select other OpenAI models if needed.
Examples and Demonstrations
PlotAI can handle complex data analyses, such as analyzing the GDP or Iris datasets, illustrating its versatility in various applications.
Connecting with PlotAI
For updates and discussions, users can follow PlotAI on Twitter and LinkedIn. Engaging with the team and community can provide insights and opportunities to collaborate.
Limitations to Note
PlotAI is currently in an experimental phase, and users should be aware of certain limitations:
- It primarily uses the OpenAI ChatGPT-3.5-turbo model but may expand to other LLMs in the future.
- Only the first five rows of the DataFrame are shared with OpenAI ChatGPT. Users should handle sensitive data carefully.
- Executing Python code returned by an LLM could pose security risks. Future updates might include an option to review the code before execution.
Disclaimer
PlotAI is provided as-is, and users assume all risks associated with its use. Regular monitoring of OpenAI API usage is recommended due to potential costs.
Future Developments
The team behind PlotAI is also developing Mercury, an open-source framework for converting Python notebooks into interactive web applications. This project promises even more capabilities for users seeking to share their Python tools and analyses online.
PlotAI is an innovative project that simplifies data visualization in Python, making it accessible and user-friendly, whether you're a data scientist, analyst, or a Python enthusiast.