如何从绘图中删除绘图中的轴刻度线?

How to remove the axes tick marks in plots from plotly?

我如何更好地格式化它?我从列列表中创建无序对并迭代地绘制它们。我还没有设法删除轴刻度标签。关于如何更好地格式化以便我在前端显示它的任何建议?

我想你在这里使用 plt.subplots(x, y)。要完全删除轴(包括文本),您可以使用 subplot[x, y].axis('off').
或者,您可以在 plt.margins(x_y_margin)plt.margins(x_margin, y_margin).

的地块之间添加更多 space

有点离题:我不会使用散点图来可视化 类(就像图中第 2 行第 3 列)。

  • 你没有说明你是如何构建子图的
  • 您可以使用 fig.update_layout({ax:{"visible":False, "matches":None} for ax in fig.to_dict()["layout"] if "axis" in ax})
  • 使所有轴不可见
  • 完整示例代码:
import numpy as np
import pandas as pd
import plotly.express as px

L = 100
df = pd.DataFrame(
    {
        "lin": np.linspace(0, 100, L),
        "cos": np.cos(np.linspace(0, np.pi, L)),
        "sin": np.sin(np.linspace(0, np.pi, L)),
        "tan": np.tan(np.linspace(0, np.pi, L)),
        "char": np.random.choice(list("ABCDEF"), L),
        "rand": np.random.uniform(1,50, L)
    }
)

fig = px.scatter(
    df.stack().reset_index(), x="level_0", y=0, facet_col="level_1", facet_col_wrap=3
)
fig.update_layout({ax:{"visible":False, "matches":None} for ax in fig.to_dict()["layout"] if "axis" in ax})
  • 所有列对所有列的矩阵。隐藏刻度线
px.scatter_matrix(df).update_layout({ax:{"tickmode":"array","tickvals":[]} for ax in fig.to_dict()["layout"] if "axis" in ax})