> For the complete documentation index, see [llms.txt](https://www.microbiomestat.wiki/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.microbiomestat.wiki/data-manipulation-and-transformation/color-palette.md).

# Color Palette

## Custom Color Palette Retrieval

### mStat\_get\_palette Function

Choosing the right color palette is essential for creating visually appealing and informative data visualizations. The `mStat_get_palette()` function in MicrobiomeStat allows users to easily access and utilize a variety of color palettes, especially those inspired by and sourced from the scientific publication realm, through the `ggsci` package.

#### Overview

`mStat_get_palette()` is tailored for users who need predefined or custom color palettes for their data visualizations in R. It offers an extensive selection from the `ggsci` package, known for its scientific journal-inspired palettes, as well as the flexibility to specify custom color sets.

**Functionality:**

* Access predefined palettes like 'npg', 'aaas', 'nejm', 'lancet', 'jama', 'jco', and 'ucscgb' from the `ggsci` package.
* Provide a vector of custom color codes.
* Return a default palette in case of `NULL` input or unrecognized palette names.

#### Usage

```r
# Default palette
mStat_get_palette()

# Predefined `ggsci` palette: 'nejm'
mStat_get_palette("nejm")

# Custom color vector
mStat_get_palette(c("#123456", "#654321"))
```

#### Parameters

* `palette`: A character string for predefined palettes or a vector of color codes. If `NULL` or unrecognized, a default palette is used.

#### Details

Here's a glimpse into the functioning of `mStat_get_palette()`:

* It first checks if the `palette` parameter is `NULL`, a character string, or a vector.
* For a character string, it verifies if the name matches one of the predefined palettes in the `ggsci` database.
* If a match is found, the corresponding palette is returned.
* For a vector input, the vector itself is returned as the palette.
* In case of `NULL` or an unrecognized input, a default set of colors is provided.

#### Applications

This function is highly beneficial for:

* Enhancing the visual appeal of data plots in scientific publications.
* Customizing color schemes to match specific publication or presentation themes.
* Ensuring consistency and accuracy of color representation in multiple visualizations.

#### Visual Representation

* npg

<figure><img src="https://3375851868-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhFAmY4z7d1R15Cv49vXQ%2Fuploads%2F0P1uwvzksQA6XZzBPQcP%2FScreenshot%202024-01-10%20at%2015.26.49.png?alt=media&amp;token=54aceda4-ab4c-4af2-934e-d33a14ad6509" alt=""><figcaption></figcaption></figure>

* lancet

<figure><img src="https://3375851868-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhFAmY4z7d1R15Cv49vXQ%2Fuploads%2FxONmpQiHNtqzBa8qTRJz%2FScreenshot%202024-01-10%20at%2015.27.24.png?alt=media&amp;token=ebc71dd7-d18b-4ae4-b324-c1f3a3d23ff4" alt=""><figcaption></figcaption></figure>

* aaas

<figure><img src="https://3375851868-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhFAmY4z7d1R15Cv49vXQ%2Fuploads%2F0bEYMWrUQUkVktUiIPIW%2FScreenshot%202024-01-10%20at%2015.27.06.png?alt=media&amp;token=9ba4550c-a14b-42a1-8e6a-95719e0ac9f1" alt=""><figcaption></figcaption></figure>

* nejm

<figure><img src="https://3375851868-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhFAmY4z7d1R15Cv49vXQ%2Fuploads%2FuS6KmJWD6kmiyYCHRLBW%2FScreenshot%202024-01-10%20at%2015.28.02.png?alt=media&amp;token=a6848143-d17b-4246-bf28-19c7cefbc33b" alt=""><figcaption></figcaption></figure>

* jama

<figure><img src="https://3375851868-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhFAmY4z7d1R15Cv49vXQ%2Fuploads%2FUXvNbh4WD9eF9BPalVbO%2FScreenshot%202024-01-10%20at%2015.28.41.png?alt=media&amp;token=6fb7de49-fb0f-4fbf-951e-090a4a753954" alt=""><figcaption></figcaption></figure>

* jco

<figure><img src="https://3375851868-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhFAmY4z7d1R15Cv49vXQ%2Fuploads%2FiYtJX0QmnLgE05xbAj1G%2FScreenshot%202024-01-10%20at%2015.30.36.png?alt=media&amp;token=7d602103-34e3-498b-b486-a6b350380772" alt=""><figcaption></figcaption></figure>

* ucscgb

<figure><img src="https://3375851868-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhFAmY4z7d1R15Cv49vXQ%2Fuploads%2F3LmKGgaMjMgOFmWCJPRz%2FScreenshot%202024-01-10%20at%2015.31.27.png?alt=media&amp;token=bae369a0-1925-4988-9c03-e39208374450" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://www.microbiomestat.wiki/data-manipulation-and-transformation/color-palette.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
