简体   繁体   English

删除 Plotly 平行坐标图末端的刻度标签

[英]Remove tick labels at ends of Plotly parallel coordinates plot

I want to remove the numbers that are circled in this parallel coordinates plot:我想删除在此平行坐标图中圈出的数字:

平行坐标图

Code to generate this plot (taken from Plotly Express example ):生成此图的代码(取自Plotly Express 示例):

import plotly.express as px
df = px.data.iris()
fig = px.parallel_coordinates(df, color="species_id", labels={"species_id": "Species",
                "sepal_width": "Sepal Width", "sepal_length": "Sepal Length",
                "petal_width": "Petal Width", "petal_length": "Petal Length", },
                             color_continuous_scale=px.colors.diverging.Tealrose,
                             color_continuous_midpoint=2)
fig.show()

I tried looking at the docs for ticks but I can't figure it out.我尝试查看文档中的刻度,但我无法弄清楚。 I'm totally new to Plotly.我对 Plotly 完全陌生。

import plotly.express as px
import numpy as np

df = px.data.iris()
fig = px.parallel_coordinates(
    df,
    color="species_id",
    labels={
        "species_id": "Species",
        "sepal_width": "Sepal Width",
        "sepal_length": "Sepal Length",
        "petal_width": "Petal Width",
        "petal_length": "Petal Length",
    },
    color_continuous_scale=px.colors.diverging.Tealrose,
    color_continuous_midpoint=2,
)
fig.show()
fig.update_traces(
    dimensions=[
        {**d, **{"tickvals": np.linspace(min(d["values"]), max(d["values"]), 5)}}
        for d in fig.to_dict()["data"][0]["dimensions"]
    ]
)

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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