In the figure the y-axis labels are in decimals from (0 to 1) ie (0.1, 0.2, 0.4 etc). How can I convert this into a % format (10%, 20%, 40% etc). Just 10, 20, 40 also will do.
Thanks, John
g = sns.catplot(x="who", y="survived", col="class",
... data=titanic, saturation=.5,
... kind="bar", ci=None, aspect=.6)
You may use a PercentFormatter
on the axes of the grid.
import seaborn as sns
import matplotlib.pyplot as plt
from matplotlib.ticker import PercentFormatter
titanic = sns.load_dataset("titanic")
g = sns.catplot(x="who", y="survived", col="class",
data=titanic, saturation=.5,
kind="bar", ci=None, aspect=.6)
for ax in g.axes.flat:
ax.yaxis.set_major_formatter(PercentFormatter(1))
plt.show()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.