How to use
Use this to generate a formatter snippet and preview labels for your tick values.
- Select your data scale: 0–1 (fractions) or 0–100 (already percent).
- Set decimals and symbol (usually
%), and pick the target (x-axis, y-axis, or colorbar). - Click Generate to get code plus a quick tick label preview. Copy and paste into your plot.
FAQ
Should I use xmax=1 or xmax=100 in PercentFormatter?
Use xmax=1 when your data is 0–1 fractions, and xmax=100 when your data is already 0–100.
How do I format the y-axis as percent in Matplotlib?
Apply the formatter to ax.yaxis with ax.yaxis.set_major_formatter(...) using either mtick.PercentFormatter or mtick.FuncFormatter.
How do I format the x-axis ticks as percentages?
Use ax.xaxis.set_major_formatter(...) with the same formatter; only the target axis changes.
Why do my percentages look like 2500%?
You likely used xmax=1 while your data is 0–100, or you multiplied by 100 in a custom formatter when the data was already percent.
Can I control decimal places (e.g., 12.5%)?
Yes—set decimals in PercentFormatter or use an f-string format in FuncFormatter.
How do I format a colorbar in percent?
Use cbar.ax.yaxis.set_major_formatter(...) after creating the colorbar.
When should I use FuncFormatter instead of PercentFormatter?
Use FuncFormatter when you want full control (signs, custom text) or need a simple fallback across environments.