Seaborn’s set_hls_values() Method Examples
Below are some of the examples of Python Seaborn’s set_hls_values() Method:
Example 1: Customizing Color Palette with set_hls_values()
Method
In this example, we demonstrate how to customize the color palette of a seaborn scatter plot using the set_hls_values()
method. The hue, lightness, and saturation values are adjusted to create a custom color palette with a base palette of ‘red’.
import seaborn as sns
import pandas as pd
# Sample dataset
data = pd.DataFrame({
'x': [1, 2, 3, 4, 5],
'y': [2, 3, 1, 5, 4],
'category': ['A', 'B', 'A', 'B', 'A']
})
sns.set_hls_values(color='husl', h=0.6, l=0.6, s=0.8)
sns.scatterplot(x='x', y='y', hue='category', data=data)
Output:
<Axes: xlabel='x', ylabel='y'>
Python Seaborn’s set_hls_values() Method
Seaborn is a powerful Python data visualization library built on top of Matplotlib. It offers a variety of functions to create visually appealing plots effortlessly. One such function is set_hls_values()
, which allows users to customize the hue, lightness, and saturation values of Seaborn’s default color palette. In this article, we will learn about Python seaborn.set_hls_values() method.