Skip to content

Add title and subtitle arguments to g2()#20

Merged
yihui-bot merged 13 commits intomainfrom
copilot/research-and-implement-tinyplot-features
Apr 2, 2026
Merged

Add title and subtitle arguments to g2()#20
yihui-bot merged 13 commits intomainfrom
copilot/research-and-implement-tinyplot-features

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 2, 2026

  • Simplify chart_title in g2() to dropNulls(list(title = title, subtitle = subtitle))
  • Remove is.null() checks in build_config() for tooltip/slider/scrollbar
  • Remove NEWS.md changes for v0.1
  • Emphasize no NEWS for v0.1 in copilot instructions
  • Merge latest main; resolve conflict in test-gglite.R (keep both title tests and new tests from main)
  • Add title/subtitle g2() argument examples to examples/titles-tooltips.Rmd

Copilot AI and others added 8 commits April 2, 2026 06:35
… convention)

Agent-Logs-Url: https://github.com/yihui/gglite/sessions/df53ceb6-3fa6-43d1-aba3-b50da99ad847

Co-authored-by: yihui-bot <264330240+yihui-bot@users.noreply.github.com>
Agent-Logs-Url: https://github.com/yihui/gglite/sessions/df53ceb6-3fa6-43d1-aba3-b50da99ad847

Co-authored-by: yihui-bot <264330240+yihui-bot@users.noreply.github.com>
… gg() test

Agent-Logs-Url: https://github.com/yihui/gglite/sessions/df53ceb6-3fa6-43d1-aba3-b50da99ad847

Co-authored-by: yihui-bot <264330240+yihui-bot@users.noreply.github.com>
Copy link
Copy Markdown
Collaborator

@yihui-bot yihui-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

drop the gg alias; it doesn't make any sense: g2 only has two chars, and gg also has two chars; no keystrokes will be saved

change main to title, and sub to subtitle

the by argument is too trivial; users can just specify color = 'Species'

formula | for color also doesn't make much sense; uses can type color = variable name

i don't like alpha or palette; drop them

in the end, only keep title/subtitle; nothing else is good

…t per review

Agent-Logs-Url: https://github.com/yihui/gglite/sessions/2d28c2bc-b9d1-4f63-b367-28a0353f740a

Co-authored-by: yihui-bot <264330240+yihui-bot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 2, 2026

drop the gg alias; it doesn't make any sense: g2 only has two chars, and gg also has two chars; no keystrokes will be saved

change main to title, and sub to subtitle...

Done in 2ed6e9b. Dropped gg(), by, formula | color, alpha, palette, and facet. Renamed maintitle and subsubtitle. Only title/subtitle params remain.

Copilot AI changed the title Ergonomic improvements inspired by tinyplot Add title and subtitle arguments to g2() Apr 2, 2026
Copilot AI requested a review from yihui-bot April 2, 2026 07:04
Comment thread R/gglite.R Outdated
Comment on lines +110 to +112
chart_title = if (!is.null(title)) {
if (!is.null(subtitle)) list(title = title, subtitle = subtitle) else title
},
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are so many is.null() tests in this package; can you remove as many of them as possible? in this specific case, you can simply do

Suggested change
chart_title = if (!is.null(title)) {
if (!is.null(subtitle)) list(title = title, subtitle = subtitle) else title
},
chart_title = list(title = title, subtitle = subtitle),

and drop the NULLs at some point

i don't like this pattern in build_config:

  if (!is.null(chart$chart_title)) config$title = chart$chart_title
  if (!is.null(chart$tooltip_config)) config$tooltip = chart$tooltip_config
  if (!is.null(chart$sliders)) config$slider = chart$sliders
  if (!is.null(chart$scrollbars)) config$scrollbar = chart$scrollbars

there's too much repetition, and even if you remove the !is.null() test, the code still works (assigning NULL to a list item will remove the item)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 1c4c63a. Simplified chart_title to dropNulls(list(title = title, subtitle = subtitle)). Removed the is.null() checks for tooltip_config, sliders, and scrollbars in build_config() — now just direct assignments.

Comment thread NEWS.md Outdated
Comment on lines +10 to +12

- Added `title` and `subtitle` arguments to `g2()` for setting the chart title
and subtitle directly, as a convenient alternative to piping into `title_()`.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i've said this many times and written it in copilot instructions: DON'T INCLUDE NEWS FOR v0.1! (please emphasize this again in copilot instructions)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 1c4c63a. Removed the NEWS entry and strengthened the copilot instructions in both the validation steps and conventions sections to explicitly say: do NOT add NEWS entries while the package is at v0.1.

…EWS for v0.1

Agent-Logs-Url: https://github.com/yihui/gglite/sessions/1f1ea7ca-8cdb-4cc9-9f6f-5bfbe65344d2

Co-authored-by: yihui-bot <264330240+yihui-bot@users.noreply.github.com>
Co-authored-by: yihui-bot <264330240+yihui-bot@users.noreply.github.com>
@yihui-bot yihui-bot marked this pull request as ready for review April 2, 2026 07:30
Copy link
Copy Markdown
Collaborator

@yihui-bot yihui-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also mention this way of specifying title/subtitle in the titles-tooltips.Rmd example

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 2, 2026

also mention this way of specifying title/subtitle in the titles-tooltips.Rmd example

Done in 42c2a3b. Added two new sections at the top of "Chart Title" in examples/titles-tooltips.Rmd showing title = and title = ..., subtitle = ... passed directly to g2().

@yihui-bot yihui-bot merged commit 3c44eb9 into main Apr 2, 2026
5 checks passed
@yihui-bot yihui-bot deleted the copilot/research-and-implement-tinyplot-features branch April 2, 2026 07:37
Copilot AI requested a review from yihui-bot April 2, 2026 07:37
Copilot stopped work on behalf of yihui-bot due to an error April 2, 2026 07:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants