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

Add vignette for plt_tize() #12

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Add vignette for plt_tize() #12

wants to merge 1 commit into from

Conversation

ivelasq
Copy link
Collaborator

@ivelasq ivelasq commented Apr 26, 2023

Closes #11

Add vignette for plt_tize() 🐧

@ivelasq ivelasq requested a review from gvelasq April 26, 2023 00:25
)
```

This vignette demonstrates how to use the {palettizer} package to generate a color palette from an image and apply it to a {ggplot2} plot using the palmerpenguins dataset.
Copy link
Owner

Choose a reason for hiding this comment

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

Should palmerpenguins have curly braces like the other package names? Or no curly braces for any package?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Do you have a preference? I'll go through and make sure they all match.

Copy link
Owner

Choose a reason for hiding this comment

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

I prefer no curly braces as per tidyverse style.

The {palettizer} package generates a color palette from an image using K-means clustering. The algorithm works as follows:

1. The image is first resized to a smaller version for faster processing.
2. The colors of the image are then represented in the LAB color space, which is more perceptually uniform compared to RGB.
Copy link
Owner

Choose a reason for hiding this comment

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

I think @gvlsq refers to the color space as CIELAB. @gvlsq do you prefer LAB or CIELAB?

Copy link
Owner

Choose a reason for hiding this comment

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


```{r generate-palette}
plt_vector <-
palettizer::plt_tize("lter_penguins.png", cluster_count = 3)
Copy link
Owner

Choose a reason for hiding this comment

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

I don't think you need the palettizer:: since you've already loaded the package, and this can all likely go in a single line.

palettizer::plt_tize("lter_penguins.png", cluster_count = 3)
```

## Create a {ggplot2} plot with the generated color palette
Copy link
Owner

Choose a reason for hiding this comment

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

Suggest: Create a plot with the generated color palette.


## Create a {ggplot2} plot with the generated color palette

Finally, we will create a {ggplot2} plot using the palmerpenguins dataset and apply the generated color palette:
Copy link
Owner

Choose a reason for hiding this comment

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

As above, ggplot2 plot seems redundant here.

scale_color_manual(values = plt_vector) +
labs(
title = "Flipper and bill length",
subtitle = "Dimensions for Adelie, Chinstrap and Gentoo Penguins at Palmer Station LTER",
Copy link
Owner

Choose a reason for hiding this comment

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

Suggest comma after Chinstrap.

flipper_bill
```

This creates a {ggplot2} plot with the color palette generated from the image applied to the data points.
Copy link
Owner

Choose a reason for hiding this comment

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

As above.

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.

Write introductory vignette
2 participants