Reputation: 25
How do I format this better? I create unordered pairs from list of columns and plotting them iteratively. I havent managed to remove the axis tick labels. Any suggestions on howto format this better so that I display it in front end?
Upvotes: 0
Views: 2300
Reputation: 31146
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})
Upvotes: 1
Reputation: 584
I suppose you are using plt.subplots(x, y)
here. To remove axes (including there text) completely, you can use subplot[x, y].axis('off')
.
Alternatively, you could add more space in between the plots with plt.margins(x_y_margin)
or plt.margins(x_margin, y_margin)
.
A little bit offtopic: I wouldn't use scatter plots for visualization of classes (like in the plot 2nd row 3rd column).
Upvotes: 1