When you prepare a presentation or a report, you often need to manage a large number of ggplot figures. You need to change the figure size, modify the title, label, themes, etc. It is inconvinient to go back to the original code to make these changes. This package provides a simple way to manage ggplot figures.
You can easily add the figure to the database and manage it later using CLI (command line interface) or GUI (graphical user interface).
ggfigdone_manage.mov
Utilizing the LLM to convert your idea in natural language into {ggplot2} code.
ggfigdone_llm.mov
Install the stable version from CRAN:
install.packages("ggfigdone")
Install the development version from GitHub:
# install.packages("remotes")
remotes::install_github("wenjie1991/ggfigdone")
First, you need to initialize the database and add figures to it.
Next time, you only need to load the database to add more figures or update the existing figures.
library(ggfigdone)
library(ggplot2)
## Initial ggfigdone database using `fd_init`
## The database location is `./fd_dir`
## Load existing database using `fd_load("./fd_dir")`
fo = fd_init("./fd_dir")
## Draw a ggplot figure
g = ggplot(mtcars, aes(x=wt, y=mpg)) + geom_point()
## Add the figure to the database
## The last plot is added to the last initialized/loaded database
fd_add(name = "fig1")
## Add the same figure with a different name
## You can specify the ggplot object and database name
fd_add(g = g, name = "fig2", fo)
## The hard disk database is automatically updated, no need to save operations.
Then you can start the server and open the browser to manage the figures.
## To start the server, provide the database location
fd_server("./fd_dir")
## Open the browser and go to http://localhost:8080/index.html
OpenAI API
To get API key, you can visit the OpenAI website at https://openai.com/ and follow the instructions in the video. You may need to update your payment methods.
openAI_key_720k.mov
Free API key
You can find free LLM service at this link: https://github.com/cheahjs/free-llm-api-resources
The following video demonstrates how to apply the GroqCloud key for free.
Link: https://console.groq.com/login
groq_free_key.mov
Example: OpenAI service
The default configuration is the OpenAI service, where you only need to provide the OpenAI API key.
fd_server("./fd_dir",
llm_api_key = "sk-use_your_own_key_here")
)
Example: Groq service
To use Croq or any other service, you must configure the parameters llm_api_url
, llm_api_key
, and llm_model
.
fd_server("./fd_dir",
llm_api_url = "https://api.groq.com/openai/v1/chat/completions",
llm_api_key = "gsk_use_your_own_key_here",
llm_model = "llama-3.3-70b-versatile"
)
You can configure the default LLM service in .Rprofile
using the following code.
options(
ggfigdone.llm_api_key = "gsk-use_your_own_key_here",
ggfigdone.llm_api_url = "https://api.groq.com/openai/v1/chat/completions",
ggfigdone.llm_model = "llama-3.3-70b-versatile",
ggfigdone.llm_temperature = "0.5",
ggfigdone.llm_max_tokens = 1000
)
This package is being developed. Feel free to contribute to the package by sending pull requests or creating issues.
MIT