簡體   English   中英

在 plotly 快遞中,如何重命名軸和我的圖例名稱? y 軸僅顯示為值,圖例上的標題是可變的

[英]In plotly express, how can I rename the axes and the name of my legend? The y-axis is only showing as values and the title on the legend is variable

我的代碼:

#成功啟動的行 plot 由啟動板用顏色編碼

launch_sum = pd.get_dummies(spacex_df,columns=["launchpad"])[["year","launchpad_CCSFS SLC 40","launchpad_KSC LC 39A","launchpad_VAFB SLC 4E","launch_success_True","launch_success_False"]]
launch_sum.rename(columns={"launchpad_CCSFS SLC 40":"CCSFS SLC 40","launchpad_KSC LC 39A":"KSC LC 39A","launchpad_VAFB SLC 4E":"VAFB SLC 4E"},inplace=True)
launch_sum = launch_sum.groupby("year").sum()

px.line(launch_sum, y=["CCSFS SLC 40","KSC LC 39A","VAFB SLC 4E"],title="The Total Annual Attempted Launches")

output 是 plot 但我無法更改 ylabel 和圖例的標題。 [1]: https://i.stack.imgur.com/feBYt.png

在布局中更新適當標題的簡單案例

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

launch_sum = pd.DataFrame(
    {
        c: np.random.randint(1, 8, 8)
        for c in ["CCSFS SLC 40", "KSC LC 39A", "VAFB SLC 4E"]
    },
    index=range(2018, 2018 + 8),
)

px.line(
    launch_sum,
    y=["CCSFS SLC 40", "KSC LC 39A", "VAFB SLC 4E"],
    title="The Total Annual Attempted Launches",
).update_layout(yaxis={"title": "some text"}, legend={"title":"column"})

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM