User Workbench
This section provides a comprehensive guide on how to use the Visual Viper library for various tasks. Whether you are a researcher, a data scientist, or a developer, you’ll find actionable steps and examples here.
Getting Started
Start by importing the library. Here is a simple example:
from visual_viper import *
Creating a Basic Chart: Forest Plot using Google Spreadsheet Data
This example demonstrates how to create a forest plot using data fetched from Google Spreadsheets with named ranges and deploy the resulting chart to Google Drive.
Initialize the Orchestrator
Initialize the VisualViperOrchestrator which will coordinate the entire process.
vv = VisualViperOrchestrator()
Register Components
Register the dataset builder, chart renderer, and chart deployer.
vv.register_dataset_builder(GoogleSpreadsheetDatasetBuilder()) vv.register_chart_renderer(AltairChartRenderer()) vv.register_chart_deployer(GdriveChartDeployer( folder_id="your_google_drive_folder_id", mime_type="image/svg+xml" ))
Data Source Configuration for Forest Plots
This step involves setting up the configuration for generating a forest plot. Here, you’ll specify where to source various data metrics for the plot using the ForestPlot and ForestPlotBinding classes.
Understanding the `Key` Class
The Key class is crucial for specifying data sources. Each Key instance requires two pieces of information:
Named Range: A string identifier that points to the specific metric in the Google Spreadsheet.
Spreadsheet ID: The unique identifier for the Google Spreadsheet.
These allow the system to fetch the exact data you need for your forest plot.
notation_builder = ForestPlot( id="the_id_for_the_plot", title="the_title_for_the_plot", subtitle="the_subtitle_for_the_plot", bindings=[ ForestPlotBinding( measure="your_measure", hr=Key("your_hr_named_range", "your_spreadsheet_id"), lo=Key("your_low_ci_named_range", "your_spreadsheet_id"), hi=Key("your_high_ci_named_range", "your_spreadsheet_id"), ), # Add more bindings as needed ] ) vv.register_notation_builder(notation_builder)
Both title`and `subtitle may be either a string or a list with strings (each element of the list will be printed in a different line).
Run the Process
Finally, execute the entire process to generate and deploy the forest plot.
vv.run()