Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor hardcoded "magic numbers" in legend.grob #9

Merged
merged 1 commit into from
Oct 16, 2021

Conversation

dan-knight
Copy link
Contributor

  • I have read the code review guidelines and the code review best practice on GitHub check-list.

  • The name of the branch is meaningful and well formatted following the standards, using [AD_username (or 5 letters of AD if AD is too long)-[brief_description_of_branch].

  • I have set up or verified the branch protection rule following the github standards before opening this pull request.

  • I have added the changes included in this pull request to NEWS under the next release version or unreleased, and updated the date.

  • I have updated the version number in metadata.yaml and DESCRIPTION.

  • Both R CMD build and R CMD check run successfully.

Closes #8

The values mentioned in the issue are explained in this comment (found earlier in the file).

# Create a layout for the legends
# Each legend gets an extra row for its title
# There is also an extra empty row/column inserted between each of the legends to allow for nicer spacing

Instead of creating multiple comments to explain the same value, it made more sense to change the repeated hardcoded values to variables.

Testing Results

legends <- list(
	legend = list(
		colours = c('orange', 'chartreuse4', 'darkorchid4'),
		labels = c('Group 1', 'Group 2', 'Group 3'),
		title = expression(underline('Legend #1'))
		),
	# Use dots instead of rectangles
	point = list(
		colours = c('firebrick3', 'lightgrey'),
		labels = c('A label', 'A longer label'),
		# Set dot size
		cex = 1.5
		)
	)
	
legend.grob(
	legends = legends,
	border = list(col = 'blue', lwd = 2, lty = 3),
	border.padding = 1.5,
	between.row = 3
	);

@dan-knight dan-knight merged commit 0f1fd67 into main Oct 16, 2021
@dan-knight dan-knight deleted the danknight-legend-layout branch October 16, 2021 00:07
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.

Unexplained Values in legend.grob
2 participants