Free color tool for figures
Color palette from image: extract the main colors of any figure
Drop in a chart, figure or photo, or paste one from the clipboard, and this color palette generator from image finds its main colors. Copy each one as HEX or RGB, see how much of the image it covers, check that the palette stays distinguishable with color blindness, and export it for matplotlib, ggplot2, CSS or JSON.
- Free, no sign-up
- Runs in your browser, nothing uploaded
- HEX, RGB and share of each color
- Code for matplotlib, ggplot2 and CSS
Drop a figure, chart or photo here, or
Or paste an image with Ctrl+V (Cmd+V on a Mac).
PNG, JPEG or WebP. The image is read in your browser and never uploaded.
Skips near-white and near-black pixels so the palette shows the figure's colors. Turn off for photos where white or black matter.
Your palette appears here
The main colors with HEX, RGB and their share of the image, ready to copy as code and checked for color blindness.
How to use it
Get a color palette from an image in three steps
Load a figure, read its main colors, then copy them as code and check them for color blindness. The image is analysed on this page and never uploaded.
1Drop in a figure
Drop a PNG, JPEG or WebP on the box, choose a file, or paste one with Ctrl+V. Set the number of colors, and keep white and black skipped for figures.
2Read the palette
The main colors appear with HEX, RGB and their share of the image. Click a swatch to copy its HEX code, and order the colors by share, hue or lightness.
3Copy the colors as code
Pick HEX list, CSS variables, matplotlib, ggplot2, MATLAB or JSON and press Copy. Below the code, the color vision check flags pairs that look alike with color blindness.
Six palettes taken from our own figures
Real runs of the tool on figures from this site, with the colors, shares and checks exactly as it reported them, white and black skipped.






Guide
How the palette is built, and how to use it
How the colors are found, why backgrounds are skipped, when you get exact HEX codes, the color blindness check, and how to paste the palette into your code.
How the colors are extracted
To extract a color palette from an image, the tool sorts similar pixels into groups and reports one color per group. It works on a copy of at most 250,000 pixels, sampled without blending so flat colors keep their exact values, and it measures color differences in OKLab, a perceptual color space published by Björn Ottosson in 2020 and now part of CSS Color Module Level 4.
- Pixels are counted by exact color, then gathered into small bins 8 levels wide per channel, so large photos stay fast.
- The starting points are chosen with k-means++ (Arthur and Vassilvitskii, 2007) from 8 fixed seeds, and the run with the lowest error wins, so the same image always gives the same palette.
- k-means then moves each group center to the average of its pixels, again and again, until no pixel changes group.
- Each color's share is the fraction of counted pixels in its group. The list is sorted by share unless you choose hue or lightness.
Pixels in OKLab, grouped by k-means
Across: OKLab a, green to red. Up: OKLab b, blue to yellow.
- #54A6F633%
- #56D06733%
- #F8C02033%
90 pixels scattered around three chart colors, grouped by the same code the tool runs. Each group becomes one swatch.
Ignore white backgrounds and black text
Most figures are largely white page with black labels and axes. Counted as colors, they would fill the palette and push the data colors down to small shares. With Ignore white background and black text switched on, which is the default, the tool skips pixels that are very light with almost no color and pixels that are very dark, then measures the shares on what is left.
- Near-neutral whites and light grays are skipped, including the light gray panel of a default ggplot2 plot. Pale tints such as a light pink or a pastel blue are kept.
- Black and near-black are skipped. Dark grays such as #333333 are kept.
- If an image is almost all white and black, the filter switches itself off, so you still get a palette.
- Turn the switch off for photos, where white snow or a black background can be part of the palette.
Transparent PNGs
Transparent pixels are always skipped, so a chart exported with a transparent background gives the palette of its marks alone.
A bar chart on a white page
All pixels
- #FFFFFF76%
- #1F77B411%
- #FF7F0E6.4%
- #2CA02C3.7%
- #0000003.3%
White and black ignored
- #1F77B451%
- #FF7F0E31%
- #2CA02C18%
Shares measured by the tool on this small chart, with the switch off and on.
Exact HEX codes from charts, averages from photos
Charts drawn in matplotlib, ggplot2, Prism or Excel fill bars and slices with one flat color, but their edges are anti-aliased: a row of in-between pixels blends the fill into the background. An average over the group would drift toward those blends. So when one exact color holds at least a quarter of its group, the tool reports that color itself. In photos and gradients no single value dominates, and the tool reports the group average, marked avg.
- Use PNG rather than JPEG for charts: JPEG compression shifts flat colors by a few levels.
- Ask for more colors than the image has and the blended edge pixels form extra groups with small shares, which tells you they are minor.
- Thin lines are mostly edge pixels, so a line color may come out as an average. Zoom in on the legend or a thick part of the plot for its exact value.
A thin line, enlarged
Most pixels of a thin line are blended with the white page, so the group average comes out lighter. The color that fills the line is reported instead.
Check the palette for color blindness
A palette taken from a photo or from another paper is not automatically readable by everyone. Under the swatches, the tool shows the colors as seen with deuteranopia and protanopia, the complete forms of red-green color vision deficiency, which is the most common kind, using the Machado et al. (2009) simulation at full severity. It flags any pair that is clearly different in normal vision but falls below a CIEDE2000 difference of 10 after simulation.
- ggplot2's default colors for three groups, #F8766D, #00BA38 and #619CFF, are a typical case: the red and the green fall to a difference of about 6 with deuteranopia.
- If a pair is flagged, change one of the two colors, or make sure the groups also differ by marker shape, line style or a direct label.
- To see the whole figure rather than its palette, open it in the Colorblind Simulator.
ggplot2's default colors for three groups
Red and green: ΔE 5.9 with deuteranopia
Machado et al. (2009) simulation at full severity; ΔE is the CIEDE2000 difference between the simulated colors.
Use the colors in matplotlib, ggplot2 and CSS
Pick an export format, copy it, and paste it into your code. The colors come out in the order shown, so sort them by share, hue or lightness first.
- Python matplotlib: sets the default color cycle with cycler, so each new line or bar series takes the next color.
- R ggplot2: a pal vector for scale_color_manual(values = pal). Use scale_fill_manual for bars and areas.
- CSS variables: --palette-1, --palette-2 and so on, for web figures and slides built in HTML.
- MATLAB, a plain HEX list, and JSON with each color's RGB values and share are there too.
Ordered groups
For groups with an order, such as doses or time points, sort by lightness so the colors step from dark to light.
# Python · matplotlib
import matplotlib.pyplot as plt from cycler import cycler colors = ["#48A4FE", "#57CF62", "#FDBF1C", "#FE4546"] plt.rcParams['axes.prop_cycle'] = cycler(color=colors)
# R · ggplot2
pal <- c("#48A4FE", "#57CF62", "#FDBF1C", "#FE4546")
# ggplot(df, aes(x, y, color = group)) + geom_point() +
scale_color_manual(values = pal)Copy the format you need; the colors keep the order shown in the tool.
Frequently asked questions
Quick answers on extracting a palette, privacy, colors that differ slightly, how many colors to ask for, shares, and colorblind-safe palettes.
How do I get a color palette from an image?
Drop the image on the tool above, choose it from your files, or paste it with Ctrl+V (Cmd+V on a Mac). The main colors appear at once with HEX, RGB and their share of the image. Set the number of colors from 3 to 12, then copy a swatch or export the whole palette as code.
Is my image uploaded anywhere?
No. The image is decoded and analysed by JavaScript in your browser, and nothing is sent to a server. The same goes for the color blindness check and the code exports.
Why is a color slightly different from the one I used in my chart?
JPEG compression shifts flat colors by a few levels, so export charts as PNG. Thin lines are mostly blended edge pixels, so no single value dominates and you get an average, marked avg. Colors without that mark occur in the image exactly as shown.
How many colors should I extract?
Start with the number of groups in the figure plus one or two. For a chart with four series, try six: the four fills and room for grays or edge blends. If the palette shows near-duplicates with small shares, lower the number; if two distinct colors are merged into one, raise it.
What does the percentage next to each color mean?
It is the share of counted pixels in that color's group. With the background filter on, white and black pixels are left out first, so the shares describe the colored part of the figure. The bar above the swatches shows the same shares as widths.
Can I get a colorblind-safe palette from my image?
The tool tells you whether the extracted colors stay apart with deuteranopia and protanopia, but it does not change them. If a pair is flagged, swap one color of the pair for one from a tested set such as Okabe-Ito, listed with HEX codes on the colorblind friendly palette page.
How is this different from a color picker?
A color picker gives the value of the one pixel you click. This tool looks at every sampled pixel and sums the image up as a few representative colors with their shares, which is what you need to reuse the palette of a figure.
Related tools
Check the colors for accessibility, convert them for print, or build a chart in them.
Colorblind friendly palette
Okabe-Ito, Paul Tol, viridis and more, with checked HEX codes and code for matplotlib and ggplot2.
Colorblind simulator
Preview a whole figure with deuteranopia, protanopia and tritanopia, and flag clashing colors.
RGB to CMYK converter
Convert HEX and RGB colors to CMYK values, or a whole figure to a CMYK TIFF.
Heatmap generator
Turn a data matrix into a heatmap with a sequential or diverging color scale.
Bar chart generator
Upload a CSV or Excel file and get a bar chart with error bars, in the colors you ask for.
Journal figure requirements
Column widths, resolution, file formats and color mode from the guides of 14 publishers.
Use your palette in a new chart
Upload a CSV or Excel file to the bar chart generator and describe the colors you want, for example with the HEX codes from your palette.
Open the bar chart generator





