[파이썬] Seaborn 컬러맵 설정

Seaborn is a powerful Python data visualization library built on top of Matplotlib. It provides a high-level interface for creating beautiful and informative statistical graphics. One of the key features of Seaborn is its ability to easily customize the color palettes used in the plots.

In this blog post, we will focus on how to set the color palette in Seaborn using the set_palette() function. We will also explore different built-in color palettes provided by Seaborn.

Setting the Color Palette

The set_palette() function is used to set the color palette in Seaborn. It can be used with both the default Seaborn color palettes or custom color palettes.

To set a color palette, you can simply call the set_palette() function and pass the name of the color palette as a string:

import seaborn as sns

sns.set_palette("deep")

The above code sets the color palette to “deep”. The “deep” palette is a sequential palette that consists of 10 colors, which are deeper versions of the default Seaborn colors.

Built-in Color Palettes

Seaborn provides a wide range of built-in color palettes that can be used to enhance the visual appeal of your plots. Some of the popular built-in color palettes include:

To use a specific built-in color palette, you can pass its name as a parameter to the set_palette() function:

sns.set_palette("bright")

Custom Color Palettes

In addition to the built-in color palettes, Seaborn also allows you to create your own custom color palettes. A custom color palette can be defined as a list of colors in any valid color format, such as RGB (red, green, blue) or HEX (hexadecimal).

To use a custom color palette, you can pass the list of colors to the set_palette() function:

custom_palette = ["#FF0000", "#00FF00", "#0000FF"]
sns.set_palette(custom_palette)

The code above sets a custom color palette consisting of three colors: red, green, and blue.

Conclusion

Setting the color palette in Seaborn is a simple yet effective way to enhance the visual impact of your plots. With the set_palette() function, you can easily switch between built-in color palettes or create your own custom color palettes.

Experiment with different color palettes in your Seaborn plots to find the perfect combination of colors that best represents your data and captures the viewer’s attention.

Happy visualizing in Seaborn!