This guide will help you get up and running with PlotSense in just a few minutes.
Before you begin, make sure you have:
- Python 3.7 or higher
- pandas library installed
- A Groq API key (required for AI features)
Install PlotSense using pip:
pip install plotsensePlotSense requires a Groq API key for its AI-powered features. You can obtain a free API key from Groq's website.
You can configure your API key in several ways:
-
Environment Variable (Recommended):
export GROQ_API_KEY="your-api-key-here"
-
In Your Python Code:
import os os.environ["GROQ_API_KEY"] = "your-api-key-here"
Let's create your first AI-powered visualization:
from plotsense import recommender
from plotsense import plotgen
from plotsense import explainer
import pandas as pd
# Create sample data
data = {
'x': [1, 2, 3, 4, 5],
'y': [2, 5, 3, 8, 7],
'category': ['A', 'B', 'A', 'B', 'A']
}
df = pd.DataFrame(data)
# Step 1: Get AI recommendations
print("Getting AI recommendations...")
suggestions = recommender(df)
print(f"Found {len(suggestions)} visualization suggestions")
# Step 2: Generate a plot from the first suggestion
print("Generating plot...")
plot = plotgen(df, suggestions.iloc[0])
# Step 3: Get AI explanation
print("Getting AI explanation...")
explanation = explainer(plot)
print(f"Explanation: {explanation}")PlotSense follows a simple three-step workflow:
- Analyzes your dataset structure
- Returns up to 10 visualization suggestions
- Each suggestion includes plot type and recommended variables
- Takes your DataFrame and a recommendation
- Generates the actual visualization
- Returns a plot object you can display or save
- Analyzes your generated plot
- Provides natural language insights
- Helps you understand patterns in your data
Here's how to use PlotSense with your own datasets:
from plotsense import recommender
from plotsense import plotgen
from plotsense import explainer
import pandas as pd
# Load your data
df = pd.read_csv("your_dataset.csv")
# Get recommendations
suggestions = recommender(df)
# Explore different suggestions
for i, suggestion in suggestions.iterrows():
print(f"Suggestion {i+1}: {suggestion['plot_type']} - {suggestion['description']}")
# Generate your preferred plot
selected_suggestion = suggestions.iloc[0] # or choose any index
plot = plotgen(df, selected_suggestion)
# Get insights
explanation = explainer(plot)
print(explanation)Now that you have PlotSense working, explore:
- API Reference - Detailed documentation of all functions
- Examples - More comprehensive examples and use cases
- Configuration - Advanced configuration options
- Troubleshooting - Common issues and solutions
- Clean Data: Ensure your data is properly formatted and doesn't have missing values in key columns
- Meaningful Column Names: Use descriptive column names to help the AI understand your data
- Appropriate Data Size: PlotSense works best with datasets that have between 10-10,000 rows
- Mixed Data Types: Include both numerical and categorical columns for more visualization options