'Axis labels are not displayed correctly in plotly

When creating a graph using plotly, the labels on the x-axis are not displayed correctly. Here is a picture of the graph enter image description here

generated with the following code:

fig = px.line(
        df,
        x=x_axis,
        y=y_axis,
        color=species,
        color_discrete_sequence=colors,
    )
    fig.update_layout(
#                 title=self.file_name,#グラフタイトル
        font_size=50/5,#文字サイズ
        font_family='Times New Roman',#フォント
        font_color="black",#文字色
    #     title_font_family="Times New Roman",#タイトルフォント
    #     title_font_color="red",#タイトルの文字色
    #     legend_title_font_color="black",#凡例の文字色
        xaxis=dict(
            title=x_axis,
            linewidth=1, mirror=True
        ),fig = px.line(
        df,
        x=x_axis,
        y=y_axis,
        color=species,
        color_discrete_sequence=colors,
    )
    fig.update_layout(
#                 title=self.file_name,#グラフタイトル
        font_size=50/5,#文字サイズ
        font_family='Times New Roman',#フォント
        font_color="black",#文字色
    #     title_font_family="Times New Roman",#タイトルフォント
    #     title_font_color="red",#タイトルの文字色
    #     legend_title_font_color="black",#凡例の文字色
        xaxis=dict(
            title=x_axis,
            linewidth=1, mirror=True
        ),
        yaxis=dict(
            title=y_label,
            linewidth=1, mirror=True
        ),
        xaxis_type="linear",
        yaxis_type="log",
#                 paper_bgcolor='rgba(0,0,0,0)',
#                 plot_bgcolor='rgba(0,0,0,0)',
        template="plotly_white" #テンプレート(他にも以下がある)
    )

fig.write_html(file_name + '.html')

        yaxis=dict(
            title=y_label,
            linewidth=1, mirror=True
        ),
        xaxis_type="linear",
        yaxis_type="log",
#                 paper_bgcolor='rgba(0,0,0,0)',
#                 plot_bgcolor='rgba(0,0,0,0)',
        template="plotly_white" #テンプレート(他にも以下がある)
    )

fig.write_html(file_name + '.html')

The x-axis label should be displayed as Gate, not G. However, it is only displayed as G.

I also tried the below code but without success.

labels={
    x_axis :x_axis
 }
        xaxis=dict(
            title=x_axis,
            linewidth=1, mirror=True
        )

What can I do to fix it?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source