简体   繁体   中英

How do I format ticks in a Plotly Express Parallel Coordinates plot?

I'm creating a parallel coordinates plot using Plotly express, but I can't seem to format the ticks on the y-axis how I'd like. You can see in the plot below that the ticks have numbers like 900m; I just want them formatted as 0.9.

情节

This seems to be coming from the exponentformat argument of the y-axis, based on the help string:

exponentformat

Determines a formatting rule for the tick exponents. For example, consider the number 1,000,000,000. If "none", it appears as 1,000,000,000. If "e", 1e+9. If "E", 1E+9. If "power", 1x10^9 (with 9 in a super script). If "SI", 1G. If "B", 1B.

So I've tried to change this argument using the update_yaxes method. However, the plot looks the same. How do I change the tick format to normal decimal numbers like 0.9 instead of 900m?

Code to reproduce the plot (using Plotly version 4.0.0):

import pandas as pd
import numpy as np
import plotly.express as px

data = pd.DataFrame({c: np.random.rand(30) for c in "abcd"})
fig = px.parallel_coordinates(
    data,
    color="d",
    color_continuous_scale=px.colors.sequential.Viridis,
)
fig.update_yaxes(exponentformat="none")
fig.show()

Plotly中的平行坐标图的尺寸不是使用layout.yaxis属性配置的,而是在data[].dimensions[].tickformat ,该文档在此处进行了记录: https : data[].dimensions[].tickformat parcoords维度项维-tickformat

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM